From 82ec59a2b0ae272e1df3889ff0f5110a7697c4c2 Mon Sep 17 00:00:00 2001 From: Tim Sylvester Date: Wed, 13 Sep 2023 11:35:20 -0700 Subject: [PATCH] Metal setup merge (#1616) Signed-off-by: dependabot[bot] Co-authored-by: Alex Cristici Co-authored-by: mwilsnd Co-authored-by: Stefan Karschti Co-authored-by: Bart Louwers Co-authored-by: Alex Cristici Co-authored-by: Bart Louwers Co-authored-by: Wei Chen Co-authored-by: Siarhei Fedartsou Co-authored-by: tdcosta100 --- .github/workflows/ios-ci.yml | 2 +- BUILD.bazel | 67 +- CMakeLists.txt | 93 +- bazel/core.bzl | 116 +- benchmark/CMakeLists.txt | 4 + bin/CMakeLists.txt | 4 + include/mbgl/gfx/backend.hpp | 5 + include/mbgl/gfx/drawable.hpp | 4 +- include/mbgl/gfx/uniform_buffer.hpp | 7 +- include/mbgl/gfx/vertex_attribute.hpp | 57 +- include/mbgl/mtl/buffer_resource.hpp | 42 + include/mbgl/mtl/command_encoder.hpp | 73 + include/mbgl/mtl/context.hpp | 124 + include/mbgl/mtl/drawable.hpp | 78 + include/mbgl/mtl/drawable_builder.hpp | 28 + include/mbgl/mtl/drawable_mtl.hpp | 0 include/mbgl/mtl/drawable_mtl_builder.hpp | 0 include/mbgl/mtl/drawable_mtl_tweaker.hpp | 0 include/mbgl/mtl/index_buffer_resource.hpp | 27 + include/mbgl/mtl/layer_group.hpp | 23 + include/mbgl/mtl/mtl_fwd.hpp | 60 + include/mbgl/mtl/render_pass.hpp | 42 + include/mbgl/mtl/renderable_resource.hpp | 30 + include/mbgl/mtl/renderer_backend.hpp | 67 + include/mbgl/mtl/shader_program_mtl.hpp | 0 include/mbgl/mtl/texture2d.hpp | 78 + include/mbgl/mtl/tile_layer_group.hpp | 23 + include/mbgl/mtl/uniform_block.hpp | 66 + include/mbgl/mtl/uniform_buffer.hpp | 49 + include/mbgl/mtl/upload_pass.hpp | 98 + include/mbgl/mtl/vertex_attribute.hpp | 75 + include/mbgl/mtl/vertex_buffer_resource.hpp | 27 + include/mbgl/renderer/layer_tweaker.hpp | 35 +- include/mbgl/shaders/background_layer_ubo.hpp | 44 + include/mbgl/shaders/circle_layer_ubo.hpp | 66 + include/mbgl/shaders/fill_layer_ubo.hpp | 166 ++ include/mbgl/shaders/gl/drawable_fill.hpp | 55 +- .../mbgl/shaders/gl/drawable_fill_outline.hpp | 56 +- .../gl/drawable_fill_outline_pattern.hpp | 52 +- .../mbgl/shaders/gl/drawable_fill_pattern.hpp | 54 +- include/mbgl/shaders/gl/drawable_line_sdf.hpp | 2 + .../mbgl/shaders/gl/drawable_symbol_icon.hpp | 7 +- .../shaders/gl/drawable_symbol_sdf_icon.hpp | 14 +- .../shaders/gl/drawable_symbol_sdf_text.hpp | 14 +- .../gl/drawable_symbol_text_and_icon.hpp | 14 +- include/mbgl/shaders/gl/hillshade_prepare.hpp | 2 +- include/mbgl/shaders/layer_ubo.hpp | 52 + include/mbgl/shaders/line_layer_ubo.hpp | 158 ++ include/mbgl/shaders/mtl/background.hpp | 66 + .../mbgl/shaders/mtl/background_pattern.hpp | 20 + include/mbgl/shaders/mtl/circle.hpp | 193 ++ include/mbgl/shaders/mtl/common.hpp | 207 ++ include/mbgl/shaders/mtl/fill.hpp | 476 ++++ include/mbgl/shaders/mtl/line.hpp | 141 + include/mbgl/shaders/mtl/line_gradient.hpp | 148 ++ include/mbgl/shaders/mtl/raster.hpp | 125 + include/mbgl/shaders/mtl/shader_group.hpp | 76 + include/mbgl/shaders/mtl/shader_program.hpp | 79 + include/mbgl/shaders/raster_layer_ubo.hpp | 28 + include/mbgl/shaders/shader_manifest.hpp | 2 +- include/mbgl/util/convert.hpp | 2 + platform/BUILD.bazel | 54 +- .../android/MapboxGLAndroidSDK/build.gradle | 8 +- .../MapboxGLAndroidSDKTestApp/build.gradle | 2 +- platform/darwin/BUILD.bazel | 39 +- platform/darwin/bazel/files.bzl | 12 +- platform/darwin/src/MLNStyle.mm | 5 +- platform/darwin/src/MLNStyleLayerManager.mm | 5 +- platform/darwin/test/MLNStyleTests.mm | 2 + platform/default/BUILD.bazel | 10 +- .../include/mbgl/gfx/headless_backend.hpp | 4 + .../src/mbgl/layermanager/layer_manager.cpp | 2 +- platform/glfw/CMakeLists.txt | 2 +- platform/glfw/glfw_view.cpp | 12 +- platform/glfw/glfw_view.hpp | 4 +- platform/ios/BUILD.bazel | 27 +- platform/ios/app/MBXViewController.m | 11 +- platform/ios/bazel/files.bzl | 8 +- platform/ios/scripts/bazel-generate-plists.sh | 1 + platform/ios/scripts/bazel-xcodeproj.sh | 6 +- platform/ios/src/MLNMapView+Impl.mm | 12 +- platform/ios/src/MLNMapView+Metal.h | 54 + platform/ios/src/MLNMapView+Metal.mm | 212 ++ platform/ios/src/Mapbox.h | 4 +- platform/ios/test/BUILD.bazel | 3 + platform/macos/BUILD.bazel | 10 +- platform/macos/bazel/files.bzl | 7 +- platform/macos/src/MLNMapView+Impl.mm | 7 +- render-test/CMakeLists.txt | 4 + shaders/drawable.fill.fragment.glsl | 28 +- shaders/drawable.fill.vertex.glsl | 25 +- shaders/drawable.fill_outline.fragment.glsl | 29 +- shaders/drawable.fill_outline.vertex.glsl | 27 +- ...rawable.fill_outline_pattern.fragment.glsl | 26 +- .../drawable.fill_outline_pattern.vertex.glsl | 26 +- shaders/drawable.fill_pattern.fragment.glsl | 27 +- shaders/drawable.fill_pattern.vertex.glsl | 27 +- shaders/drawable.line_sdf.fragment.glsl | 1 + shaders/drawable.line_sdf.vertex.glsl | 1 + shaders/generate_shader_code.js | 2 +- shaders/hillshade_prepare.fragment.glsl | 2 +- src/mbgl/gfx/command_encoder.hpp | 4 +- src/mbgl/gfx/drawable_builder.cpp | 1 + src/mbgl/gfx/index_vector.hpp | 4 +- src/mbgl/gfx/render_pass.hpp | 2 +- src/mbgl/gfx/upload_pass.hpp | 2 + src/mbgl/gfx/vertex_attribute.cpp | 14 + src/mbgl/gfx/vertex_vector.hpp | 2 +- src/mbgl/gl/command_encoder.cpp | 2 +- src/mbgl/gl/command_encoder.hpp | 2 +- src/mbgl/gl/context.cpp | 7 +- src/mbgl/gl/drawable_gl.cpp | 1 + src/mbgl/gl/drawable_gl_impl.hpp | 1 + src/mbgl/gl/program.hpp | 18 +- src/mbgl/gl/uniform_buffer_gl.cpp | 2 +- src/mbgl/mtl/buffer_resource.cpp | 44 + src/mbgl/mtl/command_encoder.cpp | 92 + src/mbgl/mtl/context.cpp | 210 ++ src/mbgl/mtl/drawable.cpp | 517 ++++ src/mbgl/mtl/drawable_builder.cpp | 49 + src/mbgl/mtl/drawable_impl.hpp | 68 + src/mbgl/mtl/drawable_mtl.cpp | 0 src/mbgl/mtl/drawable_mtl_builder.cpp | 0 src/mbgl/mtl/drawable_mtl_tweaker.cpp | 0 src/mbgl/mtl/layer_group.cpp | 60 + src/mbgl/mtl/mtl.cpp | 9 + src/mbgl/mtl/render_pass.cpp | 94 + src/mbgl/mtl/renderer_backend.cpp | 138 + src/mbgl/mtl/texture2d.cpp | 201 ++ src/mbgl/mtl/tile_layer_group.cpp | 113 + src/mbgl/mtl/uniform_block.cpp | 17 + src/mbgl/mtl/uniform_buffer.cpp | 30 + src/mbgl/mtl/upload_pass.cpp | 268 ++ src/mbgl/mtl/vertex_attribute.cpp | 100 + src/mbgl/programs/program.hpp | 8 +- src/mbgl/programs/program_parameters.cpp | 34 +- src/mbgl/programs/program_parameters.hpp | 15 +- src/mbgl/programs/symbol_program.hpp | 4 +- src/mbgl/renderer/layer_tweaker.cpp | 48 +- .../layers/background_layer_tweaker.cpp | 45 +- .../layers/background_layer_tweaker.hpp | 4 +- .../renderer/layers/circle_layer_tweaker.cpp | 120 +- .../renderer/layers/circle_layer_tweaker.hpp | 14 +- .../layers/collision_layer_tweaker.hpp | 4 +- .../layers/fill_extrusion_layer_tweaker.cpp | 13 +- .../layers/fill_extrusion_layer_tweaker.hpp | 4 +- .../renderer/layers/fill_layer_tweaker.cpp | 301 ++- .../renderer/layers/fill_layer_tweaker.hpp | 39 +- .../renderer/layers/heatmap_layer_tweaker.hpp | 4 +- .../layers/heatmap_texture_layer_tweaker.hpp | 4 +- .../layers/hillshade_layer_tweaker.hpp | 4 +- .../hillshade_prepare_layer_tweaker.hpp | 4 +- .../renderer/layers/line_layer_tweaker.cpp | 217 +- .../renderer/layers/line_layer_tweaker.hpp | 10 +- .../renderer/layers/raster_layer_tweaker.cpp | 22 +- .../renderer/layers/raster_layer_tweaker.hpp | 4 +- .../layers/render_background_layer.cpp | 5 +- .../layers/render_background_layer.hpp | 1 + .../renderer/layers/render_circle_layer.cpp | 94 +- .../renderer/layers/render_circle_layer.hpp | 29 +- .../renderer/layers/render_custom_layer.cpp | 1 + .../renderer/layers/render_custom_layer.hpp | 1 + .../layers/render_fill_extrusion_layer.cpp | 8 +- .../layers/render_fill_extrusion_layer.hpp | 1 + .../renderer/layers/render_fill_layer.cpp | 289 ++- .../renderer/layers/render_fill_layer.hpp | 17 + .../renderer/layers/render_heatmap_layer.cpp | 13 +- .../renderer/layers/render_heatmap_layer.hpp | 1 + .../layers/render_hillshade_layer.cpp | 8 +- .../layers/render_hillshade_layer.hpp | 1 + .../renderer/layers/render_line_layer.cpp | 279 +- .../renderer/layers/render_line_layer.hpp | 14 + .../renderer/layers/render_raster_layer.cpp | 30 +- .../renderer/layers/render_raster_layer.hpp | 13 + .../renderer/layers/render_symbol_layer.cpp | 11 +- .../renderer/layers/render_symbol_layer.hpp | 1 + .../renderer/layers/symbol_layer_tweaker.cpp | 31 +- .../renderer/layers/symbol_layer_tweaker.hpp | 4 +- src/mbgl/renderer/paint_parameters.cpp | 6 +- src/mbgl/renderer/paint_parameters.hpp | 18 +- src/mbgl/renderer/pattern_atlas.cpp | 4 +- src/mbgl/renderer/render_layer.hpp | 9 +- src/mbgl/renderer/render_orchestrator.cpp | 7 +- src/mbgl/renderer/render_orchestrator.hpp | 1 + src/mbgl/renderer/renderer_impl.cpp | 49 +- src/mbgl/renderer/renderer_impl.hpp | 2 + .../renderer/sources/render_tile_source.cpp | 8 +- src/mbgl/shaders/gl/shader_program_gl.cpp | 4 +- src/mbgl/shaders/mtl/shader_program.cpp | 192 ++ src/mbgl/shaders/mtl/shader_program_mtl.cpp | 11 - src/mbgl/style/properties.hpp | 5 + test/CMakeLists.txt | 2 +- test/gl/bucket.test.cpp | 10 +- vendor/BUILD.bazel | 9 + vendor/metal-cpp/Foundation/Foundation.hpp | 47 + vendor/metal-cpp/Foundation/NSArray.hpp | 115 + .../Foundation/NSAutoreleasePool.hpp | 83 + vendor/metal-cpp/Foundation/NSBundle.hpp | 374 +++ vendor/metal-cpp/Foundation/NSData.hpp | 54 + vendor/metal-cpp/Foundation/NSDate.hpp | 53 + vendor/metal-cpp/Foundation/NSDefines.hpp | 45 + vendor/metal-cpp/Foundation/NSDictionary.hpp | 128 + vendor/metal-cpp/Foundation/NSEnumerator.hpp | 78 + vendor/metal-cpp/Foundation/NSError.hpp | 173 ++ vendor/metal-cpp/Foundation/NSLock.hpp | 118 + .../metal-cpp/Foundation/NSNotification.hpp | 110 + vendor/metal-cpp/Foundation/NSNumber.hpp | 501 ++++ vendor/metal-cpp/Foundation/NSObjCRuntime.hpp | 43 + vendor/metal-cpp/Foundation/NSObject.hpp | 302 +++ vendor/metal-cpp/Foundation/NSPrivate.hpp | 507 ++++ vendor/metal-cpp/Foundation/NSProcessInfo.hpp | 354 +++ vendor/metal-cpp/Foundation/NSRange.hpp | 83 + vendor/metal-cpp/Foundation/NSSet.hpp | 87 + vendor/metal-cpp/Foundation/NSSharedPtr.hpp | 311 +++ vendor/metal-cpp/Foundation/NSString.hpp | 255 ++ vendor/metal-cpp/Foundation/NSTypes.hpp | 51 + vendor/metal-cpp/Foundation/NSURL.hpp | 90 + vendor/metal-cpp/LICENSE.txt | 202 ++ .../Metal/MTLAccelerationStructure.hpp | 1081 ++++++++ ...MTLAccelerationStructureCommandEncoder.hpp | 290 +++ .../Metal/MTLAccelerationStructureTypes.hpp | 169 ++ vendor/metal-cpp/Metal/MTLArgument.hpp | 841 ++++++ vendor/metal-cpp/Metal/MTLArgumentEncoder.hpp | 241 ++ vendor/metal-cpp/Metal/MTLBinaryArchive.hpp | 139 + .../metal-cpp/Metal/MTLBlitCommandEncoder.hpp | 246 ++ vendor/metal-cpp/Metal/MTLBlitPass.hpp | 165 ++ vendor/metal-cpp/Metal/MTLBuffer.hpp | 109 + vendor/metal-cpp/Metal/MTLCaptureManager.hpp | 220 ++ vendor/metal-cpp/Metal/MTLCaptureScope.hpp | 92 + vendor/metal-cpp/Metal/MTLCommandBuffer.hpp | 474 ++++ vendor/metal-cpp/Metal/MTLCommandEncoder.hpp | 101 + vendor/metal-cpp/Metal/MTLCommandQueue.hpp | 89 + .../Metal/MTLComputeCommandEncoder.hpp | 330 +++ vendor/metal-cpp/Metal/MTLComputePass.hpp | 181 ++ vendor/metal-cpp/Metal/MTLComputePipeline.hpp | 373 +++ vendor/metal-cpp/Metal/MTLCounters.hpp | 258 ++ vendor/metal-cpp/Metal/MTLDefines.hpp | 41 + vendor/metal-cpp/Metal/MTLDepthStencil.hpp | 269 ++ vendor/metal-cpp/Metal/MTLDevice.hpp | 1374 ++++++++++ vendor/metal-cpp/Metal/MTLDrawable.hpp | 99 + vendor/metal-cpp/Metal/MTLDynamicLibrary.hpp | 82 + vendor/metal-cpp/Metal/MTLEvent.hpp | 159 ++ vendor/metal-cpp/Metal/MTLFence.hpp | 57 + .../Metal/MTLFunctionConstantValues.hpp | 85 + .../metal-cpp/Metal/MTLFunctionDescriptor.hpp | 156 ++ vendor/metal-cpp/Metal/MTLFunctionHandle.hpp | 61 + vendor/metal-cpp/Metal/MTLFunctionLog.hpp | 114 + .../metal-cpp/Metal/MTLFunctionStitching.hpp | 305 +++ vendor/metal-cpp/Metal/MTLHeaderBridge.hpp | 2300 +++++++++++++++++ vendor/metal-cpp/Metal/MTLHeap.hpp | 329 +++ vendor/metal-cpp/Metal/MTLIOCommandBuffer.hpp | 200 ++ vendor/metal-cpp/Metal/MTLIOCommandQueue.hpp | 225 ++ vendor/metal-cpp/Metal/MTLIOCompressor.hpp | 92 + .../Metal/MTLIndirectCommandBuffer.hpp | 212 ++ .../Metal/MTLIndirectCommandEncoder.hpp | 187 ++ .../Metal/MTLIntersectionFunctionTable.hpp | 163 ++ vendor/metal-cpp/Metal/MTLLibrary.hpp | 691 +++++ vendor/metal-cpp/Metal/MTLLinkedFunctions.hpp | 115 + .../Metal/MTLParallelRenderCommandEncoder.hpp | 94 + vendor/metal-cpp/Metal/MTLPipeline.hpp | 109 + vendor/metal-cpp/Metal/MTLPixelFormat.hpp | 173 ++ vendor/metal-cpp/Metal/MTLPrivate.hpp | 156 ++ .../metal-cpp/Metal/MTLRasterizationRate.hpp | 386 +++ .../Metal/MTLRenderCommandEncoder.hpp | 1145 ++++++++ vendor/metal-cpp/Metal/MTLRenderPass.hpp | 786 ++++++ vendor/metal-cpp/Metal/MTLRenderPipeline.hpp | 1598 ++++++++++++ vendor/metal-cpp/Metal/MTLResource.hpp | 178 ++ .../Metal/MTLResourceStateCommandEncoder.hpp | 103 + .../metal-cpp/Metal/MTLResourceStatePass.hpp | 165 ++ vendor/metal-cpp/Metal/MTLSampler.hpp | 319 +++ .../Metal/MTLStageInputOutputDescriptor.hpp | 381 +++ vendor/metal-cpp/Metal/MTLTexture.hpp | 684 +++++ vendor/metal-cpp/Metal/MTLTypes.hpp | 168 ++ vendor/metal-cpp/Metal/MTLVersion.hpp | 32 + .../metal-cpp/Metal/MTLVertexDescriptor.hpp | 344 +++ .../Metal/MTLVisibleFunctionTable.hpp | 104 + vendor/metal-cpp/Metal/Metal.hpp | 84 + vendor/metal-cpp/QuartzCore/CADefines.hpp | 41 + .../metal-cpp/QuartzCore/CAMetalDrawable.hpp | 57 + vendor/metal-cpp/QuartzCore/CAMetalLayer.hpp | 131 + vendor/metal-cpp/QuartzCore/CAPrivate.hpp | 132 + vendor/metal-cpp/QuartzCore/QuartzCore.hpp | 28 + vendor/metal-cpp/README.md | 310 +++ .../SingleHeader/MakeSingleHeader.py | 271 ++ 284 files changed, 32357 insertions(+), 1155 deletions(-) create mode 100644 include/mbgl/mtl/buffer_resource.hpp create mode 100644 include/mbgl/mtl/command_encoder.hpp create mode 100644 include/mbgl/mtl/context.hpp create mode 100644 include/mbgl/mtl/drawable.hpp create mode 100644 include/mbgl/mtl/drawable_builder.hpp delete mode 100644 include/mbgl/mtl/drawable_mtl.hpp delete mode 100644 include/mbgl/mtl/drawable_mtl_builder.hpp delete mode 100644 include/mbgl/mtl/drawable_mtl_tweaker.hpp create mode 100644 include/mbgl/mtl/index_buffer_resource.hpp create mode 100644 include/mbgl/mtl/layer_group.hpp create mode 100644 include/mbgl/mtl/mtl_fwd.hpp create mode 100644 include/mbgl/mtl/render_pass.hpp create mode 100644 include/mbgl/mtl/renderable_resource.hpp create mode 100644 include/mbgl/mtl/renderer_backend.hpp delete mode 100644 include/mbgl/mtl/shader_program_mtl.hpp create mode 100644 include/mbgl/mtl/texture2d.hpp create mode 100644 include/mbgl/mtl/tile_layer_group.hpp create mode 100644 include/mbgl/mtl/uniform_block.hpp create mode 100644 include/mbgl/mtl/uniform_buffer.hpp create mode 100644 include/mbgl/mtl/upload_pass.hpp create mode 100644 include/mbgl/mtl/vertex_attribute.hpp create mode 100644 include/mbgl/mtl/vertex_buffer_resource.hpp create mode 100644 include/mbgl/shaders/background_layer_ubo.hpp create mode 100644 include/mbgl/shaders/circle_layer_ubo.hpp create mode 100644 include/mbgl/shaders/fill_layer_ubo.hpp create mode 100644 include/mbgl/shaders/layer_ubo.hpp create mode 100644 include/mbgl/shaders/line_layer_ubo.hpp create mode 100644 include/mbgl/shaders/mtl/background.hpp create mode 100644 include/mbgl/shaders/mtl/background_pattern.hpp create mode 100644 include/mbgl/shaders/mtl/circle.hpp create mode 100644 include/mbgl/shaders/mtl/common.hpp create mode 100644 include/mbgl/shaders/mtl/fill.hpp create mode 100644 include/mbgl/shaders/mtl/line.hpp create mode 100644 include/mbgl/shaders/mtl/line_gradient.hpp create mode 100644 include/mbgl/shaders/mtl/raster.hpp create mode 100644 include/mbgl/shaders/mtl/shader_group.hpp create mode 100644 include/mbgl/shaders/mtl/shader_program.hpp create mode 100644 include/mbgl/shaders/raster_layer_ubo.hpp create mode 100644 platform/ios/src/MLNMapView+Metal.h create mode 100644 platform/ios/src/MLNMapView+Metal.mm create mode 100644 src/mbgl/mtl/buffer_resource.cpp create mode 100644 src/mbgl/mtl/command_encoder.cpp create mode 100644 src/mbgl/mtl/context.cpp create mode 100644 src/mbgl/mtl/drawable.cpp create mode 100644 src/mbgl/mtl/drawable_builder.cpp create mode 100644 src/mbgl/mtl/drawable_impl.hpp delete mode 100644 src/mbgl/mtl/drawable_mtl.cpp delete mode 100644 src/mbgl/mtl/drawable_mtl_builder.cpp delete mode 100644 src/mbgl/mtl/drawable_mtl_tweaker.cpp create mode 100644 src/mbgl/mtl/layer_group.cpp create mode 100644 src/mbgl/mtl/mtl.cpp create mode 100644 src/mbgl/mtl/render_pass.cpp create mode 100644 src/mbgl/mtl/renderer_backend.cpp create mode 100644 src/mbgl/mtl/texture2d.cpp create mode 100644 src/mbgl/mtl/tile_layer_group.cpp create mode 100644 src/mbgl/mtl/uniform_block.cpp create mode 100644 src/mbgl/mtl/uniform_buffer.cpp create mode 100644 src/mbgl/mtl/upload_pass.cpp create mode 100644 src/mbgl/mtl/vertex_attribute.cpp create mode 100644 src/mbgl/shaders/mtl/shader_program.cpp delete mode 100644 src/mbgl/shaders/mtl/shader_program_mtl.cpp create mode 100644 vendor/metal-cpp/Foundation/Foundation.hpp create mode 100644 vendor/metal-cpp/Foundation/NSArray.hpp create mode 100644 vendor/metal-cpp/Foundation/NSAutoreleasePool.hpp create mode 100644 vendor/metal-cpp/Foundation/NSBundle.hpp create mode 100644 vendor/metal-cpp/Foundation/NSData.hpp create mode 100644 vendor/metal-cpp/Foundation/NSDate.hpp create mode 100644 vendor/metal-cpp/Foundation/NSDefines.hpp create mode 100644 vendor/metal-cpp/Foundation/NSDictionary.hpp create mode 100644 vendor/metal-cpp/Foundation/NSEnumerator.hpp create mode 100644 vendor/metal-cpp/Foundation/NSError.hpp create mode 100644 vendor/metal-cpp/Foundation/NSLock.hpp create mode 100644 vendor/metal-cpp/Foundation/NSNotification.hpp create mode 100644 vendor/metal-cpp/Foundation/NSNumber.hpp create mode 100644 vendor/metal-cpp/Foundation/NSObjCRuntime.hpp create mode 100644 vendor/metal-cpp/Foundation/NSObject.hpp create mode 100644 vendor/metal-cpp/Foundation/NSPrivate.hpp create mode 100644 vendor/metal-cpp/Foundation/NSProcessInfo.hpp create mode 100644 vendor/metal-cpp/Foundation/NSRange.hpp create mode 100644 vendor/metal-cpp/Foundation/NSSet.hpp create mode 100644 vendor/metal-cpp/Foundation/NSSharedPtr.hpp create mode 100644 vendor/metal-cpp/Foundation/NSString.hpp create mode 100644 vendor/metal-cpp/Foundation/NSTypes.hpp create mode 100644 vendor/metal-cpp/Foundation/NSURL.hpp create mode 100644 vendor/metal-cpp/LICENSE.txt create mode 100644 vendor/metal-cpp/Metal/MTLAccelerationStructure.hpp create mode 100644 vendor/metal-cpp/Metal/MTLAccelerationStructureCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLAccelerationStructureTypes.hpp create mode 100644 vendor/metal-cpp/Metal/MTLArgument.hpp create mode 100644 vendor/metal-cpp/Metal/MTLArgumentEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLBinaryArchive.hpp create mode 100644 vendor/metal-cpp/Metal/MTLBlitCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLBlitPass.hpp create mode 100644 vendor/metal-cpp/Metal/MTLBuffer.hpp create mode 100644 vendor/metal-cpp/Metal/MTLCaptureManager.hpp create mode 100644 vendor/metal-cpp/Metal/MTLCaptureScope.hpp create mode 100644 vendor/metal-cpp/Metal/MTLCommandBuffer.hpp create mode 100644 vendor/metal-cpp/Metal/MTLCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLCommandQueue.hpp create mode 100644 vendor/metal-cpp/Metal/MTLComputeCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLComputePass.hpp create mode 100644 vendor/metal-cpp/Metal/MTLComputePipeline.hpp create mode 100644 vendor/metal-cpp/Metal/MTLCounters.hpp create mode 100644 vendor/metal-cpp/Metal/MTLDefines.hpp create mode 100644 vendor/metal-cpp/Metal/MTLDepthStencil.hpp create mode 100644 vendor/metal-cpp/Metal/MTLDevice.hpp create mode 100644 vendor/metal-cpp/Metal/MTLDrawable.hpp create mode 100644 vendor/metal-cpp/Metal/MTLDynamicLibrary.hpp create mode 100644 vendor/metal-cpp/Metal/MTLEvent.hpp create mode 100644 vendor/metal-cpp/Metal/MTLFence.hpp create mode 100644 vendor/metal-cpp/Metal/MTLFunctionConstantValues.hpp create mode 100644 vendor/metal-cpp/Metal/MTLFunctionDescriptor.hpp create mode 100644 vendor/metal-cpp/Metal/MTLFunctionHandle.hpp create mode 100644 vendor/metal-cpp/Metal/MTLFunctionLog.hpp create mode 100644 vendor/metal-cpp/Metal/MTLFunctionStitching.hpp create mode 100644 vendor/metal-cpp/Metal/MTLHeaderBridge.hpp create mode 100644 vendor/metal-cpp/Metal/MTLHeap.hpp create mode 100644 vendor/metal-cpp/Metal/MTLIOCommandBuffer.hpp create mode 100644 vendor/metal-cpp/Metal/MTLIOCommandQueue.hpp create mode 100644 vendor/metal-cpp/Metal/MTLIOCompressor.hpp create mode 100644 vendor/metal-cpp/Metal/MTLIndirectCommandBuffer.hpp create mode 100644 vendor/metal-cpp/Metal/MTLIndirectCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLIntersectionFunctionTable.hpp create mode 100644 vendor/metal-cpp/Metal/MTLLibrary.hpp create mode 100644 vendor/metal-cpp/Metal/MTLLinkedFunctions.hpp create mode 100644 vendor/metal-cpp/Metal/MTLParallelRenderCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLPipeline.hpp create mode 100644 vendor/metal-cpp/Metal/MTLPixelFormat.hpp create mode 100644 vendor/metal-cpp/Metal/MTLPrivate.hpp create mode 100644 vendor/metal-cpp/Metal/MTLRasterizationRate.hpp create mode 100644 vendor/metal-cpp/Metal/MTLRenderCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLRenderPass.hpp create mode 100644 vendor/metal-cpp/Metal/MTLRenderPipeline.hpp create mode 100644 vendor/metal-cpp/Metal/MTLResource.hpp create mode 100644 vendor/metal-cpp/Metal/MTLResourceStateCommandEncoder.hpp create mode 100644 vendor/metal-cpp/Metal/MTLResourceStatePass.hpp create mode 100644 vendor/metal-cpp/Metal/MTLSampler.hpp create mode 100644 vendor/metal-cpp/Metal/MTLStageInputOutputDescriptor.hpp create mode 100644 vendor/metal-cpp/Metal/MTLTexture.hpp create mode 100644 vendor/metal-cpp/Metal/MTLTypes.hpp create mode 100644 vendor/metal-cpp/Metal/MTLVersion.hpp create mode 100644 vendor/metal-cpp/Metal/MTLVertexDescriptor.hpp create mode 100644 vendor/metal-cpp/Metal/MTLVisibleFunctionTable.hpp create mode 100644 vendor/metal-cpp/Metal/Metal.hpp create mode 100644 vendor/metal-cpp/QuartzCore/CADefines.hpp create mode 100644 vendor/metal-cpp/QuartzCore/CAMetalDrawable.hpp create mode 100644 vendor/metal-cpp/QuartzCore/CAMetalLayer.hpp create mode 100644 vendor/metal-cpp/QuartzCore/CAPrivate.hpp create mode 100644 vendor/metal-cpp/QuartzCore/QuartzCore.hpp create mode 100644 vendor/metal-cpp/README.md create mode 100755 vendor/metal-cpp/SingleHeader/MakeSingleHeader.py diff --git a/.github/workflows/ios-ci.yml b/.github/workflows/ios-ci.yml index 3dab4b303..171bd92cd 100644 --- a/.github/workflows/ios-ci.yml +++ b/.github/workflows/ios-ci.yml @@ -199,4 +199,4 @@ jobs: steps: - name: Mark result as failed if: needs.ios-build.result != 'success' - run: exit 1 \ No newline at end of file + run: exit 1 diff --git a/BUILD.bazel b/BUILD.bazel index a9656cf32..383030a5d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -5,7 +5,12 @@ load( "MLN_CORE_SOURCE", "MLN_DRAWABLES_HEADERS", "MLN_DRAWABLES_SOURCE", + "MLN_DRAWABLES_GL_HEADERS", + "MLN_DRAWABLES_GL_SOURCE", + "MLN_DRAWABLES_MTL_HEADERS", + "MLN_DRAWABLES_MTL_SOURCE", "MLN_GENERATED_SHADER_HEADERS", + "MLN_GENERATED_OPENGL_SHADER_HEADERS", "MLN_GENERATED_STYLE_SOURCE", "MLN_OPENGL_HEADERS", "MLN_OPENGL_SOURCE", @@ -44,7 +49,8 @@ filegroup( genrule( name = "generated_shaders", srcs = ["shader_data"], - outs = MLN_GENERATED_SHADER_HEADERS, + outs = MLN_GENERATED_SHADER_HEADERS + + MLN_GENERATED_OPENGL_SHADER_HEADERS, cmd = "node $(execpath shaders/generate_shader_code.js) --root $(RULEDIR)", tools = ["shaders/generate_shader_code.js"], ) @@ -55,7 +61,11 @@ cc_library( name = "mbgl-core-generated-public-artifacts", srcs = [], hdrs = MLN_PUBLIC_GENERATED_STYLE_HEADERS + - MLN_GENERATED_SHADER_HEADERS, + MLN_GENERATED_SHADER_HEADERS + + select({ + "//:metal_renderer": [], + "//conditions:default": MLN_GENERATED_OPENGL_SHADER_HEADERS, + }), visibility = ["//visibility:public"], deps = [ ":generated_shaders", @@ -79,23 +89,32 @@ cc_library( cc_library( name = "mbgl-core", srcs = MLN_CORE_SOURCE + - MLN_GENERATED_STYLE_SOURCE + - MLN_OPENGL_SOURCE + select({ - ":drawable_renderer": MLN_DRAWABLES_SOURCE, - "//conditions:default": [], - }), - hdrs = MLN_CORE_HEADERS + - MLN_OPENGL_HEADERS + select({ - ":drawable_renderer": MLN_DRAWABLES_HEADERS, - "//conditions:default": [], - }), + MLN_GENERATED_STYLE_SOURCE + select({ + ":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE, + ":legacy_renderer": MLN_OPENGL_SOURCE, + ":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE, + "//conditions:default": [], + }), + hdrs = MLN_CORE_HEADERS + select({ + ":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS, + ":legacy_renderer": MLN_OPENGL_HEADERS, + ":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS, + "//conditions:default": [], + }), copts = CPP_FLAGS + MAPLIBRE_FLAGS, defines = select({ ":legacy_renderer": [ + "MLN_RENDER_BACKEND_OPENGL=1", "MLN_LEGACY_RENDERER=1", "MLN_DRAWABLE_RENDERER=0", ], ":drawable_renderer": [ + "MLN_RENDER_BACKEND_OPENGL=1", + "MLN_LEGACY_RENDERER=0", + "MLN_DRAWABLE_RENDERER=1", + ], + ":metal_renderer": [ + "MLN_RENDER_BACKEND_METAL=1", "MLN_LEGACY_RENDERER=0", "MLN_DRAWABLE_RENDERER=1", ], @@ -106,7 +125,12 @@ cc_library( includes = [ "include", "src", - ], + ] + select({ + ":metal_renderer": [ + "vendor/metal-cpp", + ], + "//conditions:default": [], + }), local_defines = [ r"MLN_VERSION_REV=\"standalone\"", ], @@ -130,6 +154,11 @@ cc_library( "//vendor:icu", ], "//conditions:default": [], + }) + select({ + ":metal_renderer": [ + "//vendor:metal-cpp", + ], + "//conditions:default": [], }), ) @@ -180,10 +209,11 @@ config_setting( string_flag( name = "renderer", build_setting_default = "legacy", - values = [ + values=[ "legacy", "drawable", - ], + "metal" + ] ) config_setting( @@ -200,6 +230,13 @@ config_setting( }, ) +config_setting( + name = "metal_renderer", + flag_values = { + ":renderer": "metal" + } +) + exports_files( [ "LICENSE.md", diff --git a/CMakeLists.txt b/CMakeLists.txt index 13771e28b..7114ef413 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,7 +152,6 @@ if(MLN_DRAWABLE_RENDERER) ${PROJECT_SOURCE_DIR}/include/mbgl/renderer/layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/renderer/render_target.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/shader_program_base.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_program_mtl.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/identity.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/suppress_copies.hpp @@ -174,7 +173,7 @@ if(MLN_DRAWABLE_RENDERER) ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_custom_layer_host_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/hillshade_prepare_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/image_drawable_data.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/line_drawable_data.hpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/line_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/symbol_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/collision_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/uniform_block.cpp @@ -211,7 +210,6 @@ if(MLN_DRAWABLE_RENDERER) ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/collision_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/collision_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/shader_program_base.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/shader_program_mtl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/util/identity.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/gl/shader_program_gl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl.cpp @@ -979,10 +977,10 @@ if(MLN_WITH_OPENGL) target_compile_definitions( mbgl-core PRIVATE - MBGL_RENDER_BACKEND_OPENGL=1 + PRIVATE MLN_RENDER_BACKEND_OPENGL=1 PUBLIC "MLN_LEGACY_RENDERER=$" - "MLN_DRAWABLE_RENDERER=$" + "MLN_DRAWABLE_RENDERER=$" ) list(APPEND INCLUDE_FILES @@ -1109,6 +1107,38 @@ if(MLN_WITH_OPENGL) ${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer_properties.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer_properties.hpp ) + + if(MLN_DRAWABLE_RENDERER) + list(APPEND INCLUDE_FILES + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/background_layer_ubo.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/circle_layer_ubo.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/fill_layer_ubo.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/layer_ubo.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/line_layer_ubo.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/raster_layer_ubo.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/shader_program_gl.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/drawable_gl.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/drawable_gl_builder.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/layer_group_gl.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/render_target_gl.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/uniform_block_gl.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/uniform_buffer_gl.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/vertex_attribute_gl.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/gl/texture2d.hpp + ) + list(APPEND SRC_FILES + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/render_target_gl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/gl/shader_program_gl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl_builder.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl_impl.hpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/layer_group_gl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/texture2d.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/uniform_block_gl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/uniform_buffer_gl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_attribute_gl.cpp + ) + endif() endif() if(MBGL_WITH_METAL) @@ -1119,15 +1149,54 @@ if(MBGL_WITH_METAL) ) list(APPEND INCLUDE_FILES - ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/drawable_mtl.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/drawable_mtl_builder.hpp - ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/drawable_mtl_tweaker.hpp - ) + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/buffer_resource.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/command_encoder.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/context.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/layer_group.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/drawable.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/drawable_builder.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/drawable_tweaker.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/index_buffer_resource.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/mtl_fwd.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/texture2d.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/tile_layer_group.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/uniform_block.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/uniform_buffer.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/upload_pass.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/vertex_attribute.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/vertex_buffer_resource.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_program.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/background.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/background_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/circle.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/common.hpp + ) list(APPEND SRC_FILES - ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/drawable_mtl.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/drawable_mtl_builder.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/drawable_mtl_tweaker.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/buffer_resource.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/command_encoder.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/context.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/drawable.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/drawable_impl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/drawable_builder.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/drawable_tweaker.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/layer_group.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/mtl.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/texture2d.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/tile_layer_group.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/uniform_block.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/uniform_buffer.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/upload_pass.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/vertex_attribute.cpp + ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/shader_program.cpp + ) +endif() + +if(MBGL_WITH_METAL) + message(STATUS "Configuring Metal renderer backend") + target_compile_definitions( + mbgl-core + PRIVATE MBGL_RENDER_BACKEND_METAL=1 ) endif() diff --git a/bazel/core.bzl b/bazel/core.bzl index 0559b7ad8..e05ec0354 100644 --- a/bazel/core.bzl +++ b/bazel/core.bzl @@ -52,6 +52,9 @@ MLN_GENERATED_STYLE_SOURCE = [ MLN_GENERATED_SHADER_HEADERS = [ "include/mbgl/shaders/shader_source.hpp", "include/mbgl/shaders/shader_manifest.hpp", +] + +MLN_GENERATED_OPENGL_SHADER_HEADERS = [ "include/mbgl/shaders/gl/background.hpp", "include/mbgl/shaders/gl/background_pattern.hpp", "include/mbgl/shaders/gl/circle.hpp", @@ -137,6 +140,7 @@ MLN_CORE_SOURCE = [ "src/mbgl/geometry/line_atlas.hpp", "src/mbgl/gfx/attribute.cpp", "src/mbgl/gfx/attribute.hpp", + "include/mbgl/gfx/backend.hpp", "src/mbgl/gfx/color_mode.hpp", "src/mbgl/gfx/command_encoder.hpp", "src/mbgl/gfx/context.hpp", @@ -163,6 +167,7 @@ MLN_CORE_SOURCE = [ "src/mbgl/gfx/vertex_vector.hpp", "src/mbgl/layermanager/background_layer_factory.cpp", "src/mbgl/layermanager/circle_layer_factory.cpp", + "src/mbgl/layermanager/custom_layer_factory.cpp", "src/mbgl/layermanager/fill_extrusion_layer_factory.cpp", "src/mbgl/layermanager/fill_layer_factory.cpp", "src/mbgl/layermanager/heatmap_layer_factory.cpp", @@ -284,6 +289,8 @@ MLN_CORE_SOURCE = [ "src/mbgl/renderer/layers/render_background_layer.hpp", "src/mbgl/renderer/layers/render_circle_layer.cpp", "src/mbgl/renderer/layers/render_circle_layer.hpp", + "src/mbgl/renderer/layers/render_custom_layer.cpp", + "src/mbgl/renderer/layers/render_custom_layer.hpp", "src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp", "src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp", "src/mbgl/renderer/layers/render_fill_layer.cpp", @@ -441,6 +448,9 @@ MLN_CORE_SOURCE = [ "src/mbgl/style/layers/background_layer_impl.hpp", "src/mbgl/style/layers/circle_layer_impl.cpp", "src/mbgl/style/layers/circle_layer_impl.hpp", + "src/mbgl/style/layers/custom_layer.cpp", + "src/mbgl/style/layers/custom_layer_impl.cpp", + "src/mbgl/style/layers/custom_layer_impl.hpp", "src/mbgl/style/layers/fill_extrusion_layer_impl.cpp", "src/mbgl/style/layers/fill_extrusion_layer_impl.hpp", "src/mbgl/style/layers/fill_layer_impl.cpp", @@ -451,6 +461,8 @@ MLN_CORE_SOURCE = [ "src/mbgl/style/layers/hillshade_layer_impl.hpp", "src/mbgl/style/layers/line_layer_impl.cpp", "src/mbgl/style/layers/line_layer_impl.hpp", + "src/mbgl/style/layers/location_indicator_layer_impl.cpp", + "src/mbgl/style/layers/location_indicator_layer_impl.hpp", "src/mbgl/style/layers/raster_layer_impl.cpp", "src/mbgl/style/layers/raster_layer_impl.hpp", "src/mbgl/style/layers/symbol_layer_impl.cpp", @@ -653,6 +665,7 @@ MLN_CORE_HEADERS = [ "include/mbgl/i18n/number_format.hpp", "include/mbgl/layermanager/background_layer_factory.hpp", "include/mbgl/layermanager/circle_layer_factory.hpp", + "include/mbgl/layermanager/custom_layer_factory.hpp", "include/mbgl/layermanager/fill_extrusion_layer_factory.hpp", "include/mbgl/layermanager/fill_layer_factory.hpp", "include/mbgl/layermanager/heatmap_layer_factory.hpp", @@ -757,6 +770,7 @@ MLN_CORE_HEADERS = [ "include/mbgl/style/image.hpp", "include/mbgl/style/layer.hpp", "include/mbgl/style/layer_properties.hpp", + "include/mbgl/style/layers/custom_layer.hpp", "include/mbgl/style/position.hpp", "include/mbgl/style/property_expression.hpp", "include/mbgl/style/property_value.hpp", @@ -832,10 +846,6 @@ MLN_OPENGL_SOURCE = [ "src/mbgl/gl/command_encoder.hpp", "src/mbgl/gl/context.cpp", "src/mbgl/gl/context.hpp", - "src/mbgl/style/layers/custom_layer.cpp", - "src/mbgl/layermanager/custom_layer_factory.cpp", - "src/mbgl/style/layers/custom_layer_impl.cpp", - "src/mbgl/style/layers/custom_layer_impl.hpp", "src/mbgl/gl/debugging_extension.cpp", "src/mbgl/gl/debugging_extension.hpp", "src/mbgl/gl/defines.hpp", @@ -851,8 +861,6 @@ MLN_OPENGL_SOURCE = [ "src/mbgl/gl/offscreen_texture.cpp", "src/mbgl/gl/offscreen_texture.hpp", "src/mbgl/gl/program.hpp", - "src/mbgl/renderer/layers/render_custom_layer.cpp", - "src/mbgl/renderer/layers/render_custom_layer.hpp", "src/mbgl/gl/render_pass.cpp", "src/mbgl/gl/render_pass.hpp", "src/mbgl/gl/renderbuffer_resource.hpp", @@ -877,14 +885,10 @@ MLN_OPENGL_SOURCE = [ "src/mbgl/platform/gl_functions.cpp", "src/mbgl/renderer/layers/render_location_indicator_layer.cpp", "src/mbgl/renderer/layers/render_location_indicator_layer.hpp", - "src/mbgl/style/layers/location_indicator_layer_impl.cpp", - "src/mbgl/style/layers/location_indicator_layer_impl.hpp", ] MLN_OPENGL_HEADERS = [ "include/mbgl/gfx/backend.hpp", - "include/mbgl/style/layers/custom_layer.hpp", - "include/mbgl/layermanager/custom_layer_factory.hpp", "include/mbgl/gl/renderable_resource.hpp", "include/mbgl/gl/renderer_backend.hpp", "include/mbgl/layermanager/location_indicator_layer_factory.hpp", @@ -935,18 +939,7 @@ MLN_DRAWABLES_SOURCE = [ "src/mbgl/renderer/layers/collision_layer_tweaker.cpp", "src/mbgl/renderer/layers/collision_layer_tweaker.hpp", "src/mbgl/shaders/shader_program_base.cpp", - "src/mbgl/shaders/mtl/shader_program_mtl.cpp", - "src/mbgl/shaders/gl/shader_program_gl.cpp", "src/mbgl/util/identity.cpp", - "src/mbgl/gl/drawable_gl.cpp", - "src/mbgl/gl/drawable_gl_builder.cpp", - "src/mbgl/gl/drawable_gl_impl.hpp", - "src/mbgl/gl/layer_group_gl.cpp", - "src/mbgl/gl/render_target_gl.cpp", - "src/mbgl/gl/texture2d.cpp", - "src/mbgl/gl/uniform_block_gl.cpp", - "src/mbgl/gl/uniform_buffer_gl.cpp", - "src/mbgl/gl/vertex_attribute_gl.cpp" ] MLN_DRAWABLES_HEADERS = [ @@ -965,12 +958,30 @@ MLN_DRAWABLES_HEADERS = [ "include/mbgl/renderer/layer_group.hpp", "include/mbgl/renderer/layer_tweaker.hpp", "include/mbgl/renderer/render_target.hpp", + "include/mbgl/shaders/background_layer_ubo.hpp", + "include/mbgl/shaders/circle_layer_ubo.hpp", + "include/mbgl/shaders/fill_layer_ubo.hpp", + "include/mbgl/shaders/layer_ubo.hpp", + "include/mbgl/shaders/line_layer_ubo.hpp", + "include/mbgl/shaders/raster_layer_ubo.hpp", "include/mbgl/shaders/shader_program_base.hpp", - "include/mbgl/shaders/mtl/shader_program_mtl.hpp", "include/mbgl/util/identity.hpp", - "include/mbgl/util/suppress_copies.hpp", - "include/mbgl/shaders/gl/shader_program_gl.hpp", - "include/mbgl/shaders/gl/shader_group_gl.hpp", +] + +MLN_DRAWABLES_GL_SOURCE = [ + "src/mbgl/gl/drawable_gl.cpp", + "src/mbgl/gl/drawable_gl_builder.cpp", + "src/mbgl/gl/drawable_gl_impl.hpp", + "src/mbgl/gl/layer_group_gl.cpp", + "src/mbgl/gl/render_target_gl.cpp", + "src/mbgl/gl/texture2d.cpp", + "src/mbgl/gl/uniform_block_gl.cpp", + "src/mbgl/gl/uniform_buffer_gl.cpp", + "src/mbgl/gl/vertex_attribute_gl.cpp", + "src/mbgl/shaders/gl/shader_program_gl.cpp", +] + +MLN_DRAWABLES_GL_HEADERS = [ "include/mbgl/gl/drawable_gl.hpp", "include/mbgl/gl/drawable_gl_builder.hpp", "include/mbgl/gl/layer_group_gl.hpp", @@ -978,5 +989,58 @@ MLN_DRAWABLES_HEADERS = [ "include/mbgl/gl/uniform_block_gl.hpp", "include/mbgl/gl/uniform_buffer_gl.hpp", "include/mbgl/gl/vertex_attribute_gl.hpp", - "include/mbgl/gl/texture2d.hpp" + "include/mbgl/gl/texture2d.hpp", + "include/mbgl/shaders/gl/shader_program_gl.hpp", + "include/mbgl/shaders/gl/shader_group_gl.hpp" +] + +MLN_DRAWABLES_MTL_SOURCE = [ + "src/mbgl/mtl/buffer_resource.cpp", + "src/mbgl/mtl/command_encoder.cpp", + "src/mbgl/mtl/context.cpp", + "src/mbgl/mtl/drawable.cpp", + "src/mbgl/mtl/drawable_impl.hpp", + "src/mbgl/mtl/drawable_builder.cpp", + "src/mbgl/mtl/layer_group.cpp", + "src/mbgl/mtl/mtl.cpp", + "src/mbgl/mtl/renderer_backend.cpp", + "src/mbgl/mtl/texture2d.cpp", + "src/mbgl/mtl/render_pass.cpp", + "src/mbgl/mtl/tile_layer_group.cpp", + "src/mbgl/mtl/uniform_block.cpp", + "src/mbgl/mtl/uniform_buffer.cpp", + "src/mbgl/mtl/upload_pass.cpp", + "src/mbgl/mtl/vertex_attribute.cpp", + "src/mbgl/shaders/mtl/shader_program.cpp", +] + +MLN_DRAWABLES_MTL_HEADERS = [ + "include/mbgl/mtl/buffer_resource.hpp", + "include/mbgl/mtl/command_encoder.hpp", + "include/mbgl/mtl/context.hpp", + "include/mbgl/mtl/drawable.hpp", + "include/mbgl/mtl/drawable_builder.hpp", + "include/mbgl/mtl/index_buffer_resource.hpp", + "include/mbgl/mtl/layer_group.hpp", + "include/mbgl/mtl/mtl_fwd.hpp", + "include/mbgl/mtl/render_pass.hpp", + "include/mbgl/mtl/renderer_backend.hpp", + "include/mbgl/mtl/renderable_resource.hpp", + "include/mbgl/mtl/texture2d.hpp", + "include/mbgl/mtl/tile_layer_group.hpp", + "include/mbgl/mtl/uniform_block.hpp", + "include/mbgl/mtl/uniform_buffer.hpp", + "include/mbgl/mtl/upload_pass.hpp", + "include/mbgl/mtl/vertex_attribute.hpp", + "include/mbgl/mtl/vertex_buffer_resource.hpp", + "include/mbgl/shaders/mtl/background.hpp", + "include/mbgl/shaders/mtl/background_pattern.hpp", + "include/mbgl/shaders/mtl/circle.hpp", + "include/mbgl/shaders/mtl/common.hpp", + "include/mbgl/shaders/mtl/line.hpp", + "include/mbgl/shaders/mtl/fill.hpp", + "include/mbgl/shaders/mtl/line_gradient.hpp", + "include/mbgl/shaders/mtl/raster.hpp", + "include/mbgl/shaders/mtl/shader_group.hpp", + "include/mbgl/shaders/mtl/shader_program.hpp", ] diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 7ffb01cdb..b73ac8ef5 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -61,3 +61,7 @@ target_link_libraries( ) set_property(TARGET mbgl-benchmark PROPERTY FOLDER Core) + +if(MLN_WITH_OPENGL) + target_compile_definitions(mbgl-benchmark PRIVATE "MLN_RENDER_BACKEND_OPENGL=1") +endif() \ No newline at end of file diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index c8d527417..72690e61a 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -56,3 +56,7 @@ install(TARGETS mbgl-offline mbgl-render RUNTIME DESTINATION bin) # ${PROJECT_SOURCE_DIR} ) # # add_test(NAME mbgl-render-tool-test COMMAND mbgl-render WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) + +if(MLN_WITH_OPENGL) + target_compile_definitions(mbgl-render PRIVATE "MLN_RENDER_BACKEND_OPENGL=1") +endif() \ No newline at end of file diff --git a/include/mbgl/gfx/backend.hpp b/include/mbgl/gfx/backend.hpp index 46d85d519..bc79032b7 100644 --- a/include/mbgl/gfx/backend.hpp +++ b/include/mbgl/gfx/backend.hpp @@ -12,11 +12,16 @@ public: /// @brief The active graphics API/backend type. enum class Type : uint8_t { OpenGL, ///< The OpenGL API backend + Metal, ///< The Metal API backend TYPE_MAX, ///< Not a valid backend type, used to determine the number ///< of available backends (ie for array allocation). }; +#if MLN_RENDER_BACKEND_METAL + static constexpr Type DefaultType = Type::Metal; +#else // assume MLN_RENDER_BACKEND_METAL static constexpr Type DefaultType = Type::OpenGL; +#endif static void SetType(const Type value) { if (Value(value) != value) { diff --git a/include/mbgl/gfx/drawable.hpp b/include/mbgl/gfx/drawable.hpp index 2b55b0aa4..65fa80778 100644 --- a/include/mbgl/gfx/drawable.hpp +++ b/include/mbgl/gfx/drawable.hpp @@ -1,12 +1,12 @@ #pragma once +#include +#include #include #include #include #include #include -#include -#include #include #include diff --git a/include/mbgl/gfx/uniform_buffer.hpp b/include/mbgl/gfx/uniform_buffer.hpp index acb2a5261..38556a188 100644 --- a/include/mbgl/gfx/uniform_buffer.hpp +++ b/include/mbgl/gfx/uniform_buffer.hpp @@ -9,6 +9,11 @@ namespace mbgl { namespace gfx { class Context; +class UniformBuffer; +class UniformBufferArray; + +using UniqueUniformBuffer = std::unique_ptr; +using UniqueUniformBufferArray = std::unique_ptr; class UniformBuffer { // Can only be created by platform specific implementations @@ -74,7 +79,7 @@ public: protected: const std::shared_ptr& add(const std::string_view name, std::shared_ptr&&); - virtual std::unique_ptr copy(const UniformBuffer& uniformBuffer) = 0; + virtual std::unique_ptr copy(const UniformBuffer&) = 0; protected: UniformBufferMap uniformBufferMap; diff --git a/include/mbgl/gfx/vertex_attribute.hpp b/include/mbgl/gfx/vertex_attribute.hpp index 1b0bd33fc..91f59524a 100644 --- a/include/mbgl/gfx/vertex_attribute.hpp +++ b/include/mbgl/gfx/vertex_attribute.hpp @@ -27,8 +27,13 @@ using mat4 = std::array; namespace gfx { class ShaderProgramBase; +class VertexAttribute; +class VertexAttributeArray; class VertexVectorBase; +using UniqueVertexAttribute = std::unique_ptr; +using UniqueVertexAttributeArray = std::unique_ptr; + class VertexAttribute { public: /// type for vector of 2 floats @@ -71,11 +76,12 @@ public: /// @param stride_ the vertex attribute stride VertexAttribute(int index_, AttributeDataType dataType_, std::size_t count_, std::size_t stride_) : index(index_), - stride((int)stride_), + stride(stride_), dataType(dataType_), items(count_) {} VertexAttribute(const VertexAttribute& other) : index(other.index), + stride(other.stride), dataType(other.dataType), items(other.items), sharedRawData(other.sharedRawData), @@ -85,6 +91,7 @@ public: sharedStride(other.sharedStride) {} VertexAttribute(VertexAttribute&& other) : index(other.index), + stride(other.stride), dataType(other.dataType), items(std::move(other.items)), sharedRawData(std::move(other.sharedRawData)), @@ -104,6 +111,7 @@ public: /// @brief Get the stride of the vertex attribute std::size_t getStride() const { return stride; } + void setStride(std::size_t value) { stride = value; } /// @brief Get the count of vertex attribute items std::size_t getCount() const; @@ -188,6 +196,7 @@ public: /// Get the vertex attribute's raw data std::vector& getRawData() { return rawData; } const std::vector& getRawData() const { return rawData; } + void setRawData(std::vector value) { rawData = std::move(value); } /// Get the vertex attribute's shared raw data const std::shared_ptr& getSharedRawData() const { return sharedRawData; } @@ -225,8 +234,11 @@ public: /// @brief Clears the shared data void resetSharedRawData() { sharedRawData.reset(); } + const gfx::UniqueVertexBufferResource& getBuffer() const { return buffer; } + void setBuffer(gfx::UniqueVertexBufferResource&& value) { buffer = std::move(value); } + protected: - VertexAttribute& operator=(const VertexAttribute&) = default; + VertexAttribute& operator=(const VertexAttribute&) = delete; VertexAttribute& operator=(VertexAttribute&& other) { index = other.index; dataType = other.dataType; @@ -236,7 +248,7 @@ protected: protected: int index; - int stride; + std::size_t stride; /// indicates that a value has changed and any cached result should be discarded mutable bool dirty = true; @@ -252,6 +264,8 @@ protected: uint32_t sharedOffset = 0; uint32_t sharedVertexOffset = 0; uint32_t sharedStride = 0; + + gfx::UniqueVertexBufferResource buffer; }; /// Stores a collection of vertex attributes by name @@ -276,15 +290,15 @@ public: /// Add a new attribute element. /// Returns a pointer to the new element on success, or null if the attribute already exists. /// The result is valid only until the next non-const method call on this class. - const std::unique_ptr& get(const std::string& name) const; + const UniqueVertexAttribute& get(const std::string& name) const; /// Add a new attribute element. /// Returns a pointer to the new element on success, or null if the attribute already exists. /// The result is valid only until the next non-const method call on this class. - const std::unique_ptr& add(std::string name, - int index = -1, - AttributeDataType = AttributeDataType::Invalid, - std::size_t count = 1); + const UniqueVertexAttribute& add(std::string name, + int index = -1, + AttributeDataType = AttributeDataType::Invalid, + std::size_t count = 1); /// Add a new attribute element if it doesn't already exist. /// Returns a pointer to the new element on success, or null if the type or count conflict with an existing entry. @@ -292,10 +306,10 @@ public: /// @param index index to match, or -1 for any /// @param type type to match, or `Invalid` for any /// @param count type to match, or 0 for any - const std::unique_ptr& getOrAdd(std::string name, - int index = -1, - AttributeDataType type = AttributeDataType::Invalid, - std::size_t count = 0); + const UniqueVertexAttribute& getOrAdd(std::string name, + int index = -1, + AttributeDataType type = AttributeDataType::Invalid, + std::size_t count = 0); // Set a value if the element is present template @@ -333,8 +347,7 @@ public: }); } - using ResolveDelegate = - std::function&)>; + using ResolveDelegate = std::function; /// Call the provided delegate with each value, providing the override if one exists. void resolve(const VertexAttributeArray& overrides, ResolveDelegate) const; @@ -342,7 +355,7 @@ public: VertexAttributeArray& operator=(const VertexAttributeArray&); /// Clone the collection - virtual std::unique_ptr clone() const { + virtual UniqueVertexAttributeArray clone() const { auto newAttrs = std::make_unique(); newAttrs->copy(*this); return newAttrs; @@ -403,21 +416,13 @@ public: } protected: - const std::unique_ptr& add(std::string name, std::unique_ptr&& attr) { - const auto result = attrs.insert(std::make_pair(std::move(name), std::unique_ptr())); - if (result.second) { - result.first->second = std::move(attr); - return result.first->second; - } else { - return nullref; - } - } + const UniqueVertexAttribute& add(std::string name, std::unique_ptr&&); - virtual std::unique_ptr create(int index, AttributeDataType dataType, std::size_t count) const { + virtual UniqueVertexAttribute create(int index, AttributeDataType dataType, std::size_t count) const { return std::make_unique(index, dataType, count, count); } - virtual std::unique_ptr copy(const gfx::VertexAttribute& attr) const { + virtual UniqueVertexAttribute copy(const gfx::VertexAttribute& attr) const { return std::make_unique(attr); } diff --git a/include/mbgl/mtl/buffer_resource.hpp b/include/mbgl/mtl/buffer_resource.hpp new file mode 100644 index 000000000..1f80dbdc0 --- /dev/null +++ b/include/mbgl/mtl/buffer_resource.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +#include +#include +#include + +namespace mbgl { +namespace mtl { + +class BufferResource { +public: + BufferResource() = default; + /** @brief Create a new Metal buffer + @param device The Metal device on which to create the buffer. + @param raw Data to use for the contents of the new buffer. May be null. + @param size The minimum size of the new buffer. Must be non-zero. + @param usage A `MTL::ResourceOptions` value. Currently, only `ResourceStorageModeShared` is supported. + */ + BufferResource(MTLDevicePtr device, const void* raw, std::size_t size, MTL::ResourceOptions usage); + BufferResource(const BufferResource&); + BufferResource(BufferResource&&); + + void update(const void* data, std::size_t size, std::size_t offset); + + std::size_t getSizeInBytes() const { return buffer ? buffer->length() : 0; } + void* contents() const { return buffer ? buffer->contents() : nullptr; } + + const MTLBufferPtr& getMetalBuffer() const { return buffer; } + + operator bool() const { return buffer.operator bool(); } + +protected: + MTLDevicePtr device; + MTLBufferPtr buffer; + NS::UInteger usage; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/command_encoder.hpp b/include/mbgl/mtl/command_encoder.hpp new file mode 100644 index 000000000..558b88f88 --- /dev/null +++ b/include/mbgl/mtl/command_encoder.hpp @@ -0,0 +1,73 @@ +#pragma once + +#include +#include + +#include +#include +#include +#include +#include + +namespace mbgl { +namespace gfx { +class Renderable; +} // namespace gfx +namespace mtl { + +class Context; +class RenderPass; +class UploadPass; + +class CommandEncoder final : public gfx::CommandEncoder { +public: + explicit CommandEncoder(Context& context_); + ~CommandEncoder() override; + + std::unique_ptr createUploadPass(const char* name, gfx::Renderable&) override; + std::unique_ptr createRenderPass(const char* name, const gfx::RenderPassDescriptor&) override; + + void present(gfx::Renderable&) override; + + template + void visitDebugGroups(TFunc f) { + for (const auto& item : debugGroupNames) { + f(item.name); + } + } + +private: + friend class RenderPass; + friend class UploadPass; + + // Track a RenderPass, propagating debug groups to it + void trackRenderPass(RenderPass*); + // Stop tracking a RenderPass + void forgetRenderPass(RenderPass*); + + // Track an UploadPass, propagating debug groups to it + void trackUploadPass(UploadPass*); + // Stop tracking a RenderPass + void forgetUploadPass(UploadPass*); + + void pushDebugGroup(const char* name) override; + void popDebugGroup() override; + +protected: + struct GroupEntry { + std::string name; + std::size_t renderGroups; + std::size_t uploadGroups; + }; + +protected: + mtl::Context& context; + std::vector debugGroupNames; + std::vector> renderDebugGroups; + std::vector> uploadDebugGroups; + std::unordered_set renderPasses; + std::unordered_set uploadPasses; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/context.hpp b/include/mbgl/mtl/context.hpp new file mode 100644 index 000000000..5e923338b --- /dev/null +++ b/include/mbgl/mtl/context.hpp @@ -0,0 +1,124 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace mbgl { + +class ProgramParameters; + +namespace mtl { + +class RendererBackend; +class ShaderProgram; + +using UniqueShaderProgram = std::unique_ptr; + +class Context final : public gfx::Context { +public: + Context(RendererBackend&); + ~Context() noexcept override; + Context(const Context&) = delete; + Context& operator=(const Context& other) = delete; + + std::unique_ptr createCommandEncoder() override; + + gfx::RenderingStats& renderingStats() { return stats; } + const gfx::RenderingStats& renderingStats() const override { return stats; } + + BufferResource createBuffer(const void* data, std::size_t size, gfx::BufferUsageType) const; + + UniqueShaderProgram createProgram(std::string name, + std::string_view source, + std::string_view vertexName, + std::string_view fragmentName, + const ProgramParameters& programParameters, + const std::unordered_map& additionalDefines); + + MTLTexturePtr createMetalTexture(MTLTextureDescriptorPtr textureDescriptor) const; + MTLSamplerStatePtr createMetalSamplerState(MTLSamplerDescriptorPtr samplerDescriptor) const; + + /* + Framebuffer createFramebuffer(const gfx::Renderbuffer&, + const gfx::Renderbuffer&); + Framebuffer createFramebuffer(const gfx::Renderbuffer&); + Framebuffer createFramebuffer(const gfx::Texture&, + const gfx::Renderbuffer&); + Framebuffer createFramebuffer(const gfx::Texture&); + Framebuffer createFramebuffer(const gfx::Texture&, const gfx::Renderbuffer&); + + template + Image readFramebuffer(const Size size, bool flip = true) { + static_assert(Image::channels == (format == gfx::TexturePixelType::RGBA ? 4 : 1), "image format mismatch"); + return {size, readFramebuffer(size, format, flip)}; + } +*/ + + // Actually remove the objects we marked as abandoned with the above methods. + void performCleanup() override {} + + void reduceMemoryUsage() override {} + + gfx::UniqueDrawableBuilder createDrawableBuilder(std::string name) override; + gfx::UniformBufferPtr createUniformBuffer(const void* data, std::size_t size) override; + + gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override; + + TileLayerGroupPtr createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override; + + LayerGroupPtr createLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override; + + gfx::Texture2DPtr createTexture2D() override; + + RenderTargetPtr createRenderTarget(const Size size, const gfx::TextureChannelDataType type) override; + + // UniqueFramebuffer createFramebuffer(const gfx::Texture2D& color); + + void resetState(gfx::DepthMode depthMode, gfx::ColorMode colorMode) override; + + void setDirtyState() override; + + std::unique_ptr createOffscreenTexture(Size, gfx::TextureChannelDataType) override; + + std::unique_ptr createTextureResource(Size, + gfx::TexturePixelType, + gfx::TextureChannelDataType) override; + + std::unique_ptr createRenderbufferResource(gfx::RenderbufferPixelType, + Size size) override; + + std::unique_ptr createDrawScopeResource() override; + /* + UniqueFramebuffer createFramebuffer(); + std::unique_ptr readFramebuffer(Size, gfx::TexturePixelType, bool flip); + */ + +#if !defined(NDEBUG) + void visualizeStencilBuffer() override; + void visualizeDepthBuffer(float depthRangeSize) override; +#endif + + void clearStencilBuffer(int32_t) override; + +private: + RendererBackend& backend; + bool cleanupOnDestruction = true; + + gfx::RenderingStats stats; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/drawable.hpp b/include/mbgl/mtl/drawable.hpp new file mode 100644 index 000000000..00fea875f --- /dev/null +++ b/include/mbgl/mtl/drawable.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include +#include +#include +#include + +#include + +namespace mbgl { + +template +class Segment; + +namespace gfx { + +class IndexBuffer; +class UploadPass; +class VertexBufferResource; + +using UniqueVertexBufferResource = std::unique_ptr; + +} // namespace gfx + +namespace mtl { + +class RenderPass; +class Texture2D; +class VertexArray; + +class Drawable : public gfx::Drawable { +public: + Drawable(std::string name); + ~Drawable() override; + + void draw(PaintParameters&) const override; + + struct DrawSegment; + void setIndexData(gfx::IndexVectorBasePtr, std::vector segments) override; + + void setVertices(std::vector&&, std::size_t, gfx::AttributeDataType) override; + + const gfx::VertexAttributeArray& getVertexAttributes() const override; + void setVertexAttributes(const gfx::VertexAttributeArray& value) override; + void setVertexAttributes(gfx::VertexAttributeArray&& value) override; + + gfx::VertexAttributeArray& mutableVertexAttributes() override; + + const gfx::UniformBufferArray& getUniformBuffers() const override; + gfx::UniformBufferArray& mutableUniformBuffers() override; + + void setVertexAttrName(std::string); + + void upload(gfx::UploadPass&); + +protected: + // For testing only. + Drawable(std::unique_ptr); + + void bindAttributes(const RenderPass& renderPass) const; + void unbindAttributes(const RenderPass& renderPass) const; + + void bindUniformBuffers(const RenderPass& renderPass) const; + void unbindUniformBuffers(const RenderPass& renderPass) const; + + void bindTextures(const RenderPass& renderPass) const; + void unbindTextures(const RenderPass& renderPass) const; + + void uploadTextures() const; + + class Impl; + const std::unique_ptr impl; + + gfx::AttributeBindingArray attributeBindings; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/drawable_builder.hpp b/include/mbgl/mtl/drawable_builder.hpp new file mode 100644 index 000000000..ae5fdcfe1 --- /dev/null +++ b/include/mbgl/mtl/drawable_builder.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace mbgl { +namespace mtl { + +/** + Base class for Metal-specific drawable builders. + */ +class DrawableBuilder final : public gfx::DrawableBuilder { +public: + DrawableBuilder(std::string name_) + : gfx::DrawableBuilder(std::move(name_)) {} + ~DrawableBuilder() override = default; + + using DrawSegment = gfx::Drawable::DrawSegment; + std::unique_ptr createSegment(gfx::DrawMode, SegmentBase&&) override; + +protected: + gfx::UniqueDrawable createDrawable() const override; + + /// Setup the SDK-specific aspects after all the values are present + void init() override; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/drawable_mtl.hpp b/include/mbgl/mtl/drawable_mtl.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/include/mbgl/mtl/drawable_mtl_builder.hpp b/include/mbgl/mtl/drawable_mtl_builder.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/include/mbgl/mtl/drawable_mtl_tweaker.hpp b/include/mbgl/mtl/drawable_mtl_tweaker.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/include/mbgl/mtl/index_buffer_resource.hpp b/include/mbgl/mtl/index_buffer_resource.hpp new file mode 100644 index 000000000..178bd40ff --- /dev/null +++ b/include/mbgl/mtl/index_buffer_resource.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include + +namespace mbgl { +namespace mtl { + +class IndexBufferResource : public gfx::IndexBufferResource { +public: + IndexBufferResource() = default; + IndexBufferResource(BufferResource&& ptr) + : buffer(std::move(ptr)) {} + IndexBufferResource(IndexBufferResource&& other) + : buffer(std::move(other.buffer)) {} + + std::size_t getSizeInBytes() const { return buffer.getSizeInBytes(); } + void* contents() const { return buffer.contents(); } + + BufferResource& get() { return buffer; } + const BufferResource& get() const { return buffer; } + +protected: + BufferResource buffer; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/layer_group.hpp b/include/mbgl/mtl/layer_group.hpp new file mode 100644 index 000000000..586b8096f --- /dev/null +++ b/include/mbgl/mtl/layer_group.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace mbgl { +namespace mtl { + +/** + A layer group for non-tile-based drawables + */ +class LayerGroup : public mbgl::LayerGroup { +public: + LayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name); + ~LayerGroup() override {} + + void upload(gfx::UploadPass&) override; + void render(RenderOrchestrator&, PaintParameters&) override; + +protected: +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/mtl_fwd.hpp b/include/mbgl/mtl/mtl_fwd.hpp new file mode 100644 index 000000000..7093160cc --- /dev/null +++ b/include/mbgl/mtl/mtl_fwd.hpp @@ -0,0 +1,60 @@ +#pragma once + +// Forward-declarations for metal-cpp types, allowing +// references without including any third-party headers + +#include + +namespace CA { +class MetalDrawable; +} // namespace CA + +namespace NS { +template +class SharedPtr; +using UInteger = std::uintptr_t; +} // namespace NS + +namespace MTL { +class BlitCommandEncoder; +class BlitPassDescriptor; +class Buffer; +class CommandBuffer; +class CommandQueue; +class Device; +class Function; +class RenderCommandEncoder; +class RenderPipelineState; +class RenderPassDescriptor; +class Texture; +class TextureDescriptor; +class SamplerState; +class SamplerDescriptor; +class VertexAttributeDescriptor; +class VertexBufferLayoutDescriptor; +class VertexDescriptor; +} // namespace MTL + +namespace mbgl { +namespace mtl { +using CAMetalDrawablePtr = NS::SharedPtr; + +using MTLBlitCommandEncoderPtr = NS::SharedPtr; +using MTLBlitPassDescriptorPtr = NS::SharedPtr; +using MTLBufferPtr = NS::SharedPtr; +using MTLCommandBufferPtr = NS::SharedPtr; +using MTLCommandQueuePtr = NS::SharedPtr; +using MTLDevicePtr = NS::SharedPtr; +using MTLFunctionPtr = NS::SharedPtr; +using MTLRenderCommandEncoderPtr = NS::SharedPtr; +using MTLRenderPassDescriptorPtr = NS::SharedPtr; +using MTLRenderPipelineStatePtr = NS::SharedPtr; +using MTLTexturePtr = NS::SharedPtr; +using MTLTextureDescriptorPtr = NS::SharedPtr; +using MTLSamplerStatePtr = NS::SharedPtr; +using MTLSamplerDescriptorPtr = NS::SharedPtr; +using MTLVertexAttributeDescriptorPtr = NS::SharedPtr; +using MTLVertexBufferLayoutDescriptorPtr = NS::SharedPtr; +using MTLVertexDescriptorPtr = NS::SharedPtr; +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/render_pass.hpp b/include/mbgl/mtl/render_pass.hpp new file mode 100644 index 000000000..966609a58 --- /dev/null +++ b/include/mbgl/mtl/render_pass.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +#include +#include + +#include +#include + +namespace mbgl { +namespace mtl { + +class CommandEncoder; +class Context; + +class RenderPass final : public gfx::RenderPass { +public: + RenderPass(CommandEncoder&, const char* name, const gfx::RenderPassDescriptor&); + ~RenderPass() override; + + const MTLRenderCommandEncoderPtr& getMetalEncoder() const { return encoder; } + const gfx::RenderPassDescriptor& getDescriptor() const { return descriptor; } + + void endEncoding(); + + void addDebugSignpost(const char* name) override; + +private: + void pushDebugGroup(const char* name) override; + void popDebugGroup() override; + +private: + gfx::RenderPassDescriptor descriptor; + mtl::CommandEncoder& commandEncoder; + MTLRenderCommandEncoderPtr encoder; + std::vector> debugGroups; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/renderable_resource.hpp b/include/mbgl/mtl/renderable_resource.hpp new file mode 100644 index 000000000..f469f0a34 --- /dev/null +++ b/include/mbgl/mtl/renderable_resource.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + +#include + +namespace mbgl { +namespace mtl { + +class RendererBackend; + +class RenderableResource : public gfx::RenderableResource { +protected: + explicit RenderableResource() = default; + +public: + virtual void swap() { + // Renderable resources that require a swap function to be called + // explicitly can override this method. + } + + virtual const mbgl::mtl::RendererBackend& getBackend() const = 0; + virtual const mbgl::mtl::MTLCommandBufferPtr& getCommandBuffer() const = 0; + virtual mbgl::mtl::MTLBlitPassDescriptorPtr getUploadPassDescriptor() const = 0; + virtual mbgl::mtl::MTLRenderPassDescriptorPtr getRenderPassDescriptor() const = 0; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/renderer_backend.hpp b/include/mbgl/mtl/renderer_backend.hpp new file mode 100644 index 000000000..b519bb69d --- /dev/null +++ b/include/mbgl/mtl/renderer_backend.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace mbgl { + +class ProgramParameters; + +namespace mtl { + +using ProcAddress = void (*)(); +using FramebufferID = uint32_t; + +class RendererBackend : public gfx::RendererBackend { +public: + RendererBackend(gfx::ContextMode); + ~RendererBackend() override; + + /// Called prior to rendering to update the internally assumed MetalMetal state. + virtual void updateAssumedState() = 0; + + /// One-time shader initialization + void initShaders(gfx::ShaderRegistry&, const ProgramParameters& programParameters) override; + + const MTLDevicePtr& getDevice() const { return device; } + const MTLCommandQueuePtr& getCommandQueue() const { return commandQueue; } + +protected: + std::unique_ptr createContext() override; + + /// Reads the color pixel data from the currently bound framebuffer. + PremultipliedImage readFramebuffer(const Size&); + + /// A constant to signal that a framebuffer is bound, but with an unknown ID. + static constexpr const FramebufferID ImplicitFramebufferBinding = std::numeric_limits::max(); + + /// Tells the renderer that the Metal state has already been set by the windowing toolkit. + /// It sets the internal assumed state to the supplied values. + void assumeFramebufferBinding(FramebufferID fbo); + void assumeViewport(int32_t x, int32_t y, const Size&); + void assumeScissorTest(bool); + + /// Returns true when assumed framebuffer binding hasn't changed from the implicit binding. + bool implicitFramebufferBound(); + +public: + /// Triggers a Metal state update if the internal assumed state doesn't + /// match the supplied values. + void setFramebufferBinding(FramebufferID fbo); + void setViewport(int32_t x, int32_t y, const Size&); + void setScissorTest(bool); + +protected: + MTLDevicePtr device; + MTLCommandQueuePtr commandQueue; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/shader_program_mtl.hpp b/include/mbgl/mtl/shader_program_mtl.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/include/mbgl/mtl/texture2d.hpp b/include/mbgl/mtl/texture2d.hpp new file mode 100644 index 000000000..ad85efc78 --- /dev/null +++ b/include/mbgl/mtl/texture2d.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include +#include +#include + +#include +#include + +#include + +namespace mbgl { +namespace mtl { + +class Context; +class RenderPass; + +class Texture2D : public gfx::Texture2D { +public: + Texture2D(Context& context_); + ~Texture2D() override; + + gfx::Texture2D& setSamplerConfiguration(const SamplerState&) noexcept override; + + gfx::Texture2D& setFormat(gfx::TexturePixelType, gfx::TextureChannelDataType) noexcept override; + + gfx::Texture2D& setSize(Size size_) noexcept override; + + gfx::Texture2D& setImage(std::shared_ptr) noexcept override; + + Size getSize() const noexcept override { return size; } + + size_t getDataSize() const noexcept override; + + size_t getPixelStride() const noexcept override; + + size_t numChannels() const noexcept override; + + void create() noexcept override; + + void upload(const void* pixelData, const Size& size_) noexcept override; + void uploadSubRegion(const void* pixelData, const Size& size, uint16_t xOffset, uint16_t yOffset) noexcept override; + void upload() noexcept override; + + bool needsUpload() const noexcept override { return !!image; }; + + void updateSamplerConfiguration() noexcept; + + /// @brief Bind this texture to the specified location + /// @param renderPass Render pass on which the texture will be assign + /// @param location Location index of texture sampler in a shader + void bind(const RenderPass& renderPass, int32_t location) noexcept; + + /// @brief Unbind the texture, if it was bound + /// @param renderPass Render pass from which the texture will be removed + /// @param location Location index of texture sampler in a shader + void unbind(const RenderPass& renderPass, int32_t location) noexcept; + +private: + MTL::PixelFormat getMetalPixelFormat() const noexcept; + void createMetalTexture() noexcept; + + Context& context; + MTLTexturePtr metalTexture; + MTLSamplerStatePtr metalSamplerState; + + Size size{0, 0}; + gfx::TexturePixelType pixelFormat{gfx::TexturePixelType::RGBA}; + gfx::TextureChannelDataType channelType{gfx::TextureChannelDataType::UnsignedByte}; + SamplerState samplerState{}; + + std::shared_ptr image{nullptr}; + bool textureDirty{true}; + bool samplerStateDirty{true}; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/tile_layer_group.hpp b/include/mbgl/mtl/tile_layer_group.hpp new file mode 100644 index 000000000..d24198d32 --- /dev/null +++ b/include/mbgl/mtl/tile_layer_group.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace mbgl { +namespace mtl { + +/** + A layer group for tile-based drawables + */ +class TileLayerGroup : public mbgl::TileLayerGroup { +public: + TileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name); + ~TileLayerGroup() override {} + + void upload(gfx::UploadPass&) override; + void render(RenderOrchestrator&, PaintParameters&) override; + +protected: +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/uniform_block.hpp b/include/mbgl/mtl/uniform_block.hpp new file mode 100644 index 000000000..22f312497 --- /dev/null +++ b/include/mbgl/mtl/uniform_block.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace mtl { + +class UniformBlockArray; + +class UniformBlock final : public gfx::UniformBlock { + // Can only be created by UniformBlockArray +private: + friend UniformBlockArray; + + UniformBlock(int index_, std::size_t size_) + : gfx::UniformBlock(index_, size_) {} + UniformBlock(const UniformBlock& other) + : gfx::UniformBlock(other) {} + UniformBlock(UniformBlock&& other) + : gfx::UniformBlock(std::move(other)) {} + +public: + void bindBuffer(const gfx::UniformBuffer& uniformBuffer) override; + void unbindBuffer() override; + + bool getBindVertex() const { return bindVertex; } + void setBindVertex(bool value) { bindVertex = value; } + + bool getBindFragment() const { return bindFragment; } + void setBindFragment(bool value) { bindFragment = value; } + +protected: + bool bindVertex = false; + bool bindFragment = false; +}; + +/// Stores a collection of uniform blocks by name +class UniformBlockArray final : public gfx::UniformBlockArray { +public: + UniformBlockArray(int initCapacity = 10) + : gfx::UniformBlockArray(initCapacity) {} + UniformBlockArray(UniformBlockArray&& other) + : gfx::UniformBlockArray(std::move(other)) {} + UniformBlockArray(const UniformBlockArray&) = delete; + + UniformBlockArray& operator=(UniformBlockArray&& other) { + gfx::UniformBlockArray::operator=(std::move(other)); + return *this; + } + UniformBlockArray& operator=(const UniformBlockArray& other) { + gfx::UniformBlockArray::operator=(other); + return *this; + } + +private: + std::unique_ptr create(int index, std::size_t size) override { + return std::unique_ptr(new UniformBlock(index, size)); + } + std::unique_ptr copy(const gfx::UniformBlock& uniformBlocks) override { + return std::unique_ptr(new UniformBlock(static_cast(uniformBlocks))); + } +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/uniform_buffer.hpp b/include/mbgl/mtl/uniform_buffer.hpp new file mode 100644 index 000000000..78331ce4d --- /dev/null +++ b/include/mbgl/mtl/uniform_buffer.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace mtl { + +class UniformBuffer final : public gfx::UniformBuffer { +public: + UniformBuffer(BufferResource&&); + UniformBuffer(const UniformBuffer&) = default; + UniformBuffer(UniformBuffer&&); + ~UniformBuffer() override = default; + + const BufferResource& getBufferResource() const { return buffer; } + + void update(const void* data, std::size_t size_) override; + +protected: + BufferResource buffer; +}; + +/// Stores a collection of uniform buffers by name +class UniformBufferArray final : public gfx::UniformBufferArray { +public: + UniformBufferArray(int initCapacity = 10) + : gfx::UniformBufferArray(initCapacity) {} + UniformBufferArray(UniformBufferArray&& other) + : gfx::UniformBufferArray(std::move(other)) {} + UniformBufferArray(const UniformBufferArray&) = delete; + + UniformBufferArray& operator=(UniformBufferArray&& other) { + gfx::UniformBufferArray::operator=(std::move(other)); + return *this; + } + UniformBufferArray& operator=(const UniformBufferArray& other) { + gfx::UniformBufferArray::operator=(other); + return *this; + } + +private: + gfx::UniqueUniformBuffer copy(const gfx::UniformBuffer& buffer) override { + return std::make_unique(static_cast(buffer)); + } +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/upload_pass.hpp b/include/mbgl/mtl/upload_pass.hpp new file mode 100644 index 000000000..168034d81 --- /dev/null +++ b/include/mbgl/mtl/upload_pass.hpp @@ -0,0 +1,98 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace mbgl { +namespace gfx { + +class CommandEncoder; +class Renderable; +class VertexVectorBase; +using VertexVectorBasePtr = std::shared_ptr; + +} // namespace gfx + +namespace mtl { + +class BufferResource; +class CommandEncoder; +class Context; +class VertexArray; +class Texture2D; + +class RenderbufferResource : public gfx::RenderbufferResource { +public: + RenderbufferResource() = default; +}; + +class UploadPass final : public gfx::UploadPass { +public: + UploadPass(gfx::Renderable&, CommandEncoder&, const char* name); + ~UploadPass() override; + + gfx::Context& getContext() override; + const gfx::Context& getContext() const override; + + std::unique_ptr createVertexBufferResource(const void* data, + std::size_t size, + gfx::BufferUsageType) override; + void updateVertexBufferResource(gfx::VertexBufferResource&, const void* data, std::size_t size) override; + + std::unique_ptr createIndexBufferResource(const void* data, + std::size_t size, + gfx::BufferUsageType) override; + void updateIndexBufferResource(gfx::IndexBufferResource&, const void* data, std::size_t size) override; + + void updateResource(BufferResource&, const void* data, std::size_t size); + + const gfx::UniqueVertexBufferResource& getBuffer(const gfx::VertexVectorBasePtr&, gfx::BufferUsageType); + + gfx::AttributeBindingArray buildAttributeBindings( + const std::size_t vertexCount, + const gfx::AttributeDataType vertexType, + const std::size_t vertexAttributeIndex, + const std::vector& vertexData, + const gfx::VertexAttributeArray& defaults, + const gfx::VertexAttributeArray& overrides, + gfx::BufferUsageType, + /*out*/ std::vector>& outBuffers) override; + + std::unique_ptr createTextureResource(Size, + const void* data, + gfx::TexturePixelType, + gfx::TextureChannelDataType) override; + void updateTextureResource( + gfx::TextureResource&, Size, const void* data, gfx::TexturePixelType, gfx::TextureChannelDataType) override; + + void updateTextureResourceSub(gfx::TextureResource&, + uint16_t xOffset, + uint16_t yOffset, + Size, + const void* data, + gfx::TexturePixelType, + gfx::TextureChannelDataType) override; + +private: + void pushDebugGroup(const char* name) override; + void popDebugGroup() override; + + void endEncoding(); + +private: + CommandEncoder& commandEncoder; + MTLCommandBufferPtr buffer; + MTLBlitCommandEncoderPtr encoder; + std::vector> debugGroups; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/vertex_attribute.hpp b/include/mbgl/mtl/vertex_attribute.hpp new file mode 100644 index 000000000..37c125b78 --- /dev/null +++ b/include/mbgl/mtl/vertex_attribute.hpp @@ -0,0 +1,75 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace gfx { +class VertexBufferResource; +} // namespace gfx +namespace mtl { + +class VertexAttributeArray; +class UploadPass; + +class VertexAttribute final : public gfx::VertexAttribute { + // Can only be created by VertexAttributeArray +private: + friend VertexAttributeArray; + VertexAttribute(int index_, gfx::AttributeDataType dataType_, std::size_t count_) + : gfx::VertexAttribute(index_, dataType_, count_, /*stride_=*/0) {} + VertexAttribute(const VertexAttribute& other) + : gfx::VertexAttribute(other) {} + VertexAttribute(VertexAttribute&& other) + : gfx::VertexAttribute(std::move(other)) {} + +public: + ~VertexAttribute() override = default; + + /// Get the Metal buffer, creating it if necessary + // const gfx::UniqueVertexBufferResource& getBuffer(UploadPass&, const gfx::BufferUsageType); + + static const gfx::UniqueVertexBufferResource& getBuffer(gfx::VertexAttribute&, + UploadPass&, + const gfx::BufferUsageType); + + static std::size_t getStrideOf(gfx::AttributeDataType); +}; + +/// Stores a collection of vertex attributes by name +class VertexAttributeArray final : public gfx::VertexAttributeArray { +public: + VertexAttributeArray(int initCapacity = 10) + : gfx::VertexAttributeArray(initCapacity) {} + VertexAttributeArray(VertexAttributeArray&& other) + : gfx::VertexAttributeArray(std::move(other)) {} + + VertexAttributeArray& operator=(VertexAttributeArray&& other) { + gfx::VertexAttributeArray::operator=(std::move(other)); + return *this; + } + VertexAttributeArray& operator=(const VertexAttributeArray& other) { + gfx::VertexAttributeArray::operator=(other); + return *this; + } + + gfx::UniqueVertexAttributeArray clone() const override { + auto newAttrs = std::make_unique(); + newAttrs->copy(*this); + return newAttrs; + } + +private: + gfx::UniqueVertexAttribute create(int index, gfx::AttributeDataType dataType, std::size_t count) const override { + return gfx::UniqueVertexAttribute(new VertexAttribute(index, dataType, count)); + } + + using gfx::VertexAttributeArray::copy; + + gfx::UniqueVertexAttribute copy(const gfx::VertexAttribute& attr) const override { + return gfx::UniqueVertexAttribute(new VertexAttribute(static_cast(attr))); + } +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/mtl/vertex_buffer_resource.hpp b/include/mbgl/mtl/vertex_buffer_resource.hpp new file mode 100644 index 000000000..70a0415bb --- /dev/null +++ b/include/mbgl/mtl/vertex_buffer_resource.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include + +namespace mbgl { +namespace mtl { + +class VertexBufferResource : public gfx::VertexBufferResource { +public: + VertexBufferResource() = default; + VertexBufferResource(BufferResource&& ptr) + : buffer(std::move(ptr)) {} + VertexBufferResource(VertexBufferResource&& other) + : buffer(std::move(other.buffer)) {} + + std::size_t getSizeInBytes() const { return buffer.getSizeInBytes(); } + void* contents() const { return buffer.contents(); } + + BufferResource& get() { return buffer; } + const BufferResource& get() const { return buffer; } + +protected: + BufferResource buffer; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/renderer/layer_tweaker.hpp b/include/mbgl/renderer/layer_tweaker.hpp index f01e201bf..170d0c86e 100644 --- a/include/mbgl/renderer/layer_tweaker.hpp +++ b/include/mbgl/renderer/layer_tweaker.hpp @@ -4,12 +4,17 @@ #include #include +#include +#include namespace mbgl { namespace gfx { class UniformBuffer; using UniformBufferPtr = std::shared_ptr; } // namespace gfx +namespace shaders { +struct ExpressionInputsUBO; +} // namespace shaders namespace style { class LayerProperties; enum class TranslateAnchorType : bool; @@ -27,12 +32,30 @@ using mat4 = std::array; */ class LayerTweaker { protected: - LayerTweaker(Immutable properties); + LayerTweaker(std::string id, Immutable properties); public: LayerTweaker() = delete; virtual ~LayerTweaker() = default; + const std::string& getID() const { return id; } + +#if MLN_RENDER_BACKEND_METAL + /// Build the common expression inupts UBO + static shaders::ExpressionInputsUBO buildExpressionUBO(double zoom, uint64_t frameCount); + + /// @brief Set the collection of attribute names which will be provided at uniform values rather than per-vertex + /// attributes. + /// @details These values should not have "a_" prefixes, as produced by `readDataDrivenPaintProperties`. + void setPropertiesAsUniforms(std::vector); + + /// @brief Check whether a property name exists within the previously set collection. + /// @details The string value provided is expected to have the "a_" prefix, as defined in the shader classes. + bool hasPropertyAsUniform(std::string_view) const; +#endif // MLN_RENDER_BACKEND_METAL + + void enableOverdrawInspector(bool); + virtual void execute(LayerGroupBase&, const RenderTree&, const PaintParameters&) = 0; protected: @@ -49,7 +72,17 @@ protected: bool aligned = false); protected: + std::string id; Immutable evaluatedProperties; + +#if MLN_RENDER_BACKEND_METAL + // For Metal, whether a property is provided through attribtues or uniforms is specified in + // a uniform buffer rather than by a shader compiled with different preprocessor definitions. + std::vector propertiesAsUniforms; +#endif // MLN_RENDER_BACKEND_METAL + + bool propertiesChanged = true; + bool overdrawInspector = false; }; } // namespace mbgl diff --git a/include/mbgl/shaders/background_layer_ubo.hpp b/include/mbgl/shaders/background_layer_ubo.hpp new file mode 100644 index 000000000..4e136acdf --- /dev/null +++ b/include/mbgl/shaders/background_layer_ubo.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include + +#include + +namespace mbgl { +namespace shaders { + +struct alignas(16) BackgroundDrawableUBO { + std::array matrix; +}; +static_assert(sizeof(BackgroundDrawableUBO) % 16 == 0); + +struct alignas(16) BackgroundLayerUBO { + /* 0 */ Color color; + /* 16 */ float opacity; + /* 20 */ float pad1, pad2, pad3; + /* 32 */ +}; +static_assert(sizeof(BackgroundLayerUBO) == 32); + +struct alignas(16) BackgroundPatternLayerUBO { + /* 0 */ std::array pattern_tl_a; + /* 8 */ std::array pattern_br_a; + /* 16 */ std::array pattern_tl_b; + /* 24 */ std::array pattern_br_b; + /* 32 */ std::array texsize; + /* 40 */ std::array pattern_size_a; + /* 48 */ std::array pattern_size_b; + /* 56 */ std::array pixel_coord_upper; + /* 64 */ std::array pixel_coord_lower; + /* 72 */ float tile_units_to_pixels; + /* 76 */ float scale_a; + /* 80 */ float scale_b; + /* 84 */ float mix; + /* 88 */ float opacity; + /* 92 */ float pad; + /* 96 */ +}; +static_assert(sizeof(BackgroundPatternLayerUBO) == 96); + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/circle_layer_ubo.hpp b/include/mbgl/shaders/circle_layer_ubo.hpp new file mode 100644 index 000000000..b223882ec --- /dev/null +++ b/include/mbgl/shaders/circle_layer_ubo.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include + +namespace mbgl { +namespace shaders { + +struct alignas(16) CircleDrawableUBO { + /* 0 */ std::array matrix; // composite model-view-projection matrix + /* 64 */ std::array extrude_scale; + /* 72 */ float pad; + /* 80 */ +}; +static_assert(sizeof(CircleDrawableUBO) == 5 * 16); + +struct alignas(16) CirclePaintParamsUBO { + /* 0 */ float camera_to_center_distance; + /* 4 */ float device_pixel_ratio; + /* 8 */ float pad1, pad2; + /* 16 */ +}; +static_assert(sizeof(CirclePaintParamsUBO) == 1 * 16); + +struct alignas(16) CircleEvaluatedPropsUBO { + Color color; + Color stroke_color; + float radius; + float blur; + float opacity; + float stroke_width; + float stroke_opacity; + int scale_with_map; + int pitch_with_map; + float padding; +}; +static_assert(sizeof(CircleEvaluatedPropsUBO) % 16 == 0); + +struct alignas(16) CircleInterpolateUBO { + float color_t; + float radius_t; + float blur_t; + float opacity_t; + float stroke_color_t; + float stroke_width_t; + float stroke_opacity_t; + float padding; +}; +static_assert(sizeof(CircleInterpolateUBO) % 16 == 0); + +struct alignas(16) CirclePermutationUBO { + /* 0 */ Attribute color; + /* 8 */ Attribute radius; + /* 16 */ Attribute blur; + /* 24 */ Attribute opacity; + /* 32 */ Attribute stroke_color; + /* 40 */ Attribute stroke_width; + /* 48 */ Attribute stroke_opacity; + /* 56 */ bool overdrawInspector; + /* 57 */ uint8_t pad1, pad2, pad3; + /* 60 */ float pad4; + /* 64 */ +}; +static_assert(sizeof(CirclePermutationUBO) == 4 * 16); + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/fill_layer_ubo.hpp b/include/mbgl/shaders/fill_layer_ubo.hpp new file mode 100644 index 000000000..5cf551d71 --- /dev/null +++ b/include/mbgl/shaders/fill_layer_ubo.hpp @@ -0,0 +1,166 @@ +#pragma once + +#include + +namespace mbgl { +namespace shaders { + +// +// Fill + +struct alignas(16) FillDrawableUBO { + /* 0 */ std::array matrix; // composite model-view-projection matrix +}; +static_assert(sizeof(FillDrawableUBO) == 4 * 16); + +struct alignas(16) FillEvaluatedPropsUBO { + Color color; + float opacity; + float pad1, pad2, pad3; +}; +static_assert(sizeof(FillEvaluatedPropsUBO) == 2 * 16); + +struct alignas(16) FillInterpolateUBO { + float color_t; + float opacity_t; + float pad1, pad2; +}; +static_assert(sizeof(FillInterpolateUBO) % 16 == 0); + +struct alignas(16) FillPermutationUBO { + /* 0 */ Attribute color; + /* 8 */ Attribute opacity; + /* 16 */ bool overdrawInspector; + /* 17 */ bool pad1, pad2, pad3; + /* 20 */ float pad4, pad5, pad6; + /* 32 */ +}; +static_assert(sizeof(FillPermutationUBO) == 2 * 16); + +// +// Fill outline + +struct alignas(16) FillOutlineDrawableUBO { + /* 0 */ std::array matrix; // composite model-view-projection matrix + /* 64 */ std::array world; + /* 80 */ +}; +static_assert(sizeof(FillOutlineDrawableUBO) == 5 * 16); + +struct alignas(16) FillOutlineEvaluatedPropsUBO { + Color outline_color; + float opacity; + float pad1, pad2, pad3; +}; +static_assert(sizeof(FillOutlineEvaluatedPropsUBO) == 2 * 16); + +struct alignas(16) FillOutlineInterpolateUBO { + float outline_color_t; + float opacity_t; + float pad1, pad2; +}; +static_assert(sizeof(FillOutlineInterpolateUBO) == 1 * 16); + +struct alignas(16) FillOutlinePermutationUBO { + /* 0 */ Attribute outline_color; + /* 8 */ Attribute opacity; + /* 16 */ bool overdrawInspector; + /* 17 */ bool pad1, pad2, pad3; + /* 20 */ float pad4, pad5, pad6; + /* 32 */ +}; +static_assert(sizeof(FillOutlinePermutationUBO) == 2 * 16); + +// +// Fill Pattern + +struct alignas(16) FillPatternDrawableUBO { + /* 0 */ std::array matrix; // composite model-view-projection matrix + /* 64 */ std::array scale; + /* 80 */ std::array pixel_coord_upper; + /* 88 */ std::array pixel_coord_lower; + /* 96 */ std::array texsize; + /* 104 */ float pad1, pad2; + /* 112 */ +}; +static_assert(sizeof(FillPatternDrawableUBO) == 7 * 16); + +struct alignas(16) FillPatternEvaluatedPropsUBO { + float opacity; + float fade; + float pad1, pad2; +}; +static_assert(sizeof(FillPatternEvaluatedPropsUBO) == 1 * 16); + +struct alignas(16) FillPatternTilePropsUBO { + std::array pattern_from; + std::array pattern_to; +}; +static_assert(sizeof(FillPatternTilePropsUBO) == 2 * 16); + +struct alignas(16) FillPatternInterpolateUBO { + float pattern_from_t; + float pattern_to_t; + float opacity_t; + float pad1; +}; +static_assert(sizeof(FillPatternInterpolateUBO) == 1 * 16); + +struct alignas(16) FillPatternPermutationUBO { + /* 0 */ Attribute pattern_from; + /* 8 */ Attribute pattern_to; + /* 16 */ Attribute opacity; + /* 24 */ bool overdrawInspector; + /* 25 */ bool pad1, pad2, pad3; + /* 28 */ float pad4; + /* 32 */ +}; +static_assert(sizeof(FillPatternPermutationUBO) == 2 * 16); + +// +// Fill pattern outline + +struct alignas(16) FillOutlinePatternDrawableUBO { + /* 0 */ std::array matrix; // composite model-view-projection matrix + /* 64 */ std::array scale; + /* 80 */ std::array world; + /* 88 */ std::array pixel_coord_upper; + /* 96 */ std::array pixel_coord_lower; + /* 104 */ std::array texsize; +}; +static_assert(sizeof(FillOutlinePatternDrawableUBO) == 7 * 16); + +struct alignas(16) FillOutlinePatternEvaluatedPropsUBO { + float opacity; + float fade; + float pad1, pad2; +}; +static_assert(sizeof(FillOutlinePatternEvaluatedPropsUBO) == 16); + +struct alignas(16) FillOutlinePatternTilePropsUBO { + std::array pattern_from; + std::array pattern_to; +}; +static_assert(sizeof(FillOutlinePatternTilePropsUBO) == 2 * 16); + +struct alignas(16) FillOutlinePatternInterpolateUBO { + float pattern_from_t; + float pattern_to_t; + float opacity_t; + float pad; +}; +static_assert(sizeof(FillOutlinePatternInterpolateUBO) == 1 * 16); + +struct alignas(16) FillOutlinePatternPermutationUBO { + /* 0 */ Attribute pattern_from; + /* 8 */ Attribute pattern_to; + /* 16 */ Attribute opacity; + /* 24 */ bool overdrawInspector; + /* 17 */ bool pad1, pad2, pad3; + /* 20 */ float pad4; + /* 32 */ +}; +static_assert(sizeof(FillOutlinePatternPermutationUBO) == 2 * 16); + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/gl/drawable_fill.hpp b/include/mbgl/shaders/gl/drawable_fill.hpp index b65c3fde3..988a0d525 100644 --- a/include/mbgl/shaders/gl/drawable_fill.hpp +++ b/include/mbgl/shaders/gl/drawable_fill.hpp @@ -8,35 +8,20 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* name = "FillShader"; - static constexpr const char* vertex = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { + static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO { highp mat4 u_matrix; - highp vec4 u_scale; - highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { +layout (std140) uniform FillEvaluatedPropsUBO { highp vec4 u_color; - highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillInterpolateUBO { + highp float u_color_t; + highp float u_opacity_t; + highp float pad_interp_1, pad_interp_2; }; layout (location = 0) in vec2 a_pos; @@ -65,35 +50,17 @@ lowp float opacity = u_opacity; gl_Position = u_matrix * vec4(a_pos, 0, 1); } )"; - static constexpr const char* fragment = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { - highp mat4 u_matrix; - highp vec4 u_scale; - highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; -}; -layout (std140) uniform FillDrawablePropsUBO { + static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO { highp vec4 u_color; - highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillInterpolateUBO { + highp float u_color_t; + highp float u_opacity_t; + highp float pad_interp_1, pad_interp_2; }; #ifndef HAS_UNIFORM_u_color diff --git a/include/mbgl/shaders/gl/drawable_fill_outline.hpp b/include/mbgl/shaders/gl/drawable_fill_outline.hpp index 0201e004a..2e90ca776 100644 --- a/include/mbgl/shaders/gl/drawable_fill_outline.hpp +++ b/include/mbgl/shaders/gl/drawable_fill_outline.hpp @@ -8,35 +8,22 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* name = "FillOutlineShader"; - static constexpr const char* vertex = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { + static constexpr const char* vertex = R"(layout (std140) uniform FillOutlineDrawableUBO { highp mat4 u_matrix; - highp vec4 u_scale; highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; +layout (std140) uniform FillOutlineEvaluatedPropsUBO { highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillOutlineInterpolateUBO { + highp float u_outline_color_t; + highp float u_opacity_t; + highp float u_padding_interp1; + highp float u_padding_interp2; }; layout (location = 0) in vec2 a_pos; @@ -68,35 +55,18 @@ lowp float opacity = u_opacity; v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; } )"; - static constexpr const char* fragment = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { - highp mat4 u_matrix; - highp vec4 u_scale; - highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; -}; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; + static constexpr const char* fragment = R"(layout (std140) uniform FillOutlineEvaluatedPropsUBO { highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillOutlineInterpolateUBO { + highp float u_outline_color_t; + highp float u_opacity_t; + highp float u_padding_interp1; + highp float u_padding_interp2; }; in vec2 v_pos; diff --git a/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp index c1a50e9f1..b62c98ded 100644 --- a/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp +++ b/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp @@ -8,17 +8,7 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* name = "FillOutlinePatternShader"; - static constexpr const char* vertex = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { + static constexpr const char* vertex = R"(layout (std140) uniform FillOutlinePatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; highp vec2 u_world; @@ -26,15 +16,19 @@ layout (std140) uniform FillDrawableUBO { highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillOutlinePatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillOutlinePatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float pad1; +}; +layout (std140) uniform FillOutlinePatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; @@ -96,17 +90,7 @@ mediump vec4 pattern_to = u_pattern_to; v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; } )"; - static constexpr const char* fragment = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { + static constexpr const char* fragment = R"(layout (std140) uniform FillOutlinePatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; highp vec2 u_world; @@ -114,15 +98,19 @@ layout (std140) uniform FillDrawableUBO { highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillOutlinePatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillOutlinePatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float pad1; +}; +layout (std140) uniform FillOutlinePatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; diff --git a/include/mbgl/shaders/gl/drawable_fill_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_pattern.hpp index f76aecd2c..8594792e2 100644 --- a/include/mbgl/shaders/gl/drawable_fill_pattern.hpp +++ b/include/mbgl/shaders/gl/drawable_fill_pattern.hpp @@ -8,33 +8,26 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* name = "FillPatternShader"; - static constexpr const char* vertex = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { + static constexpr const char* vertex = R"(layout (std140) uniform FillPatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; - highp vec2 u_world; highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillPatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float u_padding_interp1; +}; +layout (std140) uniform FillPatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; @@ -92,33 +85,26 @@ mediump vec4 pattern_to = u_pattern_to; v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos); } )"; - static constexpr const char* fragment = R"(layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { + static constexpr const char* fragment = R"(layout (std140) uniform FillPatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; - highp vec2 u_world; highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillPatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float u_padding_interp1; +}; +layout (std140) uniform FillPatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; diff --git a/include/mbgl/shaders/gl/drawable_line_sdf.hpp b/include/mbgl/shaders/gl/drawable_line_sdf.hpp index d36cbf1e5..37c641081 100644 --- a/include/mbgl/shaders/gl/drawable_line_sdf.hpp +++ b/include/mbgl/shaders/gl/drawable_line_sdf.hpp @@ -56,6 +56,7 @@ layout (std140) uniform LineSDFInterpolationUBO { lowp float u_offset_t; lowp float u_width_t; lowp float u_floorwidth_t; + highp float pad2; }; @@ -215,6 +216,7 @@ layout (std140) uniform LineSDFInterpolationUBO { lowp float u_offset_t; lowp float u_width_t; lowp float u_floorwidth_t; + highp float pad2; }; diff --git a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_icon.hpp index 3ed326a2b..ea662bd41 100644 --- a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp +++ b/include/mbgl/shaders/gl/drawable_symbol_icon.hpp @@ -29,8 +29,13 @@ layout (std140) uniform SymbolDrawableUBO { highp float u_pitch; bool u_rotate_symbol; highp float u_aspect_ratio; + highp vec2 u_pad1; +}; + +layout (std140) uniform SymbolDynamicUBO { highp float u_fade_change; - highp float u_pad2; + highp float u_pad7; + highp vec2 u_pad8; }; layout (std140) uniform SymbolDrawablePaintUBO { diff --git a/include/mbgl/shaders/gl/drawable_symbol_sdf_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_sdf_icon.hpp index 132b2894c..e32be9b92 100644 --- a/include/mbgl/shaders/gl/drawable_symbol_sdf_icon.hpp +++ b/include/mbgl/shaders/gl/drawable_symbol_sdf_icon.hpp @@ -37,8 +37,13 @@ layout (std140) uniform SymbolDrawableUBO { highp float u_pitch; bool u_rotate_symbol; highp float u_aspect_ratio; + highp vec2 u_pad1; +}; + +layout (std140) uniform SymbolDynamicUBO { highp float u_fade_change; - highp float u_pad2; + highp float u_pad7; + highp vec2 u_pad8; }; layout (std140) uniform SymbolDrawablePaintUBO { @@ -207,8 +212,13 @@ layout (std140) uniform SymbolDrawableUBO { highp float u_pitch; bool u_rotate_symbol; highp float u_aspect_ratio; + highp vec2 u_pad1; +}; + +layout (std140) uniform SymbolDynamicUBO { highp float u_fade_change; - highp float u_pad2; + highp float u_pad7; + highp vec2 u_pad8; }; layout (std140) uniform SymbolDrawablePaintUBO { diff --git a/include/mbgl/shaders/gl/drawable_symbol_sdf_text.hpp b/include/mbgl/shaders/gl/drawable_symbol_sdf_text.hpp index 527c4fad5..7dbcfb10f 100644 --- a/include/mbgl/shaders/gl/drawable_symbol_sdf_text.hpp +++ b/include/mbgl/shaders/gl/drawable_symbol_sdf_text.hpp @@ -37,8 +37,13 @@ layout (std140) uniform SymbolDrawableUBO { highp float u_pitch; bool u_rotate_symbol; highp float u_aspect_ratio; + highp vec2 u_pad1; +}; + +layout (std140) uniform SymbolDynamicUBO { highp float u_fade_change; - highp float u_pad2; + highp float u_pad7; + highp vec2 u_pad8; }; layout (std140) uniform SymbolDrawablePaintUBO { @@ -207,8 +212,13 @@ layout (std140) uniform SymbolDrawableUBO { highp float u_pitch; bool u_rotate_symbol; highp float u_aspect_ratio; + highp vec2 u_pad1; +}; + +layout (std140) uniform SymbolDynamicUBO { highp float u_fade_change; - highp float u_pad2; + highp float u_pad7; + highp vec2 u_pad8; }; layout (std140) uniform SymbolDrawablePaintUBO { diff --git a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp index 764dc6282..3ad6da0a9 100644 --- a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp +++ b/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp @@ -36,8 +36,13 @@ layout (std140) uniform SymbolDrawableUBO { highp float u_pitch; bool u_rotate_symbol; highp float u_aspect_ratio; + highp vec2 u_pad1; +}; + +layout (std140) uniform SymbolDynamicUBO { highp float u_fade_change; - highp float u_pad2; + highp float u_pad7; + highp vec2 u_pad8; }; layout (std140) uniform SymbolDrawablePaintUBO { @@ -210,8 +215,13 @@ layout (std140) uniform SymbolDrawableUBO { highp float u_pitch; bool u_rotate_symbol; highp float u_aspect_ratio; + highp vec2 u_pad1; +}; + +layout (std140) uniform SymbolDynamicUBO { highp float u_fade_change; - highp float u_pad2; + highp float u_pad7; + highp vec2 u_pad8; }; layout (std140) uniform SymbolDrawablePaintUBO { diff --git a/include/mbgl/shaders/gl/hillshade_prepare.hpp b/include/mbgl/shaders/gl/hillshade_prepare.hpp index 82fd08ff7..08daf3683 100644 --- a/include/mbgl/shaders/gl/hillshade_prepare.hpp +++ b/include/mbgl/shaders/gl/hillshade_prepare.hpp @@ -78,7 +78,7 @@ void main() { // we want to vertically exaggerate the hillshading though, because otherwise // it is barely noticeable at low zooms. to do this, we multiply this by some // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value - // Here we use a=0.3 which works out to the expression below. see + // Here we use a=0.3 which works out to the expression below. see // nickidlugash's awesome breakdown for more info // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556 float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3; diff --git a/include/mbgl/shaders/layer_ubo.hpp b/include/mbgl/shaders/layer_ubo.hpp new file mode 100644 index 000000000..7caac8f20 --- /dev/null +++ b/include/mbgl/shaders/layer_ubo.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include + +#include +#include + +#define MLN_STRINGIZE(X) #X + +namespace mbgl { +namespace shaders { + +enum class AttributeSource : int32_t { + Constant, + PerVertex, + Computed, +}; + +enum class ExpressionFunction : int32_t { + Constant, + Linear, + Exponential, +}; + +struct Expression { + /* 0 */ ExpressionFunction function; + /* 4 */ +}; +static_assert(sizeof(Expression) == 4); + +struct Attribute { + /* 0 */ AttributeSource source; + /* 4 */ Expression expression; + /* 8 */ +}; +static_assert(sizeof(Attribute) == 8); + +struct alignas(16) ExpressionInputsUBO { + // These can use uint64_t in later versions of Metal + /* 0 */ uint32_t time_lo; /// Current scene time (nanoseconds) + /* 4 */ uint32_t time_hi; + /* 8 */ uint32_t frame_lo; /// Current frame count + /* 12 */ uint32_t frame_hi; + /* 16 */ float zoom; /// Current zoom level + /* 20 */ float zoom_frac; /// double precision zoom + /* 24 */ float pad1, pad2; + /* 32 */ +}; +static_assert(sizeof(ExpressionInputsUBO) == 2 * 16); + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/line_layer_ubo.hpp b/include/mbgl/shaders/line_layer_ubo.hpp new file mode 100644 index 000000000..4255eab7e --- /dev/null +++ b/include/mbgl/shaders/line_layer_ubo.hpp @@ -0,0 +1,158 @@ +#pragma once + +#include + +namespace mbgl { +namespace shaders { + +struct alignas(16) LineUBO { + std::array matrix; + std::array units_to_pixels; + float ratio; + float device_pixel_ratio; +}; +static_assert(sizeof(LineUBO) % 16 == 0); + +using LineGradientUBO = LineUBO; + +struct alignas(16) LinePropertiesUBO { + Color color; + float blur; + float opacity; + float gapwidth; + float offset; + float width; + float pad1, pad2, pad3; +}; +static_assert(sizeof(LinePropertiesUBO) % 16 == 0); + +struct alignas(16) LineGradientPropertiesUBO { + float blur; + float opacity; + float gapwidth; + float offset; + float width; + float pad1, pad2, pad3; +}; +static_assert(sizeof(LineGradientPropertiesUBO) % 16 == 0); + +struct alignas(16) LinePatternUBO { + std::array matrix; + std::array scale; + std::array texsize; + std::array units_to_pixels; + float ratio; + float device_pixel_ratio; + float fade; + float pad1; +}; +static_assert(sizeof(LinePatternUBO) % 16 == 0); + +struct alignas(16) LinePatternPropertiesUBO { + float blur; + float opacity; + float offset; + float gapwidth; + float width; + float pad1, pad2, pad3; +}; +static_assert(sizeof(LinePatternPropertiesUBO) % 16 == 0); + +struct alignas(16) LineSDFUBO { + std::array matrix; + std::array units_to_pixels; + std::array patternscale_a; + std::array patternscale_b; + float ratio; + float device_pixel_ratio; + float tex_y_a; + float tex_y_b; + float sdfgamma; + float mix; +}; +static_assert(sizeof(LineSDFUBO) % 16 == 0); + +struct alignas(16) LineSDFPropertiesUBO { + Color color; + float blur; + float opacity; + float gapwidth; + float offset; + float width; + float floorwidth; + float pad1, pad2; +}; +static_assert(sizeof(LineSDFPropertiesUBO) % 16 == 0); + +/// Property interpolation UBOs +struct alignas(16) LineInterpolationUBO { + float color_t; + float blur_t; + float opacity_t; + float gapwidth_t; + float offset_t; + float width_t; + float pad1, pad2; +}; +static_assert(sizeof(LineInterpolationUBO) % 16 == 0); + +struct alignas(16) LineGradientInterpolationUBO { + float blur_t; + float opacity_t; + float gapwidth_t; + float offset_t; + float width_t; + float pad1, pad2, pad3; +}; +static_assert(sizeof(LineGradientInterpolationUBO) % 16 == 0); + +struct alignas(16) LinePatternInterpolationUBO { + float blur_t; + float opacity_t; + float offset_t; + float gapwidth_t; + float width_t; + float pattern_from_t; + float pattern_to_t; + float pad1; +}; +static_assert(sizeof(LinePatternInterpolationUBO) % 16 == 0); + +struct alignas(16) LineSDFInterpolationUBO { + float color_t; + float blur_t; + float opacity_t; + float gapwidth_t; + float offset_t; + float width_t; + float floorwidth_t; + float pad1; +}; +static_assert(sizeof(LineSDFInterpolationUBO) % 16 == 0); + +/// Evaluated properties that depend on the tile +struct alignas(16) LinePatternTilePropertiesUBO { + std::array pattern_from; + std::array pattern_to; +}; +static_assert(sizeof(LinePatternTilePropertiesUBO) % 16 == 0); + +struct alignas(16) LinePermutationUBO { + /* 0 */ Attribute color; + /* 8 */ Attribute blur; + /* 16 */ Attribute opacity; + /* 24 */ Attribute gapwidth; + /* 32 */ Attribute offset; + /* 40 */ Attribute width; + /* 48 */ Attribute floorwidth; + /* 56 */ Attribute pattern_from; + /* 64 */ Attribute pattern_to; + /* 72 */ bool overdrawInspector; + /* 73 */ uint8_t pad1, pad2, pad3; + /* 76 */ float pad4; + /* 80 */ +}; +static_assert(sizeof(LinePermutationUBO) == 5 * 16); + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/background.hpp b/include/mbgl/shaders/mtl/background.hpp new file mode 100644 index 000000000..b5e799fca --- /dev/null +++ b/include/mbgl/shaders/mtl/background.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include +#include +#include +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource { + static constexpr auto name = "BackgroundShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Float3, 1, "a_pos"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(1, true, true, BackgroundLayerUBO), + MLN_MTL_UNIFORM_BLOCK(2, true, false, BackgroundDrawableUBO), + }; + static constexpr TextureInfo textures[] = {}; + + static constexpr auto source = R"( +#include +using namespace metal; + +struct VertexStage { + short2 position [[attribute(0)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; +}; + +struct alignas(16) BackgroundDrawableUBO { + float4x4 matrix; +}; +struct alignas(16) BackgroundLayerUBO { + float4 color; + float opacity, pad1, pad2, pad3; +}; + +FragmentStage vertex vertexMain(VertexStage in [[stage_in]], + device const BackgroundLayerUBO& layerUBO [[buffer(1)]], + device const BackgroundDrawableUBO& drawableUBO [[buffer(2)]]) { + return { + .position = drawableUBO.matrix * float4(float2(in.position.xy), 0, 1) + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const BackgroundLayerUBO& layerUBO [[buffer(1)]]) { +#ifdef OVERDRAW_INSPECTOR + return half4(1.0); +#else + return half4(float4(layerUBO.color.rgb, layerUBO.color.a * layerUBO.opacity)); +#endif +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/background_pattern.hpp b/include/mbgl/shaders/mtl/background_pattern.hpp new file mode 100644 index 000000000..428fb855a --- /dev/null +++ b/include/mbgl/shaders/mtl/background_pattern.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource + : public ShaderSource { + static constexpr auto name = "BackgroundPatternShader"; + static constexpr UniformBlockInfo uniforms[] = { + {1, sizeof(BackgroundLayerUBO), true, false, "BackgroundLayerUBO"}, + {2, sizeof(BackgroundDrawableUBO), true, false, "BackgroundDrawableUBO"}, + {3, sizeof(BackgroundPatternLayerUBO), true, false, "BackgroundPatternLayerUBO"}, + }; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/circle.hpp b/include/mbgl/shaders/mtl/circle.hpp new file mode 100644 index 000000000..42eb9fc18 --- /dev/null +++ b/include/mbgl/shaders/mtl/circle.hpp @@ -0,0 +1,193 @@ +#pragma once + +#include +#include +#include +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource { + static constexpr auto name = "CircleShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos"}, + {1, gfx::AttributeDataType::Float2, 1, "a_color"}, + {2, gfx::AttributeDataType::Float2, 1, "a_radius"}, + {3, gfx::AttributeDataType::Float2, 1, "a_blur"}, + {4, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + {5, gfx::AttributeDataType::Float4, 1, "a_stroke_color"}, + {6, gfx::AttributeDataType::Float2, 1, "a_stroke_width"}, + {7, gfx::AttributeDataType::Float2, 1, "a_stroke_opacity"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(8, true, false, CircleDrawableUBO), + MLN_MTL_UNIFORM_BLOCK(9, true, true, CirclePaintParamsUBO), + MLN_MTL_UNIFORM_BLOCK(10, true, true, CircleEvaluatedPropsUBO), + MLN_MTL_UNIFORM_BLOCK(11, true, false, CircleInterpolateUBO), + MLN_MTL_UNIFORM_BLOCK(12, true, true, CirclePermutationUBO), + MLN_MTL_UNIFORM_BLOCK(13, true, false, ExpressionInputsUBO), + }; + static constexpr TextureInfo textures[] = {}; + + static constexpr auto source = R"( + +struct VertexStage { + short2 position [[attribute(0)]]; + float2 color [[attribute(1)]]; + float2 radius [[attribute(2)]]; + float2 blur [[attribute(3)]]; + float2 opacity [[attribute(4)]]; + float4 stroke_color [[attribute(5)]]; + float2 stroke_width [[attribute(6)]]; + float2 stroke_opacity [[attribute(7)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float4 color; + float radius; + half blur; + half opacity; + float4 stroke_color; + float stroke_width; + half stroke_opacity; + + float2 extrude; + half antialiasblur; +}; + +struct alignas(16) CircleDrawableUBO { + float4x4 matrix; + float2 extrude_scale; + float2 padding; +}; +struct alignas(16) CirclePaintParamsUBO { + float camera_to_center_distance; + float device_pixel_ratio; + float pad1,pad2; +}; +struct alignas(16) CircleEvaluatedPropsUBO { + float4 color; + float4 stroke_color; + float radius; + float blur; + float opacity; + float stroke_width; + float stroke_opacity; + int scale_with_map; + int pitch_with_map; + float padding; +}; + +struct alignas(16) CircleInterpolateUBO { + float color_t; + float radius_t; + float blur_t; + float opacity_t; + float stroke_color_t; + float stroke_width_t; + float stroke_opacity_t; + float pad1_; +}; + +struct alignas(16) CirclePermutationUBO { + Attribute color; + Attribute radius; + Attribute blur; + Attribute opacity; + Attribute stroke_color; + Attribute stroke_width; + Attribute stroke_opacity; + bool overdrawInspector; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const CircleDrawableUBO& drawable [[buffer(8)]], + device const CirclePaintParamsUBO& params [[buffer(9)]], + device const CircleEvaluatedPropsUBO& props [[buffer(10)]], + device const CircleInterpolateUBO& interp [[buffer(11)]], + device const CirclePermutationUBO& permutation [[buffer(12)]], + device const ExpressionInputsUBO& expr [[buffer(13)]]) { + + const auto color = colorFor(permutation.color, props.color, vertx.color, expr); + const auto radius = valueFor(permutation.radius, props.radius, vertx.radius, interp.radius_t, expr); + const auto blur = valueFor(permutation.blur, props.blur, vertx.blur, interp.blur_t, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); + const auto stroke_color = colorFor(permutation.stroke_color, props.stroke_color, vertx.stroke_color, interp.stroke_color_t, expr); + const auto stroke_width = valueFor(permutation.stroke_width, props.stroke_width, vertx.stroke_width, interp.stroke_width_t, expr); + const auto stroke_opacity = valueFor(permutation.stroke_opacity, props.stroke_opacity, vertx.stroke_opacity, interp.stroke_opacity_t, expr); + + // unencode the extrusion vector that we snuck into the a_pos vector + const float2 extrude = fmod(float2(vertx.position), 2.0) * 2.0 - 1.0; + const float2 scaled_extrude = extrude * drawable.extrude_scale; + + // multiply a_pos by 0.5, since we had it * 2 in order to sneak in extrusion data + const float2 circle_center = floor(float2(vertx.position) * 0.5); + + float4 position; + if (props.pitch_with_map) { + float2 corner_position = circle_center; + if (props.scale_with_map) { + corner_position += scaled_extrude * (radius + stroke_width); + } else { + // Pitching the circle with the map effectively scales it with the map + // To counteract the effect for pitch-scale: viewport, we rescale the + // whole circle based on the pitch scaling effect at its central point + float4 projected_center = drawable.matrix * float4(circle_center, 0, 1); + corner_position += scaled_extrude * (radius + stroke_width) * + (projected_center.w / params.camera_to_center_distance); + } + + position = drawable.matrix * float4(corner_position, 0, 1); + } else { + position = drawable.matrix * float4(circle_center, 0, 1); + + const float factor = props.scale_with_map ? params.camera_to_center_distance : position.w; + position.xy += scaled_extrude * (radius + stroke_width) * factor; + } + + // This is a minimum blur distance that serves as a faux-antialiasing for + // the circle. since blur is a ratio of the circle's size and the intent is + // to keep the blur at roughly 1px, the two are inversely related. + const half antialiasblur = 1.0 / params.device_pixel_ratio / (radius + stroke_width); + + return { + .position = position, + .color = color, + .radius = radius, + .blur = half(blur), + .opacity = half(opacity), + .stroke_color = stroke_color, + .stroke_width = stroke_width, + .stroke_opacity = half(stroke_opacity), + .extrude = extrude, + .antialiasblur = antialiasblur, + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const CirclePaintParamsUBO& params [[buffer(9)]], + device const CircleEvaluatedPropsUBO& props [[buffer(10)]], + device const CirclePermutationUBO& permutation [[buffer(12)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + + const float extrude_length = length(in.extrude); + const float antialiased_blur = -max(in.blur, in.antialiasblur); + const float opacity_t = smoothstep(0.0, antialiased_blur, extrude_length - 1.0); + const float color_t = (in.stroke_width < 0.01) ? 0.0 : + smoothstep(antialiased_blur, 0.0, extrude_length - in.radius / (in.radius + in.stroke_width)); + + return half4(opacity_t * mix(in.color * in.opacity, in.stroke_color * in.stroke_opacity, color_t)); +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/common.hpp b/include/mbgl/shaders/mtl/common.hpp new file mode 100644 index 000000000..3fa44adf4 --- /dev/null +++ b/include/mbgl/shaders/mtl/common.hpp @@ -0,0 +1,207 @@ +#pragma once + +#define MLN_MTL_UNIFORM_BLOCK(idx, vert, frag, struc) \ + { idx, vert, frag, sizeof(struc), MLN_STRINGIZE(struc) } + +namespace mbgl { +namespace shaders { + +constexpr auto prelude = R"( +#include +using namespace metal; + +template +inline auto mod(T1 x, T2 y) -> decltype(x - y * floor(x/y)) { + return x - y * metal::floor(x/y); +} + +enum class AttributeSource : int32_t { + Constant, + PerVertex, + Computed, +}; + +struct Expression {}; + +struct Attribute { + AttributeSource source; + Expression expression; +}; + +struct alignas(16) ExpressionInputsUBO { + // These can use uint64_t in later versions of Metal + /* 0 */ uint32_t time_lo; // Current scene time (nanoseconds) + /* 4 */ uint32_t time_hi; + /* 8 */ uint32_t frame_lo; // Current frame count + /* 12 */ uint32_t frame_hi; + /* 16 */ float zoom; // Current zoom level + /* 20 */ float pad1, pad2, pad3; + /* 32 */ +}; + +// Unpack a pair of values that have been packed into a single float. +// The packed values are assumed to be 8-bit unsigned integers, and are +// packed like so: packedValue = floor(input[0]) * 256 + input[1], +float2 unpack_float(const float packedValue) { + const int packedIntValue = int(packedValue); + const int v0 = packedIntValue / 256; + return float2(v0, packedIntValue - v0 * 256); +} +float2 unpack_opacity(const float packedOpacity) { + return float2(float(int(packedOpacity) / 2) / 127.0, fmod(packedOpacity, 2.0)); +} +// To minimize the number of attributes needed, we encode a 4-component +// color into a pair of floats (i.e. a vec2) as follows: +// [ floor(color.r * 255) * 256 + color.g * 255, floor(color.b * 255) * 256 + color.g * 255 ] +float4 decode_color(const float2 encoded) { + return float4(unpack_float(encoded[0]) / 255, unpack_float(encoded[1]) / 255); +} +// Unpack a pair of paint values and interpolate between them. +float unpack_mix_float(const float2 packedValue, const float t) { + return mix(packedValue[0], packedValue[1], t); +} +// Unpack a pair of paint values and interpolate between them. +float4 unpack_mix_color(const float4 packedColors, const float t) { + return mix(decode_color(float2(packedColors[0], packedColors[1])), + decode_color(float2(packedColors[2], packedColors[3])), t); +} + +float valueFor(device const Attribute& attrib, + device const float& constValue, + thread const float2& vertexValue, + device const float& t, + device const ExpressionInputsUBO&) { + switch (attrib.source) { + case AttributeSource::PerVertex: return unpack_mix_float(vertexValue, t); + case AttributeSource::Computed: // TODO + default: + case AttributeSource::Constant: return constValue; + } +} +// single packed color +float4 colorFor(device const Attribute& attrib, + device const float4& constValue, + thread const float2& vertexValue, + device const ExpressionInputsUBO&) { + switch (attrib.source) { + case AttributeSource::PerVertex: return decode_color(float2(vertexValue[0], vertexValue[1])); + case AttributeSource::Computed: // TODO + default: + case AttributeSource::Constant: return constValue; + } +} +// interpolated packed colors +float4 colorFor(device const Attribute& attrib, + device const float4& constValue, + thread const float4& vertexValue, + device const float& t, + device const ExpressionInputsUBO&) { + switch (attrib.source) { + case AttributeSource::PerVertex: return unpack_mix_color(vertexValue, t); + case AttributeSource::Computed: // TODO + default: + case AttributeSource::Constant: return constValue; + } +} + +// The maximum allowed miter limit is 2.0 at the moment. the extrude normal is stored +// in a byte (-128..127). We scale regular normals up to length 63, but there are also +// "special" normals that have a bigger length (of up to 126 in this case). +constant float LINE_NORMAL_SCALE = 1.0 / (127 / 2); + +// The attribute conveying progress along a line is scaled to [0, 2^15). +constant float MAX_LINE_DISTANCE = 32767.0; + +struct alignas(16) LineUBO { + float4x4 matrix; + float2 units_to_pixels; + float ratio; + float device_pixel_ratio; +}; + +struct alignas(16) LineGradientUBO { + float4x4 matrix; + float2 units_to_pixels; + float ratio; + float device_pixel_ratio; +}; + +struct alignas(16) LinePropertiesUBO { + float4 color; + float blur; + float opacity; + float gapwidth; + float offset; + float width; + float pad1, pad2, pad3; +}; + +struct alignas(16) LineGradientPropertiesUBO { + float blur; + float opacity; + float gapwidth; + float offset; + float width; + float pad1, pad2, pad3; +}; + +struct alignas(16) LinePermutationUBO { + Attribute color; + Attribute blur; + Attribute opacity; + Attribute gapwidth; + Attribute offset; + Attribute width; + Attribute floorwidth; + Attribute pattern_from; + Attribute pattern_to; + bool overdrawInspector; + uint8_t pad1, pad2, pad3; + float pad4; +}; + +struct alignas(16) LineInterpolationUBO { + float color_t; + float blur_t; + float opacity_t; + float gapwidth_t; + float offset_t; + float width_t; + float pad1, pad2; +}; + +struct alignas(16) LineGradientInterpolationUBO { + float blur_t; + float opacity_t; + float gapwidth_t; + float offset_t; + float width_t; + float pad1, pad2, pad3; +}; + +// interpolated packed pattern +float4 patternFor(device const Attribute& attrib, + device const float4& constValue, + thread const ushort4& vertexValue, + device const float& , + device const ExpressionInputsUBO&) { + switch (attrib.source) { + case AttributeSource::PerVertex: return float4(vertexValue); + case AttributeSource::Computed: // TODO + default: + case AttributeSource::Constant: return constValue; + } +} + +// unpack pattern position +inline float2 get_pattern_pos(const float2 pixel_coord_upper, const float2 pixel_coord_lower, + const float2 pattern_size, const float tile_units_to_pixels, const float2 pos) { + + float2 offset = mod(mod(mod(pixel_coord_upper, pattern_size) * 256.0, pattern_size) * 256.0 + pixel_coord_lower, pattern_size); + return (tile_units_to_pixels * pos + offset) / pattern_size; +} + +)"; + +} +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/fill.hpp b/include/mbgl/shaders/mtl/fill.hpp new file mode 100644 index 000000000..dc542f841 --- /dev/null +++ b/include/mbgl/shaders/mtl/fill.hpp @@ -0,0 +1,476 @@ +#pragma once + +#include +#include +#include +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource { + static constexpr auto name = "FillShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos"}, + {1, gfx::AttributeDataType::Float2, 1, "a_color"}, + {2, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(3, true, false, FillDrawableUBO), + MLN_MTL_UNIFORM_BLOCK(4, true, true, FillEvaluatedPropsUBO), + MLN_MTL_UNIFORM_BLOCK(5, true, false, FillInterpolateUBO), + MLN_MTL_UNIFORM_BLOCK(6, true, true, FillPermutationUBO), + MLN_MTL_UNIFORM_BLOCK(7, true, false, ExpressionInputsUBO), + }; + static constexpr TextureInfo textures[] = {}; + + static constexpr auto source = R"( + +struct VertexStage { + short2 position [[attribute(0)]]; + float2 color [[attribute(1)]]; + float2 opacity [[attribute(2)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float4 color; + half opacity; +}; + +struct alignas(16) FillDrawableUBO { + float4x4 matrix; +}; + +struct alignas(16) FillEvaluatedPropsUBO { + float4 color; + float opacity; +}; + +struct alignas(16) FillInterpolateUBO { + float color_t; + float opacity_t; +}; + +struct alignas(16) FillPermutationUBO { + Attribute color; + Attribute opacity; + bool overdrawInspector; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const FillDrawableUBO& drawable [[buffer(3)]], + device const FillEvaluatedPropsUBO& props [[buffer(4)]], + device const FillInterpolateUBO& interp [[buffer(5)]], + device const FillPermutationUBO& permutation [[buffer(6)]], + device const ExpressionInputsUBO& expr [[buffer(7)]]) { + + const auto color = colorFor(permutation.color, props.color, vertx.color, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); + + float4 position = drawable.matrix * float4(float2(vertx.position), 0.0f, 1.0f); + + return { + .position = position, + .color = color, + .opacity = half(opacity), + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const FillEvaluatedPropsUBO& props [[buffer(4)]], + device const FillPermutationUBO& permutation [[buffer(6)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + + return half4(in.color * in.opacity); +} +)"; +}; + +template <> +struct ShaderSource { + static constexpr auto name = "FillOutlineShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos"}, + {1, gfx::AttributeDataType::Float2, 1, "a_outline_color"}, + {2, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(3, true, false, FillOutlineDrawableUBO), + MLN_MTL_UNIFORM_BLOCK(4, true, true, FillOutlineEvaluatedPropsUBO), + MLN_MTL_UNIFORM_BLOCK(5, true, false, FillOutlineInterpolateUBO), + MLN_MTL_UNIFORM_BLOCK(6, true, true, FillOutlinePermutationUBO), + MLN_MTL_UNIFORM_BLOCK(7, true, false, ExpressionInputsUBO), + }; + static constexpr TextureInfo textures[] = {}; + + static constexpr auto source = R"( + +struct VertexStage { + short2 position [[attribute(0)]]; + float2 outline_color [[attribute(1)]]; + float2 opacity [[attribute(2)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float4 outline_color; + float2 pos; + half opacity; +}; + +struct alignas(16) FillOutlineDrawableUBO { + float4x4 matrix; + float2 world; +}; + +struct alignas(16) FillOutlineEvaluatedPropsUBO { + float4 outline_color; + float opacity; +}; + +struct alignas(16) FillOutlineInterpolateUBO { + float outline_color_t; + float opacity_t; +}; + +struct alignas(16) FillOutlinePermutationUBO { + Attribute outline_color; + Attribute opacity; + bool overdrawInspector; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const FillOutlineDrawableUBO& drawable [[buffer(3)]], + device const FillOutlineEvaluatedPropsUBO& props [[buffer(4)]], + device const FillOutlineInterpolateUBO& interp [[buffer(5)]], + device const FillOutlinePermutationUBO& permutation [[buffer(6)]], + device const ExpressionInputsUBO& expr [[buffer(7)]]) { + + const auto outline_color = colorFor(permutation.outline_color, props.outline_color, vertx.outline_color, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); + + float4 position = drawable.matrix * float4(float2(vertx.position), 0.0f, 1.0f); + float2 v_pos = (position.xy / position.w + 1.0) / 2.0 * drawable.world; + + return { + .position = position, + .outline_color = outline_color, + .pos = v_pos, + .opacity = half(opacity), + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const FillOutlineEvaluatedPropsUBO& props [[buffer(4)]], + device const FillOutlinePermutationUBO& permutation [[buffer(6)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + +// TODO: Cause metal line primitive only support draw 1 pixel width line +// use alpha to provide edge antialiased is no point +// Should triangate the lines into triangles to support thick line and edge antialiased. +// float dist = length(in.pos - in.position.xy); +// float alpha = 1.0 - smoothstep(0.0, 1.0, dist); + + return half4(in.outline_color * in.opacity); +} +)"; +}; + +template <> +struct ShaderSource { + static constexpr auto name = "FillPatternShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos"}, + {1, gfx::AttributeDataType::UShort4, 1, "a_pattern_from"}, + {2, gfx::AttributeDataType::UShort4, 1, "a_pattern_to"}, + {3, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(4, true, true, FillPatternDrawableUBO), + MLN_MTL_UNIFORM_BLOCK(5, true, false, FillPatternTilePropsUBO), + MLN_MTL_UNIFORM_BLOCK(6, true, true, FillPatternEvaluatedPropsUBO), + MLN_MTL_UNIFORM_BLOCK(7, true, false, FillPatternInterpolateUBO), + MLN_MTL_UNIFORM_BLOCK(8, true, true, FillPatternPermutationUBO), + MLN_MTL_UNIFORM_BLOCK(9, true, false, ExpressionInputsUBO), + }; + + static constexpr TextureInfo textures[] = { + {0, "u_image"}, + }; + + static constexpr auto source = R"( + +struct VertexStage { + short2 position [[attribute(0)]]; + ushort4 pattern_from [[attribute(1)]]; + ushort4 pattern_to [[attribute(2)]]; + float2 opacity [[attribute(3)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float4 pattern_from; + float4 pattern_to; + float2 v_pos_a; + float2 v_pos_b; + half opacity; +}; + +struct alignas(16) FillPatternDrawableUBO { + float4x4 matrix; + float4 scale; + float2 pixel_coord_upper; + float2 pixel_coord_lower; + float2 texsize; +}; + +struct alignas(16) FillPatternEvaluatedPropsUBO { + float opacity; + float fade; +}; + +struct alignas(16) FillPatternTilePropsUBO { + float4 pattern_from; + float4 pattern_to; +}; + +struct alignas(16) FillPatternInterpolateUBO { + float pattern_from_t; + float pattern_to_t; + float opacity_t; +}; + +struct alignas(16) FillPatternPermutationUBO { + Attribute pattern_from; + Attribute pattern_to; + Attribute opacity; + bool overdrawInspector; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const FillPatternDrawableUBO& drawable [[buffer(4)]], + device const FillPatternTilePropsUBO& tileProps [[buffer(5)]], + device const FillPatternEvaluatedPropsUBO& props [[buffer(6)]], + device const FillPatternInterpolateUBO& interp [[buffer(7)]], + device const FillPatternPermutationUBO& permutation [[buffer(8)]], + device const ExpressionInputsUBO& expr [[buffer(9)]]) { + + const auto pattern_from = patternFor(permutation.pattern_from, tileProps.pattern_from, vertx.pattern_from, interp.pattern_from_t, expr); + const auto pattern_to = patternFor(permutation.pattern_to, tileProps.pattern_to, vertx.pattern_to, interp.pattern_to_t, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); + + float2 pattern_tl_a = pattern_from.xy; + float2 pattern_br_a = pattern_from.zw; + float2 pattern_tl_b = pattern_to.xy; + float2 pattern_br_b = pattern_to.zw; + + float pixelRatio = drawable.scale.x; + float tileZoomRatio = drawable.scale.y; + float fromScale = drawable.scale.z; + float toScale = drawable.scale.w; + + float2 display_size_a = float2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); + float2 display_size_b = float2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); + float2 postion = float2(vertx.position); + + return { + .position = drawable.matrix * float4(postion, 0, 1), + .pattern_from = pattern_from, + .pattern_to = pattern_to, + .v_pos_a = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, postion), + .v_pos_b = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, toScale * display_size_b, tileZoomRatio, postion), + .opacity = half(opacity), + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const FillPatternDrawableUBO& drawable [[buffer(4)]], + device const FillPatternEvaluatedPropsUBO& props [[buffer(6)]], + device const FillPatternPermutationUBO& permutation [[buffer(8)]], + texture2d image0 [[texture(0)]], + sampler image0_sampler [[sampler(0)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + + float2 pattern_tl_a = in.pattern_from.xy; + float2 pattern_br_a = in.pattern_from.zw; + float2 pattern_tl_b = in.pattern_to.xy; + float2 pattern_br_b = in.pattern_to.zw; + + float2 imagecoord = mod(in.v_pos_a, 1.0); + float2 pos = mix(pattern_tl_a / drawable.texsize, pattern_br_a / drawable.texsize, imagecoord); + float4 color1 = image0.sample(image0_sampler, pos); + + float2 imagecoord_b = mod(in.v_pos_b, 1.0); + float2 pos2 = mix(pattern_tl_b / drawable.texsize, pattern_br_b / drawable.texsize, imagecoord_b); + float4 color2 = image0.sample(image0_sampler, pos2); + + return half4(mix(color1, color2, props.fade) * in.opacity); +} +)"; +}; + +template <> +struct ShaderSource { + static constexpr auto name = "FillOutlinePatternShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos"}, + {1, gfx::AttributeDataType::UShort4, 1, "a_pattern_from"}, + {2, gfx::AttributeDataType::UShort4, 1, "a_pattern_to"}, + {3, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(4, true, true, FillOutlinePatternDrawableUBO), + MLN_MTL_UNIFORM_BLOCK(5, true, false, FillOutlinePatternTilePropsUBO), + MLN_MTL_UNIFORM_BLOCK(6, true, true, FillOutlinePatternEvaluatedPropsUBO), + MLN_MTL_UNIFORM_BLOCK(7, true, false, FillOutlinePatternInterpolateUBO), + MLN_MTL_UNIFORM_BLOCK(8, true, true, FillOutlinePatternPermutationUBO), + MLN_MTL_UNIFORM_BLOCK(9, true, false, ExpressionInputsUBO), + }; + + static constexpr TextureInfo textures[] = { + {0, "u_image"}, + }; + + static constexpr auto source = R"( + +struct VertexStage { + short2 position [[attribute(0)]]; + ushort4 pattern_from [[attribute(1)]]; + ushort4 pattern_to [[attribute(2)]]; + float2 opacity [[attribute(3)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float2 v_pos_a; + float2 v_pos_b; + float4 pattern_from; + float4 pattern_to; + float2 v_pos; + half opacity; +}; + +struct alignas(16) FillOutlinePatternDrawableUBO { + float4x4 matrix; + float4 scale; + float2 world; + float2 pixel_coord_upper; + float2 pixel_coord_lower; + float2 texsize; +}; + +struct alignas(16) FillOutlinePatternEvaluatedPropsUBO { + float opacity; + float fade; +}; + +struct alignas(16) FillOutlinePatternTilePropsUBO { + float4 pattern_from; + float4 pattern_to; +}; + +struct alignas(16) FillOutlinePatternInterpolateUBO { + float pattern_from_t; + float pattern_to_t; + float opacity_t; +}; + +struct alignas(16) FillOutlinePatternPermutationUBO { + Attribute pattern_from; + Attribute pattern_to; + Attribute opacity; + bool overdrawInspector; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const FillOutlinePatternDrawableUBO& drawable [[buffer(4)]], + device const FillOutlinePatternTilePropsUBO& tileProps [[buffer(5)]], + device const FillOutlinePatternEvaluatedPropsUBO& props [[buffer(6)]], + device const FillOutlinePatternInterpolateUBO& interp [[buffer(7)]], + device const FillOutlinePatternPermutationUBO& permutation [[buffer(8)]], + device const ExpressionInputsUBO& expr [[buffer(9)]]) { + + const auto pattern_from = patternFor(permutation.pattern_from, tileProps.pattern_from, vertx.pattern_from, interp.pattern_from_t, expr); + const auto pattern_to = patternFor(permutation.pattern_to, tileProps.pattern_to, vertx.pattern_to, interp.pattern_to_t, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); + + float2 pattern_tl_a = pattern_from.xy; + float2 pattern_br_a = pattern_from.zw; + float2 pattern_tl_b = pattern_to.xy; + float2 pattern_br_b = pattern_to.zw; + + float pixelRatio = drawable.scale.x; + float tileZoomRatio = drawable.scale.y; + float fromScale = drawable.scale.z; + float toScale = drawable.scale.w; + + float2 display_size_a = float2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio); + float2 display_size_b = float2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio); + float2 pos2 = float2(vertx.position); + float4 position = drawable.matrix * float4(pos2, 0, 1); + + return { + .position = position, + .pattern_from = pattern_from, + .pattern_to = pattern_to, + .v_pos_a = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, pos2), + .v_pos_b = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, toScale * display_size_b, tileZoomRatio, pos2), + .v_pos = (position.xy / position.w + 1.0) / 2.0 * drawable.world, + .opacity = half(opacity), + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const FillOutlinePatternDrawableUBO& drawable [[buffer(4)]], + device const FillOutlinePatternEvaluatedPropsUBO& props [[buffer(6)]], + device const FillOutlinePatternPermutationUBO& permutation [[buffer(8)]], + texture2d image0 [[texture(0)]], + sampler image0_sampler [[sampler(0)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + + float2 pattern_tl_a = in.pattern_from.xy; + float2 pattern_br_a = in.pattern_from.zw; + float2 pattern_tl_b = in.pattern_to.xy; + float2 pattern_br_b = in.pattern_to.zw; + + float2 imagecoord = mod(in.v_pos_a, 1.0); + float2 pos = mix(pattern_tl_a / drawable.texsize, pattern_br_a / drawable.texsize, imagecoord); + float4 color1 = image0.sample(image0_sampler, pos); + + float2 imagecoord_b = mod(in.v_pos_b, 1.0); + float2 pos2 = mix(pattern_tl_b / drawable.texsize, pattern_br_b / drawable.texsize, imagecoord_b); + float4 color2 = image0.sample(image0_sampler, pos2); + + // TODO: Should triangate the lines into triangles to support thick line and edge antialiased. + //float dist = length(in.v_pos - in.position.xy); + //float alpha = 1.0 - smoothstep(0.0, 1.0, dist); + + return half4(mix(color1, color2, props.fade) * in.opacity); +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/line.hpp b/include/mbgl/shaders/mtl/line.hpp new file mode 100644 index 000000000..0ed25ee19 --- /dev/null +++ b/include/mbgl/shaders/mtl/line.hpp @@ -0,0 +1,141 @@ +#pragma once + +#include +#include +#include +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource { + static constexpr auto name = "LineShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos_normal"}, + {1, gfx::AttributeDataType::UByte4, 1, "a_data"}, + {2, gfx::AttributeDataType::Float4, 1, "a_color"}, + {3, gfx::AttributeDataType::Float2, 1, "a_blur"}, + {4, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + {5, gfx::AttributeDataType::Float2, 1, "a_gapwidth"}, + {6, gfx::AttributeDataType::Float2, 1, "a_offset"}, + {7, gfx::AttributeDataType::Float2, 1, "a_width"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(8, true, true, LineUBO), + MLN_MTL_UNIFORM_BLOCK(9, true, false, LinePropertiesUBO), + MLN_MTL_UNIFORM_BLOCK(10, true, false, LineInterpolationUBO), + MLN_MTL_UNIFORM_BLOCK(11, true, true, LinePermutationUBO), + MLN_MTL_UNIFORM_BLOCK(12, true, false, ExpressionInputsUBO), + }; + static constexpr TextureInfo textures[] = {}; + + static constexpr auto source = R"( + +struct VertexStage { + short2 pos_normal [[attribute(0)]]; + uchar4 data [[attribute(1)]]; + float4 color [[attribute(2)]]; + float2 blur [[attribute(3)]]; + float2 opacity [[attribute(4)]]; + float2 gapwidth [[attribute(5)]]; + float2 offset [[attribute(6)]]; + float2 width [[attribute(7)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float2 width2; + float2 normal; + float gamma_scale; + float4 color; + float blur; + float opacity; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const LineUBO& line [[buffer(8)]], + device const LinePropertiesUBO& props [[buffer(9)]], + device const LineInterpolationUBO& interp [[buffer(10)]], + device const LinePermutationUBO& permutation [[buffer(11)]], + device const ExpressionInputsUBO& expr [[buffer(12)]]) { + + const auto color = colorFor(permutation.color, props.color, vertx.color, interp.color_t, expr); + const auto blur = valueFor(permutation.blur, props.blur, vertx.blur, interp.blur_t, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); + const auto gapwidth = valueFor(permutation.gapwidth, props.gapwidth, vertx.gapwidth, interp.gapwidth_t, expr) / 2; + const auto offset = valueFor(permutation.offset, props.offset, vertx.offset, interp.offset_t, expr) * -1; + const auto width = valueFor(permutation.width, props.width, vertx.width, interp.width_t, expr); + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + const float ANTIALIASING = 1.0 / line.device_pixel_ratio / 2.0; + + const float2 a_extrude = float2(vertx.data.xy) - 128.0; + const float a_direction = fmod(float(vertx.data.z), 4.0) - 1.0; + const float2 pos = floor(float2(vertx.pos_normal) * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + const float2 normal = float2(vertx.pos_normal) - 2.0 * pos; + const float2 v_normal = float2(normal.x, normal.y * 2.0 - 1.0); + + const float halfwidth = width / 2.0; + const float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + const float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width of this vertex. + const float2 dist = outset * a_extrude * LINE_NORMAL_SCALE; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + const float u = 0.5 * a_direction; + const float t = 1.0 - abs(u); + const float2 offset2 = offset * a_extrude * LINE_NORMAL_SCALE * v_normal.y * float2x2(t, -u, u, t); + + const float4 projected_extrude = line.matrix * float4(dist / line.ratio, 0.0, 0.0); + const float4 position = line.matrix * float4(pos + offset2 / line.ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + const float extrude_length_without_perspective = length(dist); + const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels); + + return { + .position = position, + .width2 = float2(outset, inset), + .normal = v_normal, + .gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective, + .color = color, + .blur = blur, + .opacity = opacity, + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const LineUBO& line [[buffer(8)]], + device const LinePermutationUBO& permutation [[buffer(11)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + + // Calculate the distance of the pixel from the line in pixels. + const float dist = length(in.normal) * in.width2.x; + + // Calculate the antialiasing fade factor. This is either when fading in the + // line in case of an offset line (v_width2.y) or when fading out (v_width2.x) + const float blur2 = (in.blur + 1.0 / line.device_pixel_ratio) * in.gamma_scale; + const float alpha = clamp(min(dist - (in.width2.y - blur2), in.width2.x - dist) / blur2, 0.0, 1.0); + + return half4(in.color * (alpha * in.opacity)); +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/line_gradient.hpp b/include/mbgl/shaders/mtl/line_gradient.hpp new file mode 100644 index 000000000..6d2b90416 --- /dev/null +++ b/include/mbgl/shaders/mtl/line_gradient.hpp @@ -0,0 +1,148 @@ +#pragma once + +#include +#include +#include +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource { + static constexpr auto name = "LineGradientShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos_normal"}, + {1, gfx::AttributeDataType::UByte4, 1, "a_data"}, + {2, gfx::AttributeDataType::Float2, 1, "a_blur"}, + {3, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + {4, gfx::AttributeDataType::Float2, 1, "a_gapwidth"}, + {5, gfx::AttributeDataType::Float2, 1, "a_offset"}, + {6, gfx::AttributeDataType::Float2, 1, "a_width"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(7, true, true, LineGradientUBO), + MLN_MTL_UNIFORM_BLOCK(8, true, false, LineGradientPropertiesUBO), + MLN_MTL_UNIFORM_BLOCK(9, true, false, LineGradientInterpolationUBO), + MLN_MTL_UNIFORM_BLOCK(10, true, true, LinePermutationUBO), + MLN_MTL_UNIFORM_BLOCK(11, true, false, ExpressionInputsUBO), + }; + static constexpr TextureInfo textures[] = { + {0, "u_image"}, + }; + + static constexpr auto source = R"( +struct VertexStage { + short2 pos_normal [[attribute(0)]]; + uchar4 data [[attribute(1)]]; + float2 blur [[attribute(3)]]; + float2 opacity [[attribute(4)]]; + float2 gapwidth [[attribute(5)]]; + float2 offset [[attribute(6)]]; + float2 width [[attribute(7)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float2 width2; + float2 gapwidth; + float2 normal; + float gamma_scale; + float blur; + float opacity; + float lineprogress; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const LineGradientUBO& line [[buffer(7)]], + device const LineGradientPropertiesUBO& props [[buffer(8)]], + device const LineGradientInterpolationUBO& interp [[buffer(9)]], + device const LinePermutationUBO& permutation [[buffer(10)]], + device const ExpressionInputsUBO& expr [[buffer(11)]]) { + + const auto blur = valueFor(permutation.blur, props.blur, vertx.blur, interp.blur_t, expr); + const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); + const auto gapwidth = valueFor(permutation.gapwidth, props.gapwidth, vertx.gapwidth, interp.gapwidth_t, expr) / 2; + const auto offset = valueFor(permutation.offset, props.offset, vertx.offset, interp.offset_t, expr) * -1; + const auto width = valueFor(permutation.width, props.width, vertx.width, interp.width_t, expr); + + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. + const float ANTIALIASING = 1.0 / line.device_pixel_ratio / 2.0; + + const float2 a_extrude = float2(vertx.data.xy) - 128.0; + const float a_direction = fmod(float(vertx.data.z), 4.0) - 1.0; + const v_lineprogress = (floor(float(a_data.z) / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE; + const float2 pos = floor(float2(vertx.pos_normal) * 0.5); + + // x is 1 if it's a round cap, 0 otherwise + // y is 1 if the normal points up, and -1 if it points down + // We store these in the least significant bit of a_pos_normal + const float2 normal = float2(vertx.pos_normal) - 2.0 * pos; + const float2 v_normal = float2(normal.x, normal.y * 2.0 - 1.0); + + const float halfwidth = width / 2.0; + const float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0); + const float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING); + + // Scale the extrusion vector down to a normal and then up by the line width of this vertex. + const float2 dist = outset * a_extrude * scale; + + // Calculate the offset when drawing a line that is to the side of the actual line. + // We do this by creating a vector that points towards the extrude, but rotate + // it when we're drawing round end points (a_direction = -1 or 1) since their + // extrude vector points in another direction. + const float u = 0.5 * a_direction; + const float t = 1.0 - abs(u); + const float2 offset2 = offset * a_extrude * scale * v_normal.y * float2x2(t, -u, u, t); + + const float4 projected_extrude = line.matrix * float4(dist / line.ratio, 0.0, 0.0); + const float4 position = line.matrix * float4(pos + offset2 / line.ratio, 0.0, 1.0) + projected_extrude; + + // calculate how much the perspective view squishes or stretches the extrude + const float extrude_length_without_perspective = length(dist); + const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels); + + return { + .position = position, + .width2 = float2(outset, inset), + .gapwidth = gapwidth, + .normal = v_normal, + .gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective, + .blur = blur, + .opacity = opacity, + .lineprogress = v_lineprogress, + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const LineGradientUBO& line [[buffer(7)]], + device const LineGradientPermutationUBO& permutation [[buffer(10)]], + metal::texture2d* gradientTexture [[texture(0)]]) { + if (permutation.overdrawInspector) { + return half4(1.0); + } + + // Calculate the distance of the pixel from the line in pixels. + const float dist = length(in.normal) * in.width2.x; + + // Calculate the antialiasing fade factor. This is either when fading in the + // line in case of an offset line (v_width2.y) or when fading out (v_width2.x) + const float blur2 = (in.blur + 1.0 / line.device_pixel_ratio) * in.gamma_scale; + const float alpha = clamp(min(dist - (in.width2.y - blur2), in.width2.x - dist) / blur2, 0.0, 1.0); + + // For gradient lines, v_lineprogress is the ratio along the entire line, + // scaled to [0, 2^15), and the gradient ramp is stored in a texture. + constexpr sampler sampler2d(coord::normalized, filter::linear); + const vec4 color = gradientTexture ? gradientTexture->sample(sampler, vec2(in.lineprogress, 0.5)) : vec4(1,0,1,1); + + return half4(color * (alpha * in.opacity)); +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/raster.hpp b/include/mbgl/shaders/mtl/raster.hpp new file mode 100644 index 000000000..ca9f6b3a1 --- /dev/null +++ b/include/mbgl/shaders/mtl/raster.hpp @@ -0,0 +1,125 @@ +#pragma once + +#include +#include +#include +#include + +namespace mbgl { +namespace shaders { + +template <> +struct ShaderSource { + static constexpr auto name = "RasterShader"; + static constexpr auto vertexMainFunction = "vertexMain"; + static constexpr auto fragmentMainFunction = "fragmentMain"; + + static constexpr AttributeInfo attributes[] = { + {0, gfx::AttributeDataType::Short2, 1, "a_pos"}, + {1, gfx::AttributeDataType::Short2, 1, "a_texture_pos"}, + }; + static constexpr UniformBlockInfo uniforms[] = { + MLN_MTL_UNIFORM_BLOCK(2, true, true, RasterDrawableUBO), + }; + static constexpr TextureInfo textures[] = { + {0, "u_image0"}, + {1, "u_image1"}, + }; + static constexpr auto source = R"( + +struct VertexStage { + short2 pos [[attribute(0)]]; + short2 texture_pos [[attribute(1)]]; +}; + +struct FragmentStage { + float4 position [[position, invariant]]; + float2 pos0; + float2 pos1; +}; + +struct alignas(16) RasterDrawableUBO { + float4x4 matrix; + float3 spin_weights; + float2 tl_parent; + float scale_parent; + float buffer_scale; + float fade_t; + float opacity; + float brightness_low; + float brightness_high; + float saturation_factor; + float contrast_factor; + bool overdrawInspector; + uint8_t pad1, pad2, pad3; + float pad4; +}; + +FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], + device const RasterDrawableUBO& drawable [[buffer(2)]]) { + + const float4 position = drawable.matrix * float4(float2(vertx.pos), 0, 1); + + // We are using Int16 for texture position coordinates to give us enough precision for + // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer + // as an arbitrarily high number to preserve adequate precision when rendering. + // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates, + // so math for modifying either is consistent. + const float2 pos0 = (((float2(vertx.texture_pos) / 8192.0) - 0.5) / drawable.buffer_scale ) + 0.5; + const float2 pos1 = (pos0 * drawable.scale_parent) + drawable.tl_parent; + + return { + .position = position, + .pos0 = pos0, + .pos1 = pos1, + }; +} + +half4 fragment fragmentMain(FragmentStage in [[stage_in]], + device const RasterDrawableUBO& drawable [[buffer(2)]], + texture2d image0 [[texture(0)]], + texture2d image1 [[texture(1)]], + sampler image0_sampler [[sampler(0)]], + sampler image1_sampler [[sampler(1)]]) { + + if (drawable.overdrawInspector) { + return half4(1.0); + } + + // read and cross-fade colors from the main and parent tiles + float4 color0 = image0.sample(image0_sampler, in.pos0); + float4 color1 = image1.sample(image1_sampler, in.pos1); + if (color0.a > 0.0) { + color0.rgb = color0.rgb / color0.a; + } + if (color1.a > 0.0) { + color1.rgb = color1.rgb / color1.a; + } + float4 color = mix(color0, color1, drawable.fade_t); + color.a *= drawable.opacity; + float3 rgb = color.rgb; + + // spin + rgb = float3( + dot(rgb, drawable.spin_weights.xyz), + dot(rgb, drawable.spin_weights.zxy), + dot(rgb, drawable.spin_weights.yzx)); + + // saturation + float average = (color.r + color.g + color.b) / 3.0; + rgb += (average - rgb) * drawable.saturation_factor; + + // contrast + rgb = (rgb - 0.5) * drawable.contrast_factor + 0.5; + + // brightness + float3 high_vec = float3(drawable.brightness_low, drawable.brightness_low, drawable.brightness_low); + float3 low_vec = float3(drawable.brightness_high, drawable.brightness_high, drawable.brightness_high); + + return half4(half3(mix(high_vec, low_vec, rgb) * color.a), color.a); +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/shader_group.hpp b/include/mbgl/shaders/mtl/shader_group.hpp new file mode 100644 index 000000000..05a402a85 --- /dev/null +++ b/include/mbgl/shaders/mtl/shader_group.hpp @@ -0,0 +1,76 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace mbgl { +namespace mtl { + +template +class ShaderGroup final : public gfx::ShaderGroup { +public: + ShaderGroup(const ProgramParameters& programParameters_) + : gfx::ShaderGroup(), + programParameters(programParameters_) {} + ~ShaderGroup() noexcept override = default; + + gfx::ShaderPtr getOrCreateShader(gfx::Context& gfxContext, + const std::vector& propertiesAsUniforms, + std::string_view /*firstAttribName*/) override { + constexpr auto& name = shaders::ShaderSource::name; + constexpr auto& source = shaders::ShaderSource::source; + constexpr auto& vertMain = shaders::ShaderSource::vertexMainFunction; + constexpr auto& fragMain = shaders::ShaderSource::fragmentMainFunction; + + uint32_t key = 0; + assert(propertiesAsUniforms.size() < 32); + std::unordered_map additionalDefines(propertiesAsUniforms.size()); + for (unsigned int i = 0; i < propertiesAsUniforms.size(); i++) { + if (!propertiesAsUniforms[i].empty()) { + key |= 1U << i; + auto name = std::string("HAS_UNIFORM_u_") + propertiesAsUniforms[i]; + additionalDefines.insert(std::make_pair(std::move(name), "1")); + } + } + + const std::string shaderName = std::string(name); // + "#" + std::to_string(key); + const auto shaderSource = std::string(shaders::prelude) + source; + + auto shader = get(shaderName); + if (!shader) { + auto& context = static_cast(gfxContext); + shader = context.createProgram( + shaderName, shaderSource, vertMain, fragMain, programParameters, additionalDefines); + assert(shader); + if (!shader || !registerShader(shader, shaderName)) { + assert(false); + throw std::runtime_error("Failed to register " + shaderName + " with shader group!"); + } + + using ShaderClass = shaders::ShaderSource; + for (const auto& attrib : ShaderClass::attributes) { + shader->initAttribute(attrib); + } + for (const auto& uniform : ShaderClass::uniforms) { + shader->initUniformBlock(uniform); + } + for (const auto& texture : ShaderClass::textures) { + shader->initTexture(texture); + } + } + return shader; + } + +private: + ProgramParameters programParameters; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/shaders/mtl/shader_program.hpp b/include/mbgl/shaders/mtl/shader_program.hpp new file mode 100644 index 000000000..656b7ead3 --- /dev/null +++ b/include/mbgl/shaders/mtl/shader_program.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace mbgl { +namespace shaders { +struct AttributeInfo { + std::size_t index; + gfx::AttributeDataType dataType; + std::size_t count; + std::string_view name; +}; +struct UniformBlockInfo { + std::size_t index; + bool vertex; + bool fragment; + std::size_t size; + std::string_view name; +}; +struct TextureInfo { + std::size_t index; + std::string_view name; +}; +} // namespace shaders +namespace mtl { +class RenderableResource; +class RendererBackend; +class ShaderProgram; +using UniqueShaderProgram = std::unique_ptr; + +class ShaderProgram final : public gfx::ShaderProgramBase { +public: + ShaderProgram(std::string name, + RendererBackend& backend, + MTLFunctionPtr vertexFunction, + MTLFunctionPtr fragmentFunction); + ~ShaderProgram() noexcept override = default; + + static constexpr std::string_view Name{"GenericMTLShader"}; + const std::string_view typeName() const noexcept override { return Name; } + + MTLRenderPipelineStatePtr getRenderPipelineState(const gfx::RenderPassDescriptor&, + const MTLVertexDescriptorPtr&, + const gfx::ColorMode& colorMode) const; + + std::optional getSamplerLocation(std::string_view name) const override; + + const gfx::VertexAttributeArray& getVertexAttributes() const override { return vertexAttributes; } + gfx::VertexAttributeArray& mutableVertexAttributes() override { return vertexAttributes; } + + const gfx::UniformBlockArray& getUniformBlocks() const override { return uniformBlocks; } + gfx::UniformBlockArray& mutableUniformBlocks() override { return uniformBlocks; } + + void initAttribute(const shaders::AttributeInfo&); + void initUniformBlock(const shaders::UniformBlockInfo&); + void initTexture(const shaders::TextureInfo&); + +protected: + std::string shaderName; + RendererBackend& backend; + MTLFunctionPtr vertexFunction; + MTLFunctionPtr fragmentFunction; + UniformBlockArray uniformBlocks; + VertexAttributeArray vertexAttributes; + std::vector textureBindings; +}; + +} // namespace mtl +} // namespace mbgl diff --git a/include/mbgl/shaders/raster_layer_ubo.hpp b/include/mbgl/shaders/raster_layer_ubo.hpp new file mode 100644 index 000000000..51da7c006 --- /dev/null +++ b/include/mbgl/shaders/raster_layer_ubo.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include + +namespace mbgl { +namespace shaders { + +struct alignas(16) RasterDrawableUBO { + std::array matrix; + std::array spin_weights; + std::array tl_parent; + float scale_parent; + float buffer_scale; + float fade_t; + float opacity; + float brightness_low; + float brightness_high; + float saturation_factor; + float contrast_factor; + bool overdrawInspector; + uint8_t pad1, pad2, pad3; + float pad4; +}; +static_assert(sizeof(RasterDrawableUBO) == 128); +static_assert(sizeof(RasterDrawableUBO) % 16 == 0); + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/shader_manifest.hpp b/include/mbgl/shaders/shader_manifest.hpp index 26baa99fb..381ba6a00 100644 --- a/include/mbgl/shaders/shader_manifest.hpp +++ b/include/mbgl/shaders/shader_manifest.hpp @@ -2,7 +2,7 @@ #pragma once #include -#ifdef MBGL_RENDER_BACKEND_OPENGL +#if !MLN_RENDER_BACKEND_METAL #include #include #include diff --git a/include/mbgl/util/convert.hpp b/include/mbgl/util/convert.hpp index 5e79b6565..8bda38143 100644 --- a/include/mbgl/util/convert.hpp +++ b/include/mbgl/util/convert.hpp @@ -1,3 +1,5 @@ +#pragma once + #include #include diff --git a/platform/BUILD.bazel b/platform/BUILD.bazel index fe42bd3cd..a467439a2 100644 --- a/platform/BUILD.bazel +++ b/platform/BUILD.bazel @@ -10,7 +10,12 @@ objc_library( "//platform/ios:ios_private_hdrs", "//platform/ios:ios_public_hdrs", "//platform/ios:ios_sdk_hdrs", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": [ + "//platform/darwin:darwin_objcpp_opengl_srcs", + ], + }), copts = CPP_FLAGS + MAPLIBRE_FLAGS + [ "-fcxx-modules", "-fmodules", @@ -28,10 +33,16 @@ objc_library( "CoreImage", "CoreGraphics", "CoreLocation", - "GLKit", - "OpenGLES", "QuartzCore", - ], + ] + select({ + "//:metal_renderer": [ + "MetalKit" + ], + "//conditions:default": [ + "OpenGLES", + "GLKit" + ], + }), deps = [ ":objc-headers", "//:mbgl-core", @@ -110,7 +121,12 @@ objc_library( "//platform/darwin:darwin_objc_hdrs", "//platform/darwin:generated_style_public_hdrs", "//platform/ios:ios_sdk_hdrs", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": [ + "//platform/darwin:darwin_objc_opengl_hdrs", + ], + }), data = ["//platform/ios:resources"], module_name = "MapLibre", sdk_dylibs = [ @@ -154,10 +170,14 @@ objc_library( objc_library( name = "iosapp", srcs = [ - "//platform/darwin:app/LimeGreenStyleLayer.h", - "//platform/darwin:app/LimeGreenStyleLayer.m", "//platform/ios:ios_app_srcs", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": [ + "//platform/darwin:app/LimeGreenStyleLayer.h", + "//platform/darwin:app/LimeGreenStyleLayer.m", + ], + }), data = glob([ "app/Assets.xcassets/**", ]), @@ -168,8 +188,13 @@ objc_library( "ios/src", ], sdk_frameworks = [ - "GLKit", # needed for LimeGreenStyleLayer - ], + ] + select({ + "//:metal_renderer": [ + "MetalKit" + ], + "//conditions:default": [ + "GLKit", # needed for LimeGreenStyleLayer + ]}), visibility = ["//visibility:public"], deps = [ ":ios-sdk", @@ -214,7 +239,14 @@ sh_binary( "//platform/macos:macos_objcpp_srcs", "//platform/macos:macos_private_hdrs", "//platform/macos:macos_public_hdrs", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": [ + "//platform/darwin:darwin_private_opengl_hdrs", + "//platform/darwin:darwin_objc_opengl_hdrs", + "//platform/darwin:darwin_objcpp_opengl_srcs", + ], + }), deps = [ "//platform/darwin:generated_code", ], diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index 07dcb2bf6..10ffec123 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -61,7 +61,7 @@ android { externalNativeBuild { cmake { - arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF", "-DMLN_RENDERER_SPLIT_VIEW=OFF" + arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF" } } } @@ -72,7 +72,7 @@ android { dimension = "renderer" externalNativeBuild { cmake { - arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF", "-DMLN_RENDERER_SPLIT_VIEW=OFF" + arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF" } } } @@ -80,7 +80,7 @@ android { dimension = "renderer" externalNativeBuild { cmake { - arguments "-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON", "-DMLN_RENDERER_SPLIT_VIEW=OFF" + arguments "-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON" } } } @@ -156,4 +156,4 @@ apply from: "${rootDir}/gradle/gradle-update-vendor-modules.gradle" apply from: "${rootDir}/gradle/android-nitpick.gradle" apply from: "${rootDir}/gradle/gradle-publish.gradle" // intentionally disabled -// apply from: "${rootDir}/gradle/jacoco-report.gradle" \ No newline at end of file +// apply from: "${rootDir}/gradle/jacoco-report.gradle" diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle index 80724d46a..7b2fc628e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle +++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle @@ -110,4 +110,4 @@ apply from: "${rootDir}/gradle/gradle-lint.gradle" -apply plugin: 'kotlin-android' \ No newline at end of file +apply plugin: 'kotlin-android' diff --git a/platform/darwin/BUILD.bazel b/platform/darwin/BUILD.bazel index 699b82dbd..03fda5a8d 100644 --- a/platform/darwin/BUILD.bazel +++ b/platform/darwin/BUILD.bazel @@ -3,8 +3,11 @@ load( "bazel/files.bzl", "MLN_DARWIN_OBJCPP_HEADERS", "MLN_DARWIN_OBJC_HEADERS", + "MLN_DARWIN_OBJC_OPENGL_HEADERS", "MLN_DARWIN_PRIVATE_HEADERS", + "MLN_DARWIN_PRIVATE_OPENGL_HEADERS", "MLN_DARWIN_PUBLIC_OBJCPP_SOURCE", + "MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE", "MLN_DARWIN_PUBLIC_OBJC_SOURCE", "MLN_GENERATED_DARWIN_STYLE_HEADERS", "MLN_GENERATED_DARWIN_STYLE_PUBLIC_HEADERS", @@ -21,12 +24,22 @@ filegroup( srcs = MLN_DARWIN_PRIVATE_HEADERS, visibility = ["//visibility:public"], ) +filegroup( + name = "darwin_private_opengl_hdrs", + srcs = MLN_DARWIN_PRIVATE_OPENGL_HEADERS, + visibility = ["//visibility:public"], +) filegroup( name = "darwin_objc_hdrs", srcs = MLN_DARWIN_OBJC_HEADERS, visibility = ["//visibility:public"], ) +filegroup( + name = "darwin_objc_opengl_hdrs", + srcs = MLN_DARWIN_OBJC_OPENGL_HEADERS, + visibility = ["//visibility:public"], +) filegroup( name = "darwin_objcpp_hdrs", @@ -39,6 +52,11 @@ filegroup( srcs = MLN_DARWIN_PUBLIC_OBJCPP_SOURCE, visibility = ["//visibility:public"], ) +filegroup( + name = "darwin_objcpp_opengl_srcs", + srcs = MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE, + visibility = ["//visibility:public"], +) filegroup( name = "darwin_objc_srcs", @@ -247,7 +265,6 @@ objc_library( srcs = [ "src/CFHandle.hpp", "src/collator.mm", - "src/headless_backend_eagl.mm", "src/http_file_source.mm", "src/image.mm", "src/local_glyph_rasterizer.mm", @@ -255,7 +272,10 @@ objc_library( "src/nsthread.mm", "src/number_format.mm", "src/string_nsstring.mm", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": ["src/headless_backend_eagl.mm"], + }), hdrs = [ "include/mbgl/interface/native_apple_interface.h", "include/mbgl/storage/reachability.h", @@ -286,19 +306,23 @@ objc_library( name = "darwin-loop", srcs = [ "src/async_task.cpp", - "src/gl_functions.cpp", "src/run_loop.cpp", "src/timer.cpp", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": ["src/gl_functions.cpp"], + }), copts = CPP_FLAGS + MAPLIBRE_FLAGS, defines = [ "GLES_SILENCE_DEPRECATION=1", "GL_SILENCE_DEPRECATION=1", ], sdk_frameworks = [ - "OpenGLES", "SystemConfiguration", - ], + ] + select({ + "//:metal_renderer": ["Metal"], + "//conditions:default": ["OpenGLES"], + }), visibility = ["//visibility:public"], deps = [ "//:mbgl-core", @@ -316,7 +340,10 @@ exports_files( "scripts/check-public-symbols.sh", ] + MLN_DARWIN_PUBLIC_OBJC_SOURCE + MLN_DARWIN_PUBLIC_OBJCPP_SOURCE + + MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE + MLN_DARWIN_PRIVATE_HEADERS + + MLN_DARWIN_PRIVATE_OPENGL_HEADERS + MLN_DARWIN_OBJC_HEADERS + + MLN_DARWIN_OBJC_OPENGL_HEADERS + MLN_DARWIN_OBJCPP_HEADERS, ) diff --git a/platform/darwin/bazel/files.bzl b/platform/darwin/bazel/files.bzl index 28ee151f3..27ad8c90d 100644 --- a/platform/darwin/bazel/files.bzl +++ b/platform/darwin/bazel/files.bzl @@ -74,7 +74,6 @@ MLN_DARWIN_OBJC_HEADERS = [ "src/MLNOfflinePack.h", "src/MLNOfflineRegion.h", "src/MLNOfflineStorage.h", - "src/MLNOpenGLStyleLayer.h", "src/MLNOverlay.h", "src/MLNPointAnnotation.h", "src/MLNPointCollection.h", @@ -101,6 +100,8 @@ MLN_DARWIN_OBJC_HEADERS = [ "src/NSPredicate+MLNAdditions.h", "src/NSValue+MLNAdditions.h", ] +MLN_DARWIN_OBJC_OPENGL_HEADERS = [ +] MLN_DARWIN_OBJCPP_HEADERS = [ "src/MLNConversion.h", @@ -137,7 +138,6 @@ MLN_DARWIN_PRIVATE_HEADERS = [ "src/MLNOfflinePack_Private.h", "src/MLNOfflineRegion_Private.h", "src/MLNOfflineStorage_Private.h", - "src/MLNOpenGLStyleLayer_Private.h", "src/MLNPointCollection_Private.h", "src/MLNPolygon_Private.h", "src/MLNPolyline_Private.h", @@ -156,6 +156,8 @@ MLN_DARWIN_PRIVATE_HEADERS = [ "src/NSExpression+MLNPrivateAdditions.h", "src/NSPredicate+MLNPrivateAdditions.h", ] +MLN_DARWIN_PRIVATE_OPENGL_HEADERS = [ +] MLN_DARWIN_PUBLIC_OBJCPP_SOURCE = [ "src/MLNAttributionInfo.mm", @@ -173,7 +175,6 @@ MLN_DARWIN_PUBLIC_OBJCPP_SOURCE = [ "src/MLNNetworkConfiguration.mm", "src/MLNOfflinePack.mm", "src/MLNOfflineStorage.mm", - "src/MLNOpenGLStyleLayer.mm", "src/MLNPointAnnotation.mm", "src/MLNPointCollection.mm", "src/MLNPolygon.mm", @@ -206,6 +207,11 @@ MLN_DARWIN_PUBLIC_OBJCPP_SOURCE = [ "src/NSPredicate+MLNAdditions.mm", "src/NSValue+MLNStyleAttributeAdditions.mm", ] +MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE = [ + "src/MLNOpenGLStyleLayer_Private.h", + "src/MLNOpenGLStyleLayer.h", + "src/MLNOpenGLStyleLayer.mm", +] MLN_DARWIN_PUBLIC_OBJC_SOURCE = [ "src/MLNAttributedExpression.m", diff --git a/platform/darwin/src/MLNStyle.mm b/platform/darwin/src/MLNStyle.mm index 7f9d19a62..7b885c6af 100644 --- a/platform/darwin/src/MLNStyle.mm +++ b/platform/darwin/src/MLNStyle.mm @@ -12,7 +12,6 @@ #import "MLNHillshadeStyleLayer.h" #import "MLNRasterStyleLayer.h" #import "MLNBackgroundStyleLayer.h" -#import "MLNOpenGLStyleLayer.h" #import "MLNStyleLayerManager.h" #import "MLNSource.h" @@ -40,6 +39,10 @@ #import "NSDate+MLNAdditions.h" +#if !MLN_RENDER_BACKEND_METAL + #import "MLNOpenGLStyleLayer.h" +#endif + #if TARGET_OS_IPHONE #import "UIImage+MLNAdditions.h" #else diff --git a/platform/darwin/src/MLNStyleLayerManager.mm b/platform/darwin/src/MLNStyleLayerManager.mm index 79e08be6b..29a1a711d 100644 --- a/platform/darwin/src/MLNStyleLayerManager.mm +++ b/platform/darwin/src/MLNStyleLayerManager.mm @@ -9,7 +9,10 @@ #import "MLNLineStyleLayer_Private.h" #import "MLNRasterStyleLayer_Private.h" #import "MLNSymbolStyleLayer_Private.h" + +#if !MLN_RENDER_BACKEND_METAL #import "MLNOpenGLStyleLayer_Private.h" +#endif #include @@ -63,7 +66,7 @@ LayerManagerDarwin::LayerManagerDarwin() { #endif #if defined(MBGL_LAYER_CUSTOM_DISABLE_RUNTIME) addLayerTypeCoreOnly(std::make_unique()); -#elif !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) +#elif !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) && !MLN_RENDER_BACKEND_METAL addLayerType(std::make_unique()); #endif } diff --git a/platform/darwin/test/MLNStyleTests.mm b/platform/darwin/test/MLNStyleTests.mm index 10aeaedbf..101c38ab3 100644 --- a/platform/darwin/test/MLNStyleTests.mm +++ b/platform/darwin/test/MLNStyleTests.mm @@ -232,7 +232,9 @@ XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MLNFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source] belowLayer:initial],NSException, @"MLNRedundantLayerIdentifierException"); XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MLNFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source] aboveLayer:initial], NSException, @"MLNRedundantLayerIdentifierException"); XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MLNFillStyleLayer alloc] initWithIdentifier:@"my-layer" source:source] atIndex:0], NSException, @"MLNRedundantLayerIdentifierException"); +#if !MLN_RENDER_BACKEND_METAL XCTAssertThrowsSpecificNamed([self.style insertLayer:[[MLNOpenGLStyleLayer alloc] initWithIdentifier:@"my-layer"] atIndex:0], NSException, @"MLNRedundantLayerIdentifierException"); +#endif } - (void)testRemovingLayerBeforeAddingSameLayer { diff --git a/platform/default/BUILD.bazel b/platform/default/BUILD.bazel index 8c8c662a2..b76d6f17c 100644 --- a/platform/default/BUILD.bazel +++ b/platform/default/BUILD.bazel @@ -32,7 +32,6 @@ cc_library( srcs = [ "src/mbgl/gfx/headless_backend.cpp", "src/mbgl/gfx/headless_frontend.cpp", - "src/mbgl/gl/headless_backend.cpp", "src/mbgl/map/map_snapshotter.cpp", "src/mbgl/platform/time.cpp", "src/mbgl/storage/asset_file_source.cpp", @@ -56,6 +55,9 @@ cc_library( "src/mbgl/util/thread_local.cpp", "src/mbgl/util/utf.cpp", ] + select({ + "//:metal_renderer": [], + "//conditions:default": ["src/mbgl/gl/headless_backend.cpp"], + }) + select({ "//:linux": [ "src/mbgl/i18n/number_format.cpp", "src/mbgl/layermanager/layer_manager.cpp", @@ -77,7 +79,6 @@ cc_library( hdrs = [ "include/mbgl/gfx/headless_backend.hpp", "include/mbgl/gfx/headless_frontend.hpp", - "include/mbgl/gl/headless_backend.hpp", "include/mbgl/map/map_snapshotter.hpp", "include/mbgl/storage/file_source_request.hpp", "include/mbgl/storage/local_file_request.hpp", @@ -87,7 +88,10 @@ cc_library( "include/mbgl/storage/offline_schema.hpp", "include/mbgl/storage/sqlite3.hpp", "include/mbgl/text/unaccent.hpp", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": ["include/mbgl/gl/headless_backend.hpp"], + }), copts = CPP_FLAGS + MAPLIBRE_FLAGS, includes = [ "include", diff --git a/platform/default/include/mbgl/gfx/headless_backend.hpp b/platform/default/include/mbgl/gfx/headless_backend.hpp index 1dc775531..14bff3eff 100644 --- a/platform/default/include/mbgl/gfx/headless_backend.hpp +++ b/platform/default/include/mbgl/gfx/headless_backend.hpp @@ -24,7 +24,11 @@ public: static std::unique_ptr Create(const Size size = {256, 256}, SwapBehaviour swapBehavior = SwapBehaviour::NoFlush, const gfx::ContextMode contextMode = gfx::ContextMode::Unique) { +#if MLN_RENDER_BACKEND_METAL + return nullptr; +#else // MLN_RENDER_BACKEND_OPENGL return Backend::Create(size, swapBehavior, contextMode); +#endif } virtual PremultipliedImage readStillImage() = 0; diff --git a/platform/default/src/mbgl/layermanager/layer_manager.cpp b/platform/default/src/mbgl/layermanager/layer_manager.cpp index fed82abfb..8411a9831 100644 --- a/platform/default/src/mbgl/layermanager/layer_manager.cpp +++ b/platform/default/src/mbgl/layermanager/layer_manager.cpp @@ -61,7 +61,7 @@ LayerManagerDefault::LayerManagerDefault() { #if !defined(MBGL_LAYER_HEATMAP_DISABLE_ALL) addLayerType(std::make_unique()); #endif -#ifdef MBGL_RENDER_BACKEND_OPENGL +#ifdef MLN_RENDER_BACKEND_OPENGL #if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) addLayerType(std::make_unique()); #endif diff --git a/platform/glfw/CMakeLists.txt b/platform/glfw/CMakeLists.txt index 2118a9fd2..98344bc0c 100644 --- a/platform/glfw/CMakeLists.txt +++ b/platform/glfw/CMakeLists.txt @@ -36,7 +36,7 @@ if(MLN_WITH_OPENGL) ) target_compile_definitions( mbgl-glfw - PRIVATE MBGL_RENDER_BACKEND_OPENGL=1 + PRIVATE MLN_RENDER_BACKEND_OPENGL=1 ) endif() diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 7f41e9a9a..5bfa8272e 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -55,7 +55,7 @@ #include #include -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL) #include namespace { @@ -824,7 +824,7 @@ void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset) } view->map->scaleBy(scale, mbgl::ScreenCoordinate{view->lastX, view->lastY}); -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) if (view->puck && view->puckFollowsCameraCenter) { mbgl::LatLng mapCenter = view->map->getCameraOptions().center.value(); view->puck->setLocation(toArray(mapCenter)); @@ -899,7 +899,7 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { } view->lastX = x; view->lastY = y; -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) if (view->puck && view->puckFollowsCameraCenter) { mbgl::LatLng mapCenter = view->map->getCameraOptions().center.value(); view->puck->setLocation(toArray(mapCenter)); @@ -1034,7 +1034,7 @@ void GLFWView::setWindowTitle(const std::string &title) { } void GLFWView::onDidFinishLoadingStyle() { -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) puck = nullptr; #endif @@ -1099,7 +1099,7 @@ void GLFWView::toggleCustomSource() { } void GLFWView::toggleLocationIndicatorLayer() { -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL) puck = static_cast(map->getStyle().getLayer("puck")); static const mbgl::LatLng puckLocation{35.683389, 139.76525}; // A location on the crossing of 4 tiles if (puck == nullptr) { @@ -1162,7 +1162,7 @@ void GLFWView::toggleLocationIndicatorLayer() { using Nanoseconds = std::chrono::nanoseconds; void GLFWView::onWillStartRenderingFrame() { -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL) puck = static_cast(map->getStyle().getLayer("puck")); if (puck) { uint64_t ns = mbgl::Clock::now().time_since_epoch().count(); diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index 40f711940..a4912d1c1 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -5,7 +5,7 @@ #include #include #include -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) #include #endif @@ -160,7 +160,7 @@ private: mbgl::ResourceOptions mapResourceOptions; mbgl::ClientOptions mapClientOptions; -#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) +#if defined(MLN_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) bool puckFollowsCameraCenter = false; mbgl::style::LocationIndicatorLayer *puck = nullptr; #endif diff --git a/platform/ios/BUILD.bazel b/platform/ios/BUILD.bazel index 972d6c0f0..c21665e69 100644 --- a/platform/ios/BUILD.bazel +++ b/platform/ios/BUILD.bazel @@ -14,6 +14,8 @@ load( "MLN_IOS_PRIVATE_HEADERS", "MLN_IOS_PUBLIC_HEADERS", "MLN_IOS_PUBLIC_OBJCPP_SOURCE", + "MLN_IOS_PUBLIC_OBJCPP_OPENGL_SOURCE", + "MLN_IOS_PUBLIC_OBJCPP_METAL_SOURCE", "MLN_IOS_PUBLIC_OBJC_SOURCE", "MLN_IOS_SDK_HEADERS", "MLN_PUBLIC_IOS_APP_SOPURCE", @@ -42,7 +44,10 @@ filegroup( filegroup( name = "ios_objcpp_srcs", - srcs = MLN_IOS_PUBLIC_OBJCPP_SOURCE, + srcs = MLN_IOS_PUBLIC_OBJCPP_SOURCE + select({ + "//:metal_renderer": MLN_IOS_PUBLIC_OBJCPP_METAL_SOURCE, + "//conditions:default": MLN_IOS_PUBLIC_OBJCPP_OPENGL_SOURCE, + }), visibility = ["//visibility:public"], ) @@ -74,7 +79,13 @@ apple_static_xcframework( ":ios_sdk_hdrs", "//platform/darwin:darwin_objc_hdrs", "//platform/darwin:darwin_objcpp_hdrs", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": [ + "//platform/darwin:darwin_objc_opengl_hdrs", + "//platform/darwin:darwin_objcpp_opengl_hdrs" + ], + }), umbrella_header = "src/Mapbox.h", visibility = ["//visibility:public"], deps = ["//platform:ios-sdk"], @@ -114,7 +125,13 @@ apple_xcframework( ":ios_sdk_hdrs", "//platform/darwin:darwin_objc_hdrs", "//platform/darwin:darwin_objcpp_hdrs", - ], + ] + select({ + "//:metal_renderer": [], + "//conditions:default": [ + "//platform/darwin:darwin_objc_opengl_hdrs", + "//platform/darwin:darwin_objcpp_opengl_hdrs" + ], + }), umbrella_header = "src/Mapbox.h", visibility = ["//visibility:public"], deps = ["//platform:ios-sdk-dynamic"], @@ -307,6 +324,8 @@ exports_files( MLN_IOS_PUBLIC_HEADERS + MLN_IOS_PRIVATE_HEADERS + MLN_IOS_PUBLIC_OBJCPP_SOURCE + + MLN_IOS_PUBLIC_OBJCPP_METAL_SOURCE + + MLN_IOS_PUBLIC_OBJCPP_OPENGL_SOURCE + MLN_IOS_PUBLIC_OBJC_SOURCE + - MLN_PUBLIC_IOS_APP_SOPURCE, + MLN_PUBLIC_IOS_APP_SOPURCE ) diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index e0177ecad..58cecf587 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -7,13 +7,16 @@ #import "MBXOfflinePacksTableViewController.h" #import "MBXAnnotationView.h" #import "MBXUserLocationAnnotationView.h" -#import "LimeGreenStyleLayer.h" #import "MBXEmbeddedMapViewController.h" #import "MBXOrnamentsViewController.h" #import "MBXStateManager.h" #import "MBXState.h" #import "MLNSettings.h" +#if !MLN_RENDER_BACKEND_METAL +#import "LimeGreenStyleLayer.h" +#endif + #import "MBXFrameTimeGraphView.h" #import "MLNMapView_Experimental.h" #import @@ -98,7 +101,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) { MBXSettingsRuntimeStylingRasterTileSource, MBXSettingsRuntimeStylingImageSource, MBXSettingsRuntimeStylingRouteLine, +#if !MLN_RENDER_BACKEND_METAL MBXSettingsRuntimeStylingAddLimeGreenTriangleLayer, +#endif MBXSettingsRuntimeStylingDDSPolygon, MBXSettingsRuntimeStylingCustomLatLonGrid, MBXSettingsRuntimeStylingLineGradient, @@ -640,9 +645,11 @@ CLLocationCoordinate2D randomWorldCoordinate(void) { case MBXSettingsRuntimeStylingRouteLine: [self styleRouteLine]; break; +#if !MLN_RENDER_BACKEND_METAL case MBXSettingsRuntimeStylingAddLimeGreenTriangleLayer: [self styleAddLimeGreenTriangleLayer]; break; +#endif case MBXSettingsRuntimeStylingDDSPolygon: [self stylePolygonWithDDS]; break; @@ -1583,11 +1590,13 @@ CLLocationCoordinate2D randomWorldCoordinate(void) { [self.mapView.style addLayer:routeLayer]; } +#if !MLN_RENDER_BACKEND_METAL - (void)styleAddLimeGreenTriangleLayer { LimeGreenStyleLayer *layer = [[LimeGreenStyleLayer alloc] initWithIdentifier:@"mbx-custom"]; [self.mapView.style addLayer:layer]; } +#endif - (void)stylePolygonWithDDS { CLLocationCoordinate2D leftCoords[] = { diff --git a/platform/ios/bazel/files.bzl b/platform/ios/bazel/files.bzl index de4db5fd5..7b2ebfb0b 100644 --- a/platform/ios/bazel/files.bzl +++ b/platform/ios/bazel/files.bzl @@ -19,6 +19,7 @@ MLN_IOS_PUBLIC_HEADERS = [ "src/MLNFaux3DUserLocationAnnotationView.h", "src/MLNMapAccessibilityElement.h", "src/MLNMapView+Impl.h", + "src/MLNMapView+Metal.h", "src/MLNMapView+OpenGL.h", "src/MLNScaleBar.h", "src/MLNUserLocationHeadingArrowLayer.h", @@ -66,11 +67,16 @@ MLN_IOS_PUBLIC_OBJCPP_SOURCE = [ "src/MLNMapProjection.mm", "src/MLNMapView.mm", "src/MLNMapView+Impl.mm", - "src/MLNMapView+OpenGL.mm", "src/MLNScaleBar.mm", "src/UIColor+MLNAdditions.mm", "src/UIImage+MLNAdditions.mm", ] +MLN_IOS_PUBLIC_OBJCPP_OPENGL_SOURCE = [ + "src/MLNMapView+OpenGL.mm", +] +MLN_IOS_PUBLIC_OBJCPP_METAL_SOURCE = [ + "src/MLNMapView+Metal.mm", +] MLN_PUBLIC_IOS_APP_SOPURCE = [ "app/MBXAnnotationView.m", diff --git a/platform/ios/scripts/bazel-generate-plists.sh b/platform/ios/scripts/bazel-generate-plists.sh index dd6740055..c154dee38 100755 --- a/platform/ios/scripts/bazel-generate-plists.sh +++ b/platform/ios/scripts/bazel-generate-plists.sh @@ -82,4 +82,5 @@ cat > platform/ios/bazel/config.bzl < MLNMapViewImpl::Create(MLNMapView* nativeView) { +#if MLN_RENDER_BACKEND_METAL + return std::make_unique(nativeView); +#else // MLN_RENDER_BACKEND_OPENGL return std::make_unique(nativeView); +#endif } MLNMapViewImpl::MLNMapViewImpl(MLNMapView* nativeView_) : mapView(nativeView_) { diff --git a/platform/ios/src/MLNMapView+Metal.h b/platform/ios/src/MLNMapView+Metal.h new file mode 100644 index 000000000..e78e83373 --- /dev/null +++ b/platform/ios/src/MLNMapView+Metal.h @@ -0,0 +1,54 @@ +#import "MLNMapView+Impl.h" +#import "MLNMapView_Private.h" + +#include +#include + +@class MLNMapViewImplDelegate; + +/// Adapter responsible for bridging calls from mbgl to MLNMapView and Cocoa. +class MLNMapViewMetalImpl final : public MLNMapViewImpl, + public mbgl::mtl::RendererBackend, + public mbgl::gfx::Renderable { +public: + MLNMapViewMetalImpl(MLNMapView*); + ~MLNMapViewMetalImpl() override; + +public: + void restoreFramebufferBinding(); + + // Implementation of mbgl::gfx::RendererBackend +public: + mbgl::gfx::Renderable& getDefaultRenderable() override { + return *this; + } + +private: + void activate() override; + void deactivate() override; + // End implementation of mbgl::gfx::RendererBackend + + // Implementation of mbgl::gl::RendererBackend +public: + void updateAssumedState() override; + // End implementation of mbgl::gl::Rendererbackend + + // Implementation of MLNMapViewImpl +public: + mbgl::gfx::RendererBackend& getRendererBackend() override { + return *this; + } + + void setOpaque(bool) override; + void display() override; + void setPresentsWithTransaction(bool) override; + void createView() override; + UIView* getView() override; + void deleteView() override; + UIImage* snapshot() override; + void layoutChanged() override; + // End implementation of MLNMapViewImpl + +private: + bool presentsWithTransaction = false; +}; diff --git a/platform/ios/src/MLNMapView+Metal.mm b/platform/ios/src/MLNMapView+Metal.mm new file mode 100644 index 000000000..4547a5af0 --- /dev/null +++ b/platform/ios/src/MLNMapView+Metal.mm @@ -0,0 +1,212 @@ +#import "MLNFoundation_Private.h" +#import "MLNLoggingConfiguration_Private.h" +#import "MLNMapView+Metal.h" + +#import + +#import +#import +#import + +#import + +@interface MLNMapViewImplDelegate : NSObject +@end + +@implementation MLNMapViewImplDelegate { + MLNMapViewMetalImpl* _impl; +} + +- (instancetype)initWithImpl:(MLNMapViewMetalImpl*)impl { + if (self = [super init]) { + _impl = impl; + } + return self; +} + +- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size {} + +- (void)drawInMTKView:(MTKView *)view { + _impl->render(); +} + +@end + +namespace { +CGFloat contentScaleFactor() { + return [UIScreen instancesRespondToSelector:@selector(nativeScale)] + ? [[UIScreen mainScreen] nativeScale] + : [[UIScreen mainScreen] scale]; +} +} // namespace + +class MLNMapViewMetalRenderableResource final : public mbgl::mtl::RenderableResource { +public: + MLNMapViewMetalRenderableResource(MLNMapViewMetalImpl& backend_) + : backend(backend_), + delegate([[MLNMapViewImplDelegate alloc] initWithImpl:&backend]) { + } + + void bind() override { + if (!commandQueue) { + commandQueue = [mtlView.device newCommandQueue]; + } + + commandBuffer = [commandQueue commandBuffer]; + commandBufferPtr = NS::RetainPtr((__bridge MTL::CommandBuffer*)commandBuffer); + + currentDrawable = [mtlView currentDrawable]; + } + + const mbgl::mtl::RendererBackend& getBackend() const override { return backend; } + + const mbgl::mtl::MTLCommandBufferPtr& getCommandBuffer() const override { + return commandBufferPtr; + } + + virtual mbgl::mtl::MTLBlitPassDescriptorPtr getUploadPassDescriptor() const override { + // Create from render pass descriptor? + return NS::TransferPtr(MTL::BlitPassDescriptor::alloc()->init()); + } + + mbgl::mtl::MTLRenderPassDescriptorPtr getRenderPassDescriptor() const override { + return NS::RetainPtr((__bridge MTL::RenderPassDescriptor*)mtlView.currentRenderPassDescriptor); + } + + void swap() override { + [commandBuffer presentDrawable:currentDrawable]; + [commandBuffer commit]; + commandBuffer = nil; + commandBufferPtr.reset(); + } + + mbgl::Size framebufferSize() { + assert(mtlView); + return { static_cast(mtlView.drawableSize.width), + static_cast(mtlView.drawableSize.height) }; + } + +private: + MLNMapViewMetalImpl& backend; + mbgl::mtl::MTLCommandBufferPtr commandBufferPtr; + +public: + MLNMapViewImplDelegate* delegate = nil; + MTKView *mtlView = nil; + id currentDrawable; + id commandBuffer; + id commandQueue; + + // We count how often the context was activated/deactivated so that we can truly deactivate it + // after the activation count drops to 0. + NSUInteger activationCount = 0; +}; + +MLNMapViewMetalImpl::MLNMapViewMetalImpl(MLNMapView* nativeView_) + : MLNMapViewImpl(nativeView_), + mbgl::mtl::RendererBackend(mbgl::gfx::ContextMode::Unique), + mbgl::gfx::Renderable({ 0, 0 }, std::make_unique(*this)) { +} + +MLNMapViewMetalImpl::~MLNMapViewMetalImpl() = default; + +void MLNMapViewMetalImpl::setOpaque(const bool opaque) { + auto& resource = getResource(); + resource.mtlView.opaque = opaque; + resource.mtlView.layer.opaque = opaque; +} + +void MLNMapViewMetalImpl::setPresentsWithTransaction(const bool value) { + presentsWithTransaction = value; + + if (@available(iOS 13.0, *)) { + auto& resource = getResource(); + if (CAMetalLayer* metalLayer = MLN_OBJC_DYNAMIC_CAST(resource.mtlView.layer, CAMetalLayer)) { + metalLayer.presentsWithTransaction = value; + } + } +} + +void MLNMapViewMetalImpl::display() { + auto& resource = getResource(); + + // Calling `display` here directly causes the stuttering bug (if + // `presentsWithTransaction` is `YES` - see above) + // as reported in https://github.com/mapbox/mapbox-gl-native-ios/issues/350 + // + // Since we use `presentsWithTransaction` to synchronize with UIView + // annotations, we now let the system handle when the view is rendered. This + // has the potential to increase latency + [resource.mtlView setNeedsDisplay]; +} + +void MLNMapViewMetalImpl::createView() { + auto& resource = getResource(); + if (resource.mtlView) { + return; + } + + id device = (__bridge id)resource.getBackend().getDevice().get(); + + resource.mtlView = [[MTKView alloc] initWithFrame:mapView.bounds device:device]; + resource.mtlView.delegate = resource.delegate; + resource.mtlView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + resource.mtlView.contentScaleFactor = contentScaleFactor(); + resource.mtlView.contentMode = UIViewContentModeCenter; + resource.mtlView.colorPixelFormat = MTLPixelFormatBGRA8Unorm; + resource.mtlView.depthStencilPixelFormat = MTLPixelFormatDepth32Float_Stencil8; + resource.mtlView.opaque = mapView.opaque; + resource.mtlView.layer.opaque = mapView.opaque; + resource.mtlView.enableSetNeedsDisplay = YES; + + if (@available(iOS 13.0, *)) { + CAMetalLayer* metalLayer = MLN_OBJC_DYNAMIC_CAST(resource.mtlView.layer, CAMetalLayer); + metalLayer.presentsWithTransaction = presentsWithTransaction; + } + + [mapView insertSubview:resource.mtlView atIndex:0]; +} + +UIView* MLNMapViewMetalImpl::getView() { + auto& resource = getResource(); + return resource.mtlView; +} + +void MLNMapViewMetalImpl::deleteView() { + auto& resource = getResource(); + [resource.mtlView releaseDrawables]; +} + +void MLNMapViewMetalImpl::activate() { + auto& resource = getResource(); + if (resource.activationCount++) { + return; + } +} + +void MLNMapViewMetalImpl::deactivate() { + auto& resource = getResource(); + if (--resource.activationCount) { + return; + } +} + +/// This function is called before we start rendering, when iOS invokes our rendering method. +/// iOS already sets the correct framebuffer and viewport for us, so we need to update the +/// context state with the anticipated values. +void MLNMapViewMetalImpl::updateAssumedState() { + auto& resource = getResource(); + assumeFramebufferBinding(ImplicitFramebufferBinding); + assumeViewport(0, 0, resource.framebufferSize()); +} + +UIImage* MLNMapViewMetalImpl::snapshot() { + auto& resource = getResource(); + return nil; //TODO: resource.mtlView.snapshot; +} + +void MLNMapViewMetalImpl::layoutChanged() { + const auto scaleFactor = contentScaleFactor(); + size = { static_cast(mapView.bounds.size.width * scaleFactor), + static_cast(mapView.bounds.size.height * scaleFactor) }; +} diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index a62889457..6554eae0e 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -46,7 +46,9 @@ FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; #import "MLNOfflinePack.h" #import "MLNOfflineRegion.h" #import "MLNOfflineStorage.h" +#if !MLN_RENDER_BACKEND_METAL #import "MLNOpenGLStyleLayer.h" +#endif #import "MLNOverlay.h" #import "MLNPointAnnotation.h" #import "MLNPointCollection.h" @@ -74,4 +76,4 @@ FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; #import "NSExpression+MLNAdditions.h" #import "NSPredicate+MLNAdditions.h" #import "NSValue+MLNAdditions.h" -#import "MLNUserLocationAnnotationViewStyle.h" \ No newline at end of file +#import "MLNUserLocationAnnotationViewStyle.h" diff --git a/platform/ios/test/BUILD.bazel b/platform/ios/test/BUILD.bazel index 1176b03cb..9667794d5 100644 --- a/platform/ios/test/BUILD.bazel +++ b/platform/ios/test/BUILD.bazel @@ -66,6 +66,9 @@ ios_unit_test( "//platform/darwin:shared_tests_objc_srcs", "//platform/darwin:shared_tests_objcpp_srcs", "//platform/darwin:shared_tests_swift_srcs", + "//platform/darwin:darwin_objc_hdrs", + "//platform/darwin:darwin_objcpp_hdrs", + "//platform/darwin:darwin_objc_opengl_hdrs", ], ) diff --git a/platform/macos/BUILD.bazel b/platform/macos/BUILD.bazel index 6bd37a1dd..66b7858e3 100644 --- a/platform/macos/BUILD.bazel +++ b/platform/macos/BUILD.bazel @@ -3,6 +3,8 @@ load( "MLN_MACOS_PRIVATE_HEADERS", "MLN_MACOS_PUBLIC_HEADERS", "MLN_MACOS_PUBLIC_OBJCPP_SOURCE", + "MLN_MACOS_PUBLIC_OBJCPP_OPENGL_SOURCE", + "MLN_MACOS_PUBLIC_OBJCPP_METAL_SOURCE", "MLN_MACOS_PUBLIC_OBJC_SOURCE", ) @@ -20,7 +22,10 @@ filegroup( filegroup( name = "macos_objcpp_srcs", - srcs = MLN_MACOS_PUBLIC_OBJCPP_SOURCE, + srcs = MLN_MACOS_PUBLIC_OBJCPP_SOURCE + select({ + "//:metal_renderer": MLN_MACOS_PUBLIC_OBJCPP_METAL_SOURCE, + "//conditions:default": MLN_MACOS_PUBLIC_OBJCPP_OPENGL_SOURCE, + }), visibility = ["//visibility:public"], ) @@ -34,5 +39,6 @@ exports_files( MLN_MACOS_PRIVATE_HEADERS + MLN_MACOS_PUBLIC_HEADERS + MLN_MACOS_PUBLIC_OBJCPP_SOURCE + - MLN_MACOS_PUBLIC_OBJC_SOURCE, + MLN_MACOS_PUBLIC_OBJCPP_METAL_SOURCE + + MLN_MACOS_PUBLIC_OBJC_SOURCE ) diff --git a/platform/macos/bazel/files.bzl b/platform/macos/bazel/files.bzl index 17be06dcc..7d7ec4114 100644 --- a/platform/macos/bazel/files.bzl +++ b/platform/macos/bazel/files.bzl @@ -1,13 +1,18 @@ MLN_MACOS_PUBLIC_OBJCPP_SOURCE = [ "src/MLNAttributionButton.mm", "src/MLNMapView+IBAdditions.mm", - "src/MLNMapView+OpenGL.mm", "src/MLNMapView+Impl.mm", "src/MLNMapView.mm", "src/MLNOpenGLLayer.mm", "src/NSColor+MLNAdditions.mm", "src/NSImage+MLNAdditions.mm", ] +MLN_MACOS_PUBLIC_OBJCPP_OPENGL_SOURCE = [ + "src/MLNMapView+OpenGL.mm", +] +MLN_MACOS_PUBLIC_OBJCPP_METAL_SOURCE = [ + "src/MLNMapView+OpenGL.mm", +] MLN_MACOS_PUBLIC_OBJC_SOURCE = [ "src/MLNAnnotationImage.m", diff --git a/platform/macos/src/MLNMapView+Impl.mm b/platform/macos/src/MLNMapView+Impl.mm index 0ba217d7c..c57bb3386 100644 --- a/platform/macos/src/MLNMapView+Impl.mm +++ b/platform/macos/src/MLNMapView+Impl.mm @@ -1,8 +1,13 @@ #import "MLNMapView+Impl.h" -#import "MLNMapView+OpenGL.h" #import "MLNStyle_Private.h" #import "NSBundle+MLNAdditions.h" +#if MLN_RENDER_BACKEND_METAL +#import "MLNMapView+Metal.h" +#else // MLN_RENDER_BACKEND_OPENGL +#import "MLNMapView+OpenGL.h" +#endif + #include #include diff --git a/render-test/CMakeLists.txt b/render-test/CMakeLists.txt index 2ade54ead..4360147bb 100644 --- a/render-test/CMakeLists.txt +++ b/render-test/CMakeLists.txt @@ -66,3 +66,7 @@ target_link_libraries( ) set_property(TARGET mbgl-render-test PROPERTY FOLDER Core) + +if(MLN_WITH_OPENGL) + target_compile_definitions(mbgl-render-test PRIVATE "MLN_RENDER_BACKEND_OPENGL=1") +endif() diff --git a/shaders/drawable.fill.fragment.glsl b/shaders/drawable.fill.fragment.glsl index 1eeadc94a..36cc6be0b 100644 --- a/shaders/drawable.fill.fragment.glsl +++ b/shaders/drawable.fill.fragment.glsl @@ -1,32 +1,14 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { - highp mat4 u_matrix; - highp vec4 u_scale; - highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; -}; -layout (std140) uniform FillDrawablePropsUBO { +layout (std140) uniform FillEvaluatedPropsUBO { highp vec4 u_color; - highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillInterpolateUBO { + highp float u_color_t; + highp float u_opacity_t; + highp float pad_interp_1, pad_interp_2; }; #pragma mapbox: define highp vec4 color diff --git a/shaders/drawable.fill.vertex.glsl b/shaders/drawable.fill.vertex.glsl index 77e2cb16a..9ac467c8e 100644 --- a/shaders/drawable.fill.vertex.glsl +++ b/shaders/drawable.fill.vertex.glsl @@ -1,32 +1,17 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; layout (std140) uniform FillDrawableUBO { highp mat4 u_matrix; - highp vec4 u_scale; - highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { +layout (std140) uniform FillEvaluatedPropsUBO { highp vec4 u_color; - highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillInterpolateUBO { + highp float u_color_t; + highp float u_opacity_t; + highp float pad_interp_1, pad_interp_2; }; layout (location = 0) in vec2 a_pos; diff --git a/shaders/drawable.fill_outline.fragment.glsl b/shaders/drawable.fill_outline.fragment.glsl index b2be2c4cf..44b3b20df 100644 --- a/shaders/drawable.fill_outline.fragment.glsl +++ b/shaders/drawable.fill_outline.fragment.glsl @@ -1,32 +1,15 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { - highp mat4 u_matrix; - highp vec4 u_scale; - highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; -}; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; +layout (std140) uniform FillOutlineEvaluatedPropsUBO { highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillOutlineInterpolateUBO { + highp float u_outline_color_t; + highp float u_opacity_t; + highp float u_padding_interp1; + highp float u_padding_interp2; }; in vec2 v_pos; diff --git a/shaders/drawable.fill_outline.vertex.glsl b/shaders/drawable.fill_outline.vertex.glsl index 41218a869..b201f79a4 100644 --- a/shaders/drawable.fill_outline.vertex.glsl +++ b/shaders/drawable.fill_outline.vertex.glsl @@ -1,32 +1,19 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { +layout (std140) uniform FillOutlineDrawableUBO { highp mat4 u_matrix; - highp vec4 u_scale; highp vec2 u_world; - highp vec2 u_pixel_coord_upper; - highp vec2 u_pixel_coord_lower; - highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; +layout (std140) uniform FillOutlineEvaluatedPropsUBO { highp vec4 u_outline_color; highp float u_opacity; highp float padding_props1; highp float padding_props2; highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { - highp vec4 u_pattern_from; - highp vec4 u_pattern_to; +layout (std140) uniform FillOutlineInterpolateUBO { + highp float u_outline_color_t; + highp float u_opacity_t; + highp float u_padding_interp1; + highp float u_padding_interp2; }; layout (location = 0) in vec2 a_pos; diff --git a/shaders/drawable.fill_outline_pattern.fragment.glsl b/shaders/drawable.fill_outline_pattern.fragment.glsl index 8bbf277f8..eff75cd08 100644 --- a/shaders/drawable.fill_outline_pattern.fragment.glsl +++ b/shaders/drawable.fill_outline_pattern.fragment.glsl @@ -1,14 +1,4 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { +layout (std140) uniform FillOutlinePatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; highp vec2 u_world; @@ -16,15 +6,19 @@ layout (std140) uniform FillDrawableUBO { highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillOutlinePatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillOutlinePatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float pad1; +}; +layout (std140) uniform FillOutlinePatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; diff --git a/shaders/drawable.fill_outline_pattern.vertex.glsl b/shaders/drawable.fill_outline_pattern.vertex.glsl index 2b5dd2a1a..785fe032f 100644 --- a/shaders/drawable.fill_outline_pattern.vertex.glsl +++ b/shaders/drawable.fill_outline_pattern.vertex.glsl @@ -1,14 +1,4 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { +layout (std140) uniform FillOutlinePatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; highp vec2 u_world; @@ -16,15 +6,19 @@ layout (std140) uniform FillDrawableUBO { highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillOutlinePatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillOutlinePatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float pad1; +}; +layout (std140) uniform FillOutlinePatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; diff --git a/shaders/drawable.fill_pattern.fragment.glsl b/shaders/drawable.fill_pattern.fragment.glsl index 1308b0845..3f5195795 100644 --- a/shaders/drawable.fill_pattern.fragment.glsl +++ b/shaders/drawable.fill_pattern.fragment.glsl @@ -1,30 +1,23 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { +layout (std140) uniform FillPatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; - highp vec2 u_world; highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillPatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float u_padding_interp1; +}; +layout (std140) uniform FillPatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; diff --git a/shaders/drawable.fill_pattern.vertex.glsl b/shaders/drawable.fill_pattern.vertex.glsl index a6ab36193..afff0a637 100644 --- a/shaders/drawable.fill_pattern.vertex.glsl +++ b/shaders/drawable.fill_pattern.vertex.glsl @@ -1,30 +1,23 @@ -layout (std140) uniform FillInterpolateUBO { - highp float u_color_t; - highp float u_opacity_t; - highp float u_outline_color_t; - highp float u_pattern_from_t; - highp float u_pattern_to_t; - highp float u_fade; - highp float u_padding_interp1; - highp float u_padding_interp2; -}; -layout (std140) uniform FillDrawableUBO { +layout (std140) uniform FillPatternDrawableUBO { highp mat4 u_matrix; highp vec4 u_scale; - highp vec2 u_world; highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; }; -layout (std140) uniform FillDrawablePropsUBO { - highp vec4 u_color; - highp vec4 u_outline_color; +layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; + highp float u_fade; highp float padding_props1; highp float padding_props2; - highp float padding_props3; }; -layout (std140) uniform FillDrawableTilePropsUBO { +layout (std140) uniform FillPatternInterpolateUBO { + highp float u_pattern_from_t; + highp float u_pattern_to_t; + highp float u_opacity_t; + highp float u_padding_interp1; +}; +layout (std140) uniform FillPatternTilePropsUBO { highp vec4 u_pattern_from; highp vec4 u_pattern_to; }; diff --git a/shaders/drawable.line_sdf.fragment.glsl b/shaders/drawable.line_sdf.fragment.glsl index 72f3edafb..c15478885 100644 --- a/shaders/drawable.line_sdf.fragment.glsl +++ b/shaders/drawable.line_sdf.fragment.glsl @@ -32,6 +32,7 @@ layout (std140) uniform LineSDFInterpolationUBO { lowp float u_offset_t; lowp float u_width_t; lowp float u_floorwidth_t; + highp float pad2; }; diff --git a/shaders/drawable.line_sdf.vertex.glsl b/shaders/drawable.line_sdf.vertex.glsl index 40f167639..879857830 100644 --- a/shaders/drawable.line_sdf.vertex.glsl +++ b/shaders/drawable.line_sdf.vertex.glsl @@ -46,6 +46,7 @@ layout (std140) uniform LineSDFInterpolationUBO { lowp float u_offset_t; lowp float u_width_t; lowp float u_floorwidth_t; + highp float pad2; }; diff --git a/shaders/generate_shader_code.js b/shaders/generate_shader_code.js index af48723bd..cee954bae 100644 --- a/shaders/generate_shader_code.js +++ b/shaders/generate_shader_code.js @@ -278,7 +278,7 @@ fs.writeFileSync(path.join(outputRoot, "shader_manifest.hpp"), #pragma once #include -#ifdef MBGL_RENDER_BACKEND_OPENGL +#if !MLN_RENDER_BACKEND_METAL ${generatedHeaders.join('\n')} #endif `); diff --git a/shaders/hillshade_prepare.fragment.glsl b/shaders/hillshade_prepare.fragment.glsl index 4734527b0..5175fb122 100644 --- a/shaders/hillshade_prepare.fragment.glsl +++ b/shaders/hillshade_prepare.fragment.glsl @@ -52,7 +52,7 @@ void main() { // we want to vertically exaggerate the hillshading though, because otherwise // it is barely noticeable at low zooms. to do this, we multiply this by some // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value - // Here we use a=0.3 which works out to the expression below. see + // Here we use a=0.3 which works out to the expression below. see // nickidlugash's awesome breakdown for more info // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556 float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3; diff --git a/src/mbgl/gfx/command_encoder.hpp b/src/mbgl/gfx/command_encoder.hpp index 617a20b3f..c632e4843 100644 --- a/src/mbgl/gfx/command_encoder.hpp +++ b/src/mbgl/gfx/command_encoder.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace mbgl { namespace gfx { @@ -26,8 +27,9 @@ public: CommandEncoder& operator=(const CommandEncoder&) = delete; DebugGroup createDebugGroup(const char* name) { return {*this, name}; } + DebugGroup createDebugGroup(std::string_view name) { return createDebugGroup(name.data()); } - virtual std::unique_ptr createUploadPass(const char* name) = 0; + virtual std::unique_ptr createUploadPass(const char* name, Renderable&) = 0; virtual std::unique_ptr createRenderPass(const char* name, const RenderPassDescriptor&) = 0; virtual void present(Renderable&) = 0; }; diff --git a/src/mbgl/gfx/drawable_builder.cpp b/src/mbgl/gfx/drawable_builder.cpp index e462145ac..183f185e0 100644 --- a/src/mbgl/gfx/drawable_builder.cpp +++ b/src/mbgl/gfx/drawable_builder.cpp @@ -167,6 +167,7 @@ void DrawableBuilder::setSegments(const gfx::DrawMode mode, gfx::IndexVectorBasePtr indexes, const SegmentBase* segments, const std::size_t segmentCount) { + assert(indexes && indexes->elements()); impl->sharedIndexes = std::move(indexes); for (std::size_t i = 0; i < segmentCount; ++i) { const auto& seg = segments[i]; diff --git a/src/mbgl/gfx/index_vector.hpp b/src/mbgl/gfx/index_vector.hpp index f47b14a30..f5befbf5d 100644 --- a/src/mbgl/gfx/index_vector.hpp +++ b/src/mbgl/gfx/index_vector.hpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include namespace mbgl { namespace gfx { @@ -84,6 +84,8 @@ protected: bool released = false; }; +using IndexVectorBasePtr = std::shared_ptr; + template class IndexVector final : public IndexVectorBase { public: diff --git a/src/mbgl/gfx/render_pass.hpp b/src/mbgl/gfx/render_pass.hpp index 8ceb61da7..b65eea4cc 100644 --- a/src/mbgl/gfx/render_pass.hpp +++ b/src/mbgl/gfx/render_pass.hpp @@ -4,7 +4,6 @@ #include #include -#include namespace mbgl { namespace gfx { @@ -26,6 +25,7 @@ protected: friend class DebugGroup; virtual void pushDebugGroup(const char* name) = 0; virtual void popDebugGroup() = 0; + virtual void addDebugSignpost(const char*) {} public: virtual ~RenderPass() = default; diff --git a/src/mbgl/gfx/upload_pass.hpp b/src/mbgl/gfx/upload_pass.hpp index 51e3fe1ea..d9676ddb4 100644 --- a/src/mbgl/gfx/upload_pass.hpp +++ b/src/mbgl/gfx/upload_pass.hpp @@ -15,6 +15,7 @@ #endif #include +#include #include namespace mbgl { @@ -43,6 +44,7 @@ public: UploadPass& operator=(const UploadPass&) = delete; DebugGroup createDebugGroup(const char* name) { return {*this, name}; } + DebugGroup createDebugGroup(std::string_view name) { return createDebugGroup(name.data()); } #if MLN_DRAWABLE_RENDERER virtual Context& getContext() = 0; diff --git a/src/mbgl/gfx/vertex_attribute.cpp b/src/mbgl/gfx/vertex_attribute.cpp index 198d510af..cee7add99 100644 --- a/src/mbgl/gfx/vertex_attribute.cpp +++ b/src/mbgl/gfx/vertex_attribute.cpp @@ -9,6 +9,10 @@ namespace mbgl { namespace gfx { +namespace { +const UniqueVertexAttribute nullref; +} // namespace + std::size_t VertexAttribute::getCount() const { return sharedRawData ? sharedRawData->getRawCount() : items.size(); } @@ -90,5 +94,15 @@ void VertexAttributeArray::resolve(const VertexAttributeArray& overrides, Resolv } } +const UniqueVertexAttribute& VertexAttributeArray::add(std::string name, std::unique_ptr&& attr) { + const auto result = attrs.insert(std::make_pair(std::move(name), std::unique_ptr())); + if (result.second) { + result.first->second = std::move(attr); + return result.first->second; + } else { + return nullref; + } +} + } // namespace gfx } // namespace mbgl diff --git a/src/mbgl/gfx/vertex_vector.hpp b/src/mbgl/gfx/vertex_vector.hpp index f18c47e13..1066b1f58 100644 --- a/src/mbgl/gfx/vertex_vector.hpp +++ b/src/mbgl/gfx/vertex_vector.hpp @@ -2,8 +2,8 @@ #include -#include #include +#include namespace mbgl { namespace gfx { diff --git a/src/mbgl/gl/command_encoder.cpp b/src/mbgl/gl/command_encoder.cpp index 486096e72..56c96dd85 100644 --- a/src/mbgl/gl/command_encoder.cpp +++ b/src/mbgl/gl/command_encoder.cpp @@ -16,7 +16,7 @@ CommandEncoder::~CommandEncoder() { context.performCleanup(); } -std::unique_ptr CommandEncoder::createUploadPass(const char* name) { +std::unique_ptr CommandEncoder::createUploadPass(const char* name, gfx::Renderable&) { return std::make_unique(*this, name); } diff --git a/src/mbgl/gl/command_encoder.hpp b/src/mbgl/gl/command_encoder.hpp index 8c3e57545..c594bc1fc 100644 --- a/src/mbgl/gl/command_encoder.hpp +++ b/src/mbgl/gl/command_encoder.hpp @@ -17,7 +17,7 @@ public: friend class UploadPass; friend class RenderPass; - std::unique_ptr createUploadPass(const char* name) override; + std::unique_ptr createUploadPass(const char* name, gfx::Renderable&) override; std::unique_ptr createRenderPass(const char* name, const gfx::RenderPassDescriptor&) override; void present(gfx::Renderable&) override; diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index a97dd2a23..e0d089a09 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -480,8 +480,11 @@ gfx::UniformBufferPtr Context::createUniformBuffer(const void* data, std::size_t gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) { std::vector emptyProperties(0); - return std::static_pointer_cast( - shaders.getShaderGroup(name)->getOrCreateShader(*this, emptyProperties)); + auto shaderGroup = shaders.getShaderGroup(name); + if (!shaderGroup) { + return nullptr; + } + return std::static_pointer_cast(shaderGroup->getOrCreateShader(*this, emptyProperties)); } TileLayerGroupPtr Context::createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) { diff --git a/src/mbgl/gl/drawable_gl.cpp b/src/mbgl/gl/drawable_gl.cpp index afce5d540..b6cbcaacb 100644 --- a/src/mbgl/gl/drawable_gl.cpp +++ b/src/mbgl/gl/drawable_gl.cpp @@ -17,6 +17,7 @@ DrawableGL::DrawableGL(std::string name_) impl(std::make_unique()) {} DrawableGL::~DrawableGL() { + impl->indexBuffer = {0, nullptr}; impl->attributeBuffers.clear(); } diff --git a/src/mbgl/gl/drawable_gl_impl.hpp b/src/mbgl/gl/drawable_gl_impl.hpp index d2288b4ef..2caa19d35 100644 --- a/src/mbgl/gl/drawable_gl_impl.hpp +++ b/src/mbgl/gl/drawable_gl_impl.hpp @@ -40,6 +40,7 @@ public: VertexAttributeArrayGL vertexAttributes; + gfx::IndexBuffer indexBuffer = {0, nullptr}; std::vector attributeBuffers; UniformBufferArrayGL uniformBuffers; diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index 0e6f0ab9a..f44bb7392 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -52,22 +52,32 @@ public: static std::unique_ptr createInstance(gl::Context& context, const ProgramParameters& programParameters, const std::string& additionalDefines) { +#if MLN_RENDER_BACKEND_OPENGL + constexpr auto backend = gfx::Backend::Type::OpenGL; +#elif MLN_RENDER_BACKEND_METAL + constexpr auto backend = gfx::Backend::Type::Metal; +#endif + +#if MLN_RENDER_BACKEND_METAL + return std::make_unique(context); +#else // Compile the shader std::initializer_list vertexSource = { "#version 300 es\n", - programParameters.getDefines().c_str(), + programParameters.getDefinesString().c_str(), additionalDefines.c_str(), - shaders::ShaderSource::vertex, + shaders::ShaderSource::vertex, programParameters.vertexSource(gfx::Backend::Type::OpenGL).c_str()}; std::initializer_list fragmentSource = { "#version 300 es\n", - programParameters.getDefines().c_str(), + programParameters.getDefinesString().c_str(), additionalDefines.c_str(), - shaders::ShaderSource::fragment, + shaders::ShaderSource::fragment, programParameters.fragmentSource(gfx::Backend::Type::OpenGL).c_str()}; return std::make_unique(context, vertexSource, fragmentSource); +#endif } UniqueProgram program; diff --git a/src/mbgl/gl/uniform_buffer_gl.cpp b/src/mbgl/gl/uniform_buffer_gl.cpp index d89aedb89..b2df0c20f 100644 --- a/src/mbgl/gl/uniform_buffer_gl.cpp +++ b/src/mbgl/gl/uniform_buffer_gl.cpp @@ -28,7 +28,7 @@ UniformBufferGL::~UniformBufferGL() { } void UniformBufferGL::update(const void* data_, std::size_t size_) { - assert(size == size_); // && size == data.size()); + assert(size == size_); if (size != size_) { Log::Error( Event::General, diff --git a/src/mbgl/mtl/buffer_resource.cpp b/src/mbgl/mtl/buffer_resource.cpp new file mode 100644 index 000000000..40b97e897 --- /dev/null +++ b/src/mbgl/mtl/buffer_resource.cpp @@ -0,0 +1,44 @@ +#include + +#include + +namespace mbgl { +namespace mtl { + +BufferResource::BufferResource(MTLDevicePtr device_, const void* data, std::size_t size, MTL::ResourceOptions usage_) + : device(std::move(device_)), + usage(usage_) { + if (data && size) { + buffer = NS::TransferPtr(device->newBuffer(data, static_cast(size), usage)); + } else { + buffer = NS::TransferPtr(device->newBuffer(static_cast(size), usage)); + } +} + +BufferResource::BufferResource(const BufferResource& other) + : device(other.device), + usage(other.usage) { + if (other.buffer) { + buffer = NS::TransferPtr(device->newBuffer(other.buffer->contents(), other.buffer->length(), other.usage)); + } +} + +BufferResource::BufferResource(BufferResource&& other) + : device(std::move(other.device)), + buffer(std::move(other.buffer)), + usage(other.usage) {} + +void BufferResource::update(const void* data, std::size_t size, std::size_t offset) { + assert(buffer && (data || size == 0)); + if (buffer && data && size > 0) { + assert(buffer->contents()); + if (void* content = buffer->contents()) { + const auto size_ = std::min(size, static_cast(buffer->length()) - offset); + assert(size == size_); + std::memcpy(static_cast(content) + offset, data, size_); + } + } +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/command_encoder.cpp b/src/mbgl/mtl/command_encoder.cpp new file mode 100644 index 000000000..b7f7602e0 --- /dev/null +++ b/src/mbgl/mtl/command_encoder.cpp @@ -0,0 +1,92 @@ +#include + +#include +#include +#include +#include + +#include + +#include + +namespace mbgl { +namespace mtl { + +CommandEncoder::CommandEncoder(Context& context_) + : context(context_) {} + +CommandEncoder::~CommandEncoder() { + context.performCleanup(); +} + +std::unique_ptr CommandEncoder::createUploadPass(const char* name, gfx::Renderable& renderable) { + return std::make_unique(renderable, *this, name); +} + +std::unique_ptr CommandEncoder::createRenderPass(const char* name, + const gfx::RenderPassDescriptor& descriptor) { + return std::make_unique(*this, name, descriptor); +} + +void CommandEncoder::present(gfx::Renderable& renderable) { + renderable.getResource().swap(); +} + +void CommandEncoder::pushDebugGroup(const char* name) { + // Debug groups exist in MTLBuffer and MTLCommandEncoder, but these are associated with the + // renderable provided in the RenderPassDescriptor, and so may not have been created yet. + // Instead, maintain a stack of names and push them to each render pass as we create it. + debugGroupNames.push_back({name ? name : std::string(), renderPasses.size(), uploadPasses.size()}); + + // Apply it to any groups that are already active + for (auto* pass : renderPasses) { + renderDebugGroups.emplace_back(gfx::DebugGroup{*pass, name}); + } + for (auto* pass : uploadPasses) { + uploadDebugGroups.emplace_back(gfx::DebugGroup{*pass, name}); + } +} + +void CommandEncoder::popDebugGroup() { + assert(!debugGroupNames.empty()); + if (!debugGroupNames.empty()) { + // Pop the entries we added for each active encoder when this item was added + for (std::size_t i = 0; i < debugGroupNames.back().renderGroups; ++i) { + assert(!renderDebugGroups.empty()); + if (!renderDebugGroups.empty()) { + renderDebugGroups.pop_back(); + } + } + for (std::size_t i = 0; i < debugGroupNames.back().uploadGroups; ++i) { + assert(!uploadDebugGroups.empty()); + if (!uploadDebugGroups.empty()) { + uploadDebugGroups.pop_back(); + } + } + + debugGroupNames.pop_back(); + } +} + +void CommandEncoder::trackRenderPass(RenderPass* pass) { + if (pass) { + renderPasses.insert(pass); + } +} + +void CommandEncoder::forgetRenderPass(RenderPass* pass) { + renderPasses.erase(pass); +} + +void CommandEncoder::trackUploadPass(UploadPass* pass) { + if (pass) { + uploadPasses.insert(pass); + } +} + +void CommandEncoder::forgetUploadPass(UploadPass* pass) { + uploadPasses.erase(pass); +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/context.cpp b/src/mbgl/mtl/context.cpp new file mode 100644 index 000000000..be3c3510f --- /dev/null +++ b/src/mbgl/mtl/context.cpp @@ -0,0 +1,210 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +namespace mbgl { +namespace mtl { + +// Maximum number of vertex attributes, per vertex descriptor +// 31 for Apple2-8, Mac2, per https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf +constexpr uint32_t maximumVertexBindingCount = 31; + +Context::Context(RendererBackend& backend_) + : gfx::Context(mtl::maximumVertexBindingCount), + backend(backend_), + stats() {} + +Context::~Context() noexcept { + if (cleanupOnDestruction) { + performCleanup(); + assert(stats.isZero()); + } +} + +std::unique_ptr Context::createCommandEncoder() { + return std::make_unique(*this); +} + +BufferResource Context::createBuffer(const void* data, std::size_t size, gfx::BufferUsageType) const { + return {backend.getDevice(), data, size, MTL::ResourceStorageModeShared}; +} + +UniqueShaderProgram Context::createProgram(std::string name, + const std::string_view source, + const std::string_view vertexName, + const std::string_view fragmentName, + const ProgramParameters& programParameters, + const std::unordered_map& additionalDefines) { + const auto pool = NS::TransferPtr(NS::AutoreleasePool::alloc()->init()); + + // No NSMutableDictionary? + const auto& programDefines = programParameters.getDefines(); + const auto numDefines = programDefines.size() + additionalDefines.size(); + + std::vector rawDefines; + rawDefines.reserve(2 * numDefines); + const auto addDefine = [&rawDefines](const auto& pair) { + auto* nsKey = NS::String::string(pair.first.data(), NS::UTF8StringEncoding); + auto* nsVal = NS::String::string(pair.second.data(), NS::UTF8StringEncoding); + rawDefines.insert(std::next(rawDefines.begin(), rawDefines.size() / 2), nsKey); + rawDefines.insert(rawDefines.end(), nsVal); + }; + std::for_each(programDefines.begin(), programDefines.end(), addDefine); + std::for_each(additionalDefines.begin(), additionalDefines.end(), addDefine); + + const auto nsDefines = NS::Dictionary::dictionary( + &rawDefines[numDefines], rawDefines.data(), static_cast(numDefines)); + rawDefines.clear(); + + auto options = NS::TransferPtr(MTL::CompileOptions::alloc()->init()); + options->setPreprocessorMacros(nsDefines); + options->setFastMathEnabled(true); + options->setLanguageVersion(MTL::LanguageVersion2_1); + + // TODO: Compile common code into a `LibraryTypeDynamic` to be used by other shaders + // instead of duplicating that code in each and every shader compilation. + options->setLibraryType(MTL::LibraryTypeExecutable); + + // Allows use of the [[invariant]] attribute on position outputs to + // guarantee that the GPU performs the calculations the same way. + options->setPreserveInvariance(true); + + // TODO: Allow use of `LibraryOptimizationLevelSize` which "may also reduce compile time" + // requires a check for iOS 16+ + // options->setOptimizationLevel(MTL::LibraryOptimizationLevelDefault); + + NS::Error* error = nullptr; + NS::String* nsSource = NS::String::string(source.data(), NS::UTF8StringEncoding); + + const auto& device = backend.getDevice(); + MTL::Library* library = device->newLibrary(nsSource, options.get(), &error); + if (!library || error) { + const auto errPtr = error ? error->localizedDescription()->utf8String() : nullptr; + const auto errStr = (errPtr && errPtr[0]) ? ": " + std::string(errPtr) : std::string(); + Log::Error(Event::Shader, name + " compile failed" + errStr); + assert(false); + return nullptr; + } + + const auto nsVertName = NS::String::string(vertexName.data(), NS::UTF8StringEncoding); + NS::SharedPtr vertexFunction = NS::RetainPtr(library->newFunction(nsVertName)); + if (!vertexFunction) { + Log::Error(Event::Shader, name + " missing vertex function " + vertexName.data()); + assert(false); + return nullptr; + } + + // fragment function is optional + NS::SharedPtr fragmentFunction; + if (!fragmentName.empty()) { + const auto nsFragName = NS::String::string(fragmentName.data(), NS::UTF8StringEncoding); + fragmentFunction = NS::RetainPtr(library->newFunction(nsFragName)); + if (!fragmentFunction) { + Log::Error(Event::Shader, name + " missing fragment function " + fragmentName.data()); + assert(false); + return nullptr; + } + } + + return std::make_unique( + std::move(name), backend, std::move(vertexFunction), std::move(fragmentFunction)); +} + +MTLTexturePtr Context::createMetalTexture(MTLTextureDescriptorPtr textureDescriptor) const { + return NS::TransferPtr(backend.getDevice()->newTexture(textureDescriptor.get())); +} + +MTLSamplerStatePtr Context::createMetalSamplerState(MTLSamplerDescriptorPtr samplerDescriptor) const { + return NS::TransferPtr(backend.getDevice()->newSamplerState(samplerDescriptor.get())); +} + +gfx::UniqueDrawableBuilder Context::createDrawableBuilder(std::string name) { + return std::make_unique(std::move(name)); +} + +gfx::UniformBufferPtr Context::createUniformBuffer(const void* data, std::size_t size) { + return std::make_shared(createBuffer(data, size, gfx::BufferUsageType::StaticDraw)); +} + +gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) { + std::vector emptyProperties(0); + auto shaderGroup = shaders.getShaderGroup(name); + if (!shaderGroup) { + return nullptr; + } + return std::static_pointer_cast(shaderGroup->getOrCreateShader(*this, emptyProperties)); +} + +TileLayerGroupPtr Context::createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) { + return std::make_shared(layerIndex, initialCapacity, std::move(name)); +} + +LayerGroupPtr Context::createLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) { + return std::make_shared(layerIndex, initialCapacity, name); +} + +gfx::Texture2DPtr Context::createTexture2D() { + return std::make_shared(*this); +} + +RenderTargetPtr Context::createRenderTarget(const Size size, const gfx::TextureChannelDataType type) { + assert(false); + return nullptr; +} + +void Context::resetState(gfx::DepthMode depthMode, gfx::ColorMode colorMode) {} + +void Context::setDirtyState() {} + +std::unique_ptr Context::createOffscreenTexture(Size, gfx::TextureChannelDataType) { + assert(false); + return nullptr; +} + +std::unique_ptr Context::createTextureResource(Size, + gfx::TexturePixelType, + gfx::TextureChannelDataType) { + assert(false); + return nullptr; +} + +std::unique_ptr Context::createRenderbufferResource(gfx::RenderbufferPixelType, Size size) { + return std::make_unique(); +} + +std::unique_ptr Context::createDrawScopeResource() { + assert(false); + return nullptr; +} + +#if !defined(NDEBUG) +void Context::visualizeStencilBuffer() {} + +void Context::visualizeDepthBuffer(float depthRangeSize) {} +#endif // !defined(NDEBUG) + +void Context::clearStencilBuffer(int32_t) {} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/drawable.cpp b/src/mbgl/mtl/drawable.cpp new file mode 100644 index 000000000..4b071ae48 --- /dev/null +++ b/src/mbgl/mtl/drawable.cpp @@ -0,0 +1,517 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +namespace mbgl { +namespace mtl { + +struct IndexBuffer : public gfx::IndexBufferBase { + IndexBuffer(std::unique_ptr&& buffer_) + : buffer(std::move(buffer_)) {} + ~IndexBuffer() override = default; + + std::unique_ptr buffer; +}; + +Drawable::Drawable(std::string name_) + : gfx::Drawable(std::move(name_)), + impl(std::make_unique()) {} + +Drawable::~Drawable() {} + +namespace { +// Downcast a generic vertex buffer resource and extract the Metal buffer +MTL::Buffer* getMetalBuffer(const gfx::VertexBufferResource* resource_) { + if (const auto* resource = static_cast(resource_)) { + if (const auto& bufferResource = resource->get()) { + return bufferResource.getMetalBuffer().get(); + } + } + return nullptr; +} + +#if !defined(NDEBUG) +std::size_t getBufferSize(const gfx::VertexBufferResource* resource_) { + if (const auto* resource = static_cast(resource_)) { + if (const auto& bufferResource = resource->get()) { + return bufferResource.getSizeInBytes(); + } + } + return 0UL; +} +#endif // !defined(NDEBUG) + +MTL::PrimitiveType getPrimitiveType(const gfx::DrawModeType type) { + switch (type) { + default: + assert(false); + [[fallthrough]]; + case gfx::DrawModeType::Points: + return MTL::PrimitiveType::PrimitiveTypePoint; + case gfx::DrawModeType::Lines: + return MTL::PrimitiveType::PrimitiveTypeLine; + case gfx::DrawModeType::Triangles: + return MTL::PrimitiveType::PrimitiveTypeTriangle; + } +} + +#if !defined(NDEBUG) +std::string debugLabel(const gfx::Drawable& drawable) { + std::string result = drawable.getName(); + if (const auto& tileID = drawable.getTileID()) { + result.append("/tile=").append(util::toString(*tileID)); + } + return result; +} +#endif // !defined(NDEBUG) + +MTL::Buffer* getMetalBuffer(const gfx::IndexVectorBasePtr& indexes) { + if (const auto* buf0 = indexes->getBuffer()) { + if (const auto* buf1 = static_cast(buf0)->buffer.get()) { + const auto& buf2 = buf1->getResource().get(); + return buf2.getMetalBuffer().get(); + } + } + return nullptr; +} + +} // namespace + +void Drawable::draw(PaintParameters& parameters) const { + if (isCustom) { + return; + } + + const auto& context = static_cast(parameters.context); + const auto& renderPass = static_cast(*parameters.renderPass); + const auto& encoder = renderPass.getMetalEncoder(); + if (!encoder) { + assert(false); + return; + } + + if (!shader) { + Log::Warning(Event::General, "Missing shader for drawable " + util::toString(getID()) + "/" + getName()); + assert(false); + return; + } + + const auto& shaderMTL = static_cast(*shader); + +#if !defined(NDEBUG) + const auto debugGroup = parameters.encoder->createDebugGroup(debugLabel(*this)); +#endif + + /* + context.setDepthMode(getIs3D() ? parameters.depthModeFor3D() + : parameters.depthModeForSublayer(getSubLayerIndex(), getDepthType())); + + // force disable depth test for debugging + // context.setDepthMode({gfx::DepthFunctionType::Always, gfx::DepthMaskType::ReadOnly, {0,1}}); + + // For 3D mode, stenciling is handled by the layer group + if (!is3D) { + context.setStencilMode(makeStencilMode(parameters)); + } + + context.setColorMode(getColorMode()); + context.setCullFaceMode(getCullFaceMode()); + + */ + + bindAttributes(renderPass); + bindUniformBuffers(renderPass); + bindTextures(renderPass); + + const auto& renderPassDescriptor = renderPass.getDescriptor(); + + if (!impl->indexes->getBuffer() || impl->indexes->getDirty()) { + assert(!"Index buffer not uploaded"); + return; + } + + const auto* indexBuffer = getMetalBuffer(impl->indexes); + if (!indexBuffer || impl->indexes->getDirty()) { + assert(!"Index buffer not uploaded"); + return; + } + + if (!impl->vertexDesc) { + assert(!"Vertex descriptor missing"); + } + + for (const auto& seg_ : impl->segments) { + const auto& segment = static_cast(*seg_); + const auto& mlSegment = segment.getSegment(); + if (mlSegment.indexLength > 0) { + const auto& mode = segment.getMode(); + if (auto state = shaderMTL.getRenderPipelineState(renderPassDescriptor, impl->vertexDesc, getColorMode())) { + encoder->setRenderPipelineState(state.get()); + } else { + assert(!"Failed to create render pipeline state"); + continue; + } + + const auto primitiveType = getPrimitiveType(mode.type); + constexpr auto indexType = MTL::IndexType::IndexTypeUInt16; + constexpr auto indexSize = sizeof(std::uint16_t); + constexpr NS::UInteger instanceCount = 1; + constexpr NS::UInteger baseInstance = 0; + const NS::UInteger indexOffset = static_cast(indexSize * + mlSegment.indexOffset); // in bytes, not indexes + const NS::Integer baseVertex = static_cast(mlSegment.vertexOffset); + encoder->drawIndexedPrimitives(primitiveType, + mlSegment.indexLength, + indexType, + indexBuffer, + indexOffset, + instanceCount, + baseVertex, + baseInstance); + } + } + + unbindTextures(renderPass); + unbindUniformBuffers(renderPass); + unbindAttributes(renderPass); +} + +void Drawable::setIndexData(gfx::IndexVectorBasePtr indexes, std::vector segments) { + assert(indexes && indexes->elements()); + impl->indexes = std::move(indexes); + impl->segments = std::move(segments); +} + +void Drawable::setVertices(std::vector&& data, std::size_t count, gfx::AttributeDataType type) { + impl->vertexCount = count; + impl->vertexType = type; + + if (count && type != gfx::AttributeDataType::Invalid && !data.empty() && !impl->vertexAttrName.empty()) { + if (auto& attrib = impl->vertexAttributes.getOrAdd(impl->vertexAttrName, /*index=*/-1, type)) { + attrib->setRawData(std::move(data)); + attrib->setStride(VertexAttribute::getStrideOf(type)); + } else { + Log::Warning(Event::General, "Vertex attribute type mismatch: " + name + " / " + impl->vertexAttrName); + assert(false); + } + } +} + +const gfx::VertexAttributeArray& Drawable::getVertexAttributes() const { + return impl->vertexAttributes; +} + +gfx::VertexAttributeArray& Drawable::mutableVertexAttributes() { + return impl->vertexAttributes; +} + +void Drawable::setVertexAttributes(const gfx::VertexAttributeArray& value) { + impl->vertexAttributes = static_cast(value); +} +void Drawable::setVertexAttributes(gfx::VertexAttributeArray&& value) { + impl->vertexAttributes = std::move(static_cast(value)); +} + +const gfx::UniformBufferArray& Drawable::getUniformBuffers() const { + return impl->uniformBuffers; +} + +gfx::UniformBufferArray& Drawable::mutableUniformBuffers() { + return impl->uniformBuffers; +} + +void Drawable::setVertexAttrName(std::string value) { + impl->vertexAttrName = std::move(value); +} + +void Drawable::bindAttributes(const RenderPass& renderPass) const { + const auto& encoder = renderPass.getMetalEncoder(); + + NS::UInteger attributeIndex = 0; + for (const auto& binding : attributeBindings) { + if (const auto buffer = getMetalBuffer(binding ? binding->vertexBufferResource : nullptr)) { + assert(getBufferSize(binding->vertexBufferResource) == binding->vertexStride * impl->vertexCount); + encoder->setVertexBuffer(buffer, /*offset=*/0, attributeIndex); + } else if (const auto buffer = getMetalBuffer(impl->noBindingBuffer.get())) { + encoder->setVertexBuffer(buffer, /*offset=*/0, attributeIndex); + } + attributeIndex += 1; + } +} + +void Drawable::unbindAttributes(const RenderPass& renderPass) const { + const auto& encoder = renderPass.getMetalEncoder(); + + NS::UInteger attributeIndex = 0; + for (const auto& binding : attributeBindings) { + encoder->setVertexBuffer(nullptr, /*offset=*/0, attributeIndex); + attributeIndex += 1; + } +} + +void Drawable::bindUniformBuffers(const RenderPass& renderPass) const { + if (shader) { + const auto& shaderMTL = static_cast(*shader); + const auto& encoder = renderPass.getMetalEncoder(); + for (const auto& element : shaderMTL.getUniformBlocks().getMap()) { + const auto& uniformBuffer = getUniformBuffers().get(element.first); + if (!uniformBuffer) { + using namespace std::string_literals; + Log::Error(Event::General, + "Drawable::bindUniformBuffers: UBO "s + element.first + " not found. skipping."); + assert(false); + continue; + } + + const auto& buffer = static_cast(*uniformBuffer.get()); + const auto& bufferMTL = buffer.getBufferResource().getMetalBuffer().get(); + + const auto& block = static_cast(*element.second); + const auto index = block.getIndex(); + + if (block.getBindVertex()) { + encoder->setVertexBuffer(bufferMTL, /*offset=*/0, index); + } + if (block.getBindFragment()) { + encoder->setFragmentBuffer(bufferMTL, /*offset=*/0, index); + } + } + } +} + +void Drawable::unbindUniformBuffers(const RenderPass& renderPass) const { + if (shader) { + const auto& shaderMTL = static_cast(*shader); + const auto& encoder = renderPass.getMetalEncoder(); + for (const auto& element : shaderMTL.getUniformBlocks().getMap()) { + const auto index = element.second->getIndex(); + encoder->setVertexBuffer(nullptr, 0, index); + } + } +} + +void Drawable::bindTextures(const RenderPass& renderPass) const { + for (const auto& pair : textures) { + if (const auto& tex = pair.second) { + const auto& location = pair.first; + std::static_pointer_cast(tex)->bind(renderPass, location); + } + } +} + +void Drawable::unbindTextures(const RenderPass& renderPass) const { + for (const auto& pair : textures) { + if (const auto& tex = pair.second) { + const auto& location = pair.first; + std::static_pointer_cast(tex)->unbind(renderPass, location); + } + } +} + +void Drawable::uploadTextures() const { + for (const auto& pair : textures) { + if (const auto& tex = pair.second) { + std::static_pointer_cast(tex)->upload(); + } + } +} + +namespace { +MTL::VertexFormat mtlVertexTypeOf(gfx::AttributeDataType type) { + switch (type) { + case gfx::AttributeDataType::Byte: + return MTL::VertexFormatChar; + case gfx::AttributeDataType::Byte2: + return MTL::VertexFormatChar2; + case gfx::AttributeDataType::Byte3: + return MTL::VertexFormatChar3; + case gfx::AttributeDataType::Byte4: + return MTL::VertexFormatChar4; + case gfx::AttributeDataType::UByte: + return MTL::VertexFormatUChar; + case gfx::AttributeDataType::UByte2: + return MTL::VertexFormatUChar2; + case gfx::AttributeDataType::UByte3: + return MTL::VertexFormatUChar3; + case gfx::AttributeDataType::UByte4: + return MTL::VertexFormatUChar4; + case gfx::AttributeDataType::Short: + return MTL::VertexFormatShort; + case gfx::AttributeDataType::Short2: + return MTL::VertexFormatShort2; + case gfx::AttributeDataType::Short3: + return MTL::VertexFormatShort3; + case gfx::AttributeDataType::Short4: + return MTL::VertexFormatShort4; + case gfx::AttributeDataType::UShort: + return MTL::VertexFormatUShort; + case gfx::AttributeDataType::UShort2: + return MTL::VertexFormatUShort2; + case gfx::AttributeDataType::UShort3: + return MTL::VertexFormatUShort3; + case gfx::AttributeDataType::UShort4: + return MTL::VertexFormatUShort4; + // case gfx::AttributeDataType::UShort8: return MTL::VertexFormatUShort8; + case gfx::AttributeDataType::Int: + return MTL::VertexFormatInt; + case gfx::AttributeDataType::Int2: + return MTL::VertexFormatInt2; + case gfx::AttributeDataType::Int3: + return MTL::VertexFormatInt3; + case gfx::AttributeDataType::Int4: + return MTL::VertexFormatInt4; + case gfx::AttributeDataType::UInt: + return MTL::VertexFormatUInt; + case gfx::AttributeDataType::UInt2: + return MTL::VertexFormatUInt2; + case gfx::AttributeDataType::UInt3: + return MTL::VertexFormatUInt3; + case gfx::AttributeDataType::UInt4: + return MTL::VertexFormatUInt4; + case gfx::AttributeDataType::Float: + return MTL::VertexFormatFloat; + case gfx::AttributeDataType::Float2: + return MTL::VertexFormatFloat2; + case gfx::AttributeDataType::Float3: + return MTL::VertexFormatFloat3; + case gfx::AttributeDataType::Float4: + return MTL::VertexFormatFloat4; + default: + assert(!"Unsupported vertex attribute format"); + return MTL::VertexFormatInvalid; + } +} +} // namespace + +void Drawable::upload(gfx::UploadPass& uploadPass_) { + if (!shader) { + Log::Warning(Event::General, "Missing shader for drawable " + util::toString(getID()) + "/" + getName()); + assert(false); + return; + } + const auto& shaderMTL = static_cast(*shader); + const auto& shaderUniforms = shaderMTL.getUniformBlocks(); + + auto& uploadPass = static_cast(uploadPass_); + auto& contextBase = uploadPass.getContext(); + auto& context = static_cast(contextBase); + constexpr auto usage = gfx::BufferUsageType::StaticDraw; + + if (!impl->indexes || !impl->indexes->bytes()) { + assert(!"Missing index data"); + return; + } + + if (impl->indexes->getDirty()) { + auto indexBufferResource{ + uploadPass.createIndexBufferResource(impl->indexes->data(), impl->indexes->bytes(), usage)}; + auto indexBuffer = std::make_unique(impl->indexes->elements(), + std::move(indexBufferResource)); + auto buffer = std::make_unique(std::move(indexBuffer)); + + impl->indexes->setBuffer(std::move(buffer)); + impl->indexes->setDirty(false); + } + + const bool buildAttribs = impl->vertexAttributes.isDirty() || !impl->vertexDesc; + + if (buildAttribs) { +#if !defined(NDEBUG) + const auto debugGroup = uploadPass.createDebugGroup(debugLabel(*this)); +#endif + + // Apply drawable values to shader defaults + std::vector> vertexBuffers; + attributeBindings = uploadPass.buildAttributeBindings(impl->vertexCount, + impl->vertexType, + /*vertexAttributeIndex=*/-1, + /*vertexData=*/{}, + shader->getVertexAttributes(), + impl->vertexAttributes, + usage, + vertexBuffers); + impl->attributeBuffers = std::move(vertexBuffers); + + impl->vertexAttributes.visitAttributes( + [](const auto&, gfx::VertexAttribute& attrib) { attrib.setDirty(false); }); + + // Create a layout descriptor for each attribute + auto vertDesc = NS::RetainPtr(MTL::VertexDescriptor::vertexDescriptor()); + + NS::UInteger index = 0; + for (auto& binding : attributeBindings) { + if (!binding) { + assert("Missing attribute binding"); + continue; + } + + if (!binding->vertexBufferResource && !impl->noBindingBuffer) { + impl->noBindingBuffer = uploadPass.createVertexBufferResource( + nullptr, 64, gfx::BufferUsageType::StaticDraw); + } + + auto attribDesc = NS::TransferPtr(MTL::VertexAttributeDescriptor::alloc()->init()); + attribDesc->setBufferIndex(index); + attribDesc->setOffset(static_cast(binding->attribute.offset)); + attribDesc->setFormat(mtlVertexTypeOf(binding->attribute.dataType)); + assert(binding->vertexStride > 0); + + auto layoutDesc = NS::TransferPtr(MTL::VertexBufferLayoutDescriptor::alloc()->init()); + layoutDesc->setStride(static_cast(binding->vertexStride)); + layoutDesc->setStepFunction(binding->vertexBufferResource ? MTL::VertexStepFunctionPerVertex + : MTL::VertexStepFunctionConstant); + layoutDesc->setStepRate(binding->vertexBufferResource ? 1 : 0); + + vertDesc->attributes()->setObject(attribDesc.get(), index); + vertDesc->layouts()->setObject(layoutDesc.get(), index); + + index += 1; + } + + impl->vertexDesc = std::move(vertDesc); + } + + const bool texturesNeedUpload = std::any_of( + textures.begin(), textures.end(), [](const auto& pair) { return pair.second && pair.second->needsUpload(); }); + + if (texturesNeedUpload) { + uploadTextures(); + } +} +/* +gfx::ColorMode Drawable::makeColorMode(PaintParameters& parameters) const { + return enableColor ? parameters.colorModeForRenderPass() : gfx::ColorMode::disabled(); +} + +gfx::StencilMode Drawable::makeStencilMode(PaintParameters& parameters) const { + if (enableStencil) { + if (!is3D && tileID) { + return parameters.stencilModeForClipping(tileID->toUnwrapped()); + } + assert(false); + } + return gfx::StencilMode::disabled(); +} +*/ +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/drawable_builder.cpp b/src/mbgl/mtl/drawable_builder.cpp new file mode 100644 index 000000000..3abde66af --- /dev/null +++ b/src/mbgl/mtl/drawable_builder.cpp @@ -0,0 +1,49 @@ +#include + +#include +#include +#include +#include +#include + +#include + +namespace mbgl { +namespace mtl { + +gfx::UniqueDrawable DrawableBuilder::createDrawable() const { + return std::make_unique(drawableName.empty() ? name : drawableName); +}; + +std::unique_ptr DrawableBuilder::createSegment(gfx::DrawMode mode, SegmentBase&& seg) { + return std::make_unique(mode, std::move(seg)); +} + +void DrawableBuilder::init() { + auto& drawable = static_cast(*currentDrawable); + + drawable.setVertexAttrName(vertexAttrName); + + if (impl->rawVerticesCount) { + auto raw = impl->rawVertices; + drawable.setVertices(std::move(raw), impl->rawVerticesCount, impl->rawVerticesType); + } else { + const auto& verts = impl->vertices.vector(); + constexpr auto vertSize = sizeof(std::remove_reference::type::value_type); + std::vector raw(verts.size() * vertSize); + std::memcpy(raw.data(), verts.data(), raw.size()); + drawable.setVertices(std::move(raw), verts.size(), gfx::AttributeDataType::Short2); + } + + if (!impl->sharedIndexes && !impl->buildIndexes.empty()) { + impl->sharedIndexes = std::make_shared(std::move(impl->buildIndexes)); + } + drawable.setIndexData(std::move(impl->sharedIndexes), std::move(impl->segments)); + + impl->buildIndexes.clear(); + impl->segments.clear(); + impl->vertices.clear(); +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/drawable_impl.hpp b/src/mbgl/mtl/drawable_impl.hpp new file mode 100644 index 000000000..faa51ad8e --- /dev/null +++ b/src/mbgl/mtl/drawable_impl.hpp @@ -0,0 +1,68 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace mbgl { +namespace mtl { + +using namespace platform; + +class Drawable::Impl final { +public: + Impl() = default; + ~Impl() = default; + + std::vector segments; + + MTLVertexDescriptorPtr vertexDesc; + + /* + std::vector textures; + */ + gfx::IndexVectorBasePtr indexes; + std::size_t vertexCount = 0; + gfx::AttributeDataType vertexType = gfx::AttributeDataType::Invalid; + gfx::VertexAttributeArray vertexAttributes; + + std::vector attributeBuffers; + + UniformBufferArray uniformBuffers; + + gfx::DepthMode depthMode = gfx::DepthMode::disabled(); + gfx::StencilMode stencilMode; + gfx::CullFaceMode cullFaceMode; + // GLfloat pointSize = 0.0f; + std::string vertexAttrName = "a_pos"; + + gfx::UniqueVertexBufferResource noBindingBuffer; +}; + +struct Drawable::DrawSegment final : public gfx::Drawable::DrawSegment { + DrawSegment(gfx::DrawMode mode_, SegmentBase&& segment_) + : gfx::Drawable::DrawSegment(mode_, std::move(segment_)) {} + ~DrawSegment() override = default; + +protected: +}; + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/drawable_mtl.cpp b/src/mbgl/mtl/drawable_mtl.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/mbgl/mtl/drawable_mtl_builder.cpp b/src/mbgl/mtl/drawable_mtl_builder.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/mbgl/mtl/drawable_mtl_tweaker.cpp b/src/mbgl/mtl/drawable_mtl_tweaker.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/mbgl/mtl/layer_group.cpp b/src/mbgl/mtl/layer_group.cpp new file mode 100644 index 000000000..6c1c54566 --- /dev/null +++ b/src/mbgl/mtl/layer_group.cpp @@ -0,0 +1,60 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace mbgl { +namespace mtl { + +LayerGroup::LayerGroup(int32_t layerIndex_, std::size_t initialCapacity, std::string name_) + : mbgl::LayerGroup(layerIndex_, initialCapacity, std::move(name_)) {} + +void LayerGroup::upload(gfx::UploadPass& uploadPass) { + if (!enabled) { + return; + } + +#if !defined(NDEBUG) + const auto debugGroup = uploadPass.createDebugGroup(getName() + "-upload"); +#endif + + visitDrawables([&](gfx::Drawable& drawable) { + if (drawable.getEnabled()) { + auto& drawableMTL = static_cast(drawable); + drawableMTL.upload(uploadPass); + } + }); +} + +void LayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) { + if (!enabled) { + return; + } + +#if !defined(NDEBUG) + const auto debugGroup = parameters.encoder->createDebugGroup(getName() + "-render"); +#endif + + visitDrawables([&](gfx::Drawable& drawable) { + if (!drawable.getEnabled() || !drawable.hasRenderPass(parameters.pass)) { + return; + } + + for (const auto& tweaker : drawable.getTweakers()) { + tweaker->execute(drawable, parameters); + } + + drawable.draw(parameters); + }); +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/mtl.cpp b/src/mbgl/mtl/mtl.cpp new file mode 100644 index 000000000..84777f84d --- /dev/null +++ b/src/mbgl/mtl/mtl.cpp @@ -0,0 +1,9 @@ +// metal-cpp is a header-only library. +// To generate the implementation, +// add the following code in one of your .cpp files: +#define NS_PRIVATE_IMPLEMENTATION +#define CA_PRIVATE_IMPLEMENTATION +#define MTL_PRIVATE_IMPLEMENTATION +#include +#include +#include diff --git a/src/mbgl/mtl/render_pass.cpp b/src/mbgl/mtl/render_pass.cpp new file mode 100644 index 000000000..1118e284f --- /dev/null +++ b/src/mbgl/mtl/render_pass.cpp @@ -0,0 +1,94 @@ +#include + +#include +#include +#include +#include + +#include + +namespace mbgl { +namespace mtl { + +RenderPass::RenderPass(CommandEncoder& commandEncoder_, const char* name, const gfx::RenderPassDescriptor& descriptor) + : descriptor(descriptor), + commandEncoder(commandEncoder_) { + auto& resource = descriptor.renderable.getResource(); + + if (!resource.getCommandBuffer()) { + resource.bind(); + } + + if (const auto& buffer = resource.getCommandBuffer()) { + if (auto rpd = resource.getRenderPassDescriptor()) { + if (descriptor.clearColor) { + if (auto copy = NS::TransferPtr(rpd->copy())) { + if (auto* colorTarget = copy->colorAttachments()->object(0)) { + const auto& c = *descriptor.clearColor; + colorTarget->setClearColor(MTL::ClearColor::Make(c.r, c.g, c.b, c.a)); + rpd = copy; + } + } + } + encoder = NS::RetainPtr(buffer->renderCommandEncoder(rpd.get())); + } + } + + assert(encoder); + + // Push the groups already accumulated by the encoder + commandEncoder.visitDebugGroups([this](const auto& group) { + debugGroups.emplace_back(gfx::DebugGroup{*this, group.c_str()}); + }); + + // Push the group for the name provided + debugGroups.emplace_back(gfx::DebugGroup{*this, name}); + + // Let the encoder pass along any groups pushed to it after this + commandEncoder.trackRenderPass(this); +} + +RenderPass::~RenderPass() { + commandEncoder.forgetRenderPass(this); + endEncoding(); +} + +void RenderPass::endEncoding() { + debugGroups.clear(); + + if (encoder) { + encoder->endEncoding(); + encoder.reset(); + } +} + +namespace { +constexpr auto missing = ""; +NS::String* toNSString(const char* str) { + return NS::String::string(str ? str : missing, NS::UTF8StringEncoding); +} +} // namespace + +void RenderPass::pushDebugGroup(const char* name) { + assert(encoder); + if (encoder) { + encoder->pushDebugGroup(toNSString(name)); + } +} + +void RenderPass::popDebugGroup() { + assert(encoder); + if (encoder) { + encoder->popDebugGroup(); + } +} + +void RenderPass::addDebugSignpost(const char* name) { + assert(encoder); + if (encoder) { + encoder->insertDebugSignpost(toNSString(name)); + } +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/renderer_backend.cpp b/src/mbgl/mtl/renderer_backend.cpp new file mode 100644 index 000000000..d19928a93 --- /dev/null +++ b/src/mbgl/mtl/renderer_backend.cpp @@ -0,0 +1,138 @@ +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +// ... shader_manifest.hpp +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace mbgl { +namespace mtl { + +RendererBackend::RendererBackend(const gfx::ContextMode contextMode_) + : gfx::RendererBackend(contextMode_), + device(NS::TransferPtr(MTL::CreateSystemDefaultDevice())), + commandQueue(NS::TransferPtr(device->newCommandQueue())) { + assert(device); + assert(commandQueue); +} + +RendererBackend::~RendererBackend() = default; + +std::unique_ptr RendererBackend::createContext() { + return std::make_unique(*this); +} + +PremultipliedImage RendererBackend::readFramebuffer(const Size& size) { + return PremultipliedImage(size); + // return getContext().readFramebuffer(size); +} + +void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID fbo) { + /*getContext().bindFramebuffer.setCurrentValue(fbo); + if (fbo != ImplicitFramebufferBinding) { + assert(mtl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); + }*/ +} + +void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) { + /*getContext().viewport.setCurrentValue({x, y, size}); + assert(mtl::value::Viewport::Get() == getContext().viewport.getCurrentValue());*/ +} + +void RendererBackend::assumeScissorTest(bool enabled) { + /*getContext().scissorTest.setCurrentValue(enabled); + assert(mtl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());*/ +} + +bool RendererBackend::implicitFramebufferBound() { + return false; + // return getContext().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding; +} + +void RendererBackend::setFramebufferBinding(const mtl::FramebufferID fbo) { + /*getContext().bindFramebuffer = fbo; + if (fbo != ImplicitFramebufferBinding) { + assert(mtl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); + }*/ +} + +void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) { + /*getContext().viewport = {x, y, size}; + assert(mtl::value::Viewport::Get() == getContext().viewport.getCurrentValue());*/ +} + +void RendererBackend::setScissorTest(bool enabled) { + /*getContext().scissorTest = enabled; + assert(mtl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue());*/ +} + +/// @brief Register a list of types with a shader registry instance +/// @tparam ...ShaderID Pack of BuiltIn:: shader IDs +/// @param registry A shader registry instance +/// @param programParameters ProgramParameters used to initialize each instance +template +void registerTypes(gfx::ShaderRegistry& registry, const ProgramParameters& programParameters) { + /// The following fold expression will create a shader for every type + /// in the parameter pack and register it with the shader registry. + + /// Registration calls are wrapped in a lambda that throws on registration + /// failure, we shouldn't expect registration to faill unless the shader + /// registry instance provided already has conflicting programs present. + ( + [&]() { + using namespace std::string_literals; + using ShaderClass = shaders::ShaderSource; + auto group = std::make_shared>(programParameters); + if (!registry.registerShaderGroup(std::move(group), ShaderClass::name)) { + assert(!"duplicate shader group"); + throw std::runtime_error("Failed to register "s + ShaderClass::name + " with shader registry!"); + } + }(), + ...); +} + +void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramParameters& programParameters) { + registerTypes(shaders, programParameters); +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/texture2d.cpp b/src/mbgl/mtl/texture2d.cpp new file mode 100644 index 000000000..19239019f --- /dev/null +++ b/src/mbgl/mtl/texture2d.cpp @@ -0,0 +1,201 @@ +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace mbgl { +namespace mtl { + +Texture2D::Texture2D(Context& context_) + : context(context_) {} + +Texture2D::~Texture2D() {} + +gfx::Texture2D& Texture2D::setSamplerConfiguration(const SamplerState& samplerState_) noexcept { + samplerState = samplerState_; + samplerStateDirty = true; + return *this; +} + +gfx::Texture2D& Texture2D::setFormat(gfx::TexturePixelType pixelFormat_, + gfx::TextureChannelDataType channelType_) noexcept { + if (pixelFormat_ == pixelFormat && channelType_ == channelType) { + return *this; + } + pixelFormat = pixelFormat_; + channelType = channelType_; + textureDirty = true; + return *this; +} + +gfx::Texture2D& Texture2D::setSize(mbgl::Size size_) noexcept { + if (size_ == size) { + return *this; + } + size = size_; + textureDirty = true; + return *this; +} + +gfx::Texture2D& Texture2D::setImage(std::shared_ptr image_) noexcept { + image = std::move(image_); + return *this; +} + +size_t Texture2D::getDataSize() const noexcept { + return size.width * size.height * getPixelStride(); +} + +size_t Texture2D::getPixelStride() const noexcept { + switch (channelType) { + case gfx::TextureChannelDataType::UnsignedByte: + return 1 * numChannels(); + case gfx::TextureChannelDataType::HalfFloat: + return 2 * numChannels(); + } +} + +size_t Texture2D::numChannels() const noexcept { + switch (pixelFormat) { + case gfx::TexturePixelType::RGBA: + return 4; + case gfx::TexturePixelType::Alpha: + return 1; + default: + return 0; + } +} + +MTL::PixelFormat Texture2D::getMetalPixelFormat() const noexcept { + switch (channelType) { + case gfx::TextureChannelDataType::UnsignedByte: + switch (pixelFormat) { + case gfx::TexturePixelType::RGBA: + return MTL::PixelFormat::PixelFormatRGBA8Unorm; + case gfx::TexturePixelType::Alpha: + return MTL::PixelFormat::PixelFormatA8Unorm; + default: + assert(false); + return MTL::PixelFormat::PixelFormatInvalid; + } + case gfx::TextureChannelDataType::HalfFloat: + switch (pixelFormat) { + case gfx::TexturePixelType::RGBA: + return MTL::PixelFormat::PixelFormatRGBA16Float; + case gfx::TexturePixelType::Alpha: + return MTL::PixelFormat::PixelFormatR16Float; + default: + assert(false); + return MTL::PixelFormat::PixelFormatInvalid; + } + default: + assert(false); + return MTL::PixelFormat::PixelFormatInvalid; + } +} + +void Texture2D::createMetalTexture() noexcept { + if (size == Size{0, 0}) { + return; + } + metalTexture.reset(); + + const auto format = getMetalPixelFormat(); + if (format == MTL::PixelFormat::PixelFormatInvalid) { + return; + } + + // Create a new texture object + if (auto textureDescriptor = NS::RetainPtr( + MTL::TextureDescriptor::texture2DDescriptor(format, size.width, size.height, /*mipmapped=*/false))) { + metalTexture = context.createMetalTexture(std::move(textureDescriptor)); + } + + if (metalTexture) { + textureDirty = false; + context.renderingStats().memTextures += getDataSize(); + } +} + +void Texture2D::create() noexcept { + if (textureDirty) { + createMetalTexture(); + } + if (samplerStateDirty) { + updateSamplerConfiguration(); + } +} + +void Texture2D::updateSamplerConfiguration() noexcept { + auto samplerDescriptor = NS::RetainPtr(MTL::SamplerDescriptor::alloc()->init()); + samplerDescriptor->setMinFilter(samplerState.filter == gfx::TextureFilterType::Nearest + ? MTL::SamplerMinMagFilterNearest + : MTL::SamplerMinMagFilterLinear); + samplerDescriptor->setMagFilter(samplerState.filter == gfx::TextureFilterType::Nearest + ? MTL::SamplerMinMagFilterNearest + : MTL::SamplerMinMagFilterLinear); + samplerDescriptor->setSAddressMode(samplerState.wrapU == gfx::TextureWrapType::Clamp + ? MTL::SamplerAddressModeClampToEdge + : MTL::SamplerAddressModeRepeat); + samplerDescriptor->setTAddressMode(samplerState.wrapV == gfx::TextureWrapType::Clamp + ? MTL::SamplerAddressModeClampToEdge + : MTL::SamplerAddressModeRepeat); + metalSamplerState = context.createMetalSamplerState(samplerDescriptor); +} + +void Texture2D::bind(const RenderPass& renderPass, int32_t location) noexcept { + assert(!textureDirty); + const auto& encoder = renderPass.getMetalEncoder(); + + // Update the sampler state if it was changed after resource creation + if (samplerStateDirty) { + updateSamplerConfiguration(); + } + + encoder->setFragmentTexture(metalTexture.get(), location); + encoder->setFragmentSamplerState(metalSamplerState.get(), location); +} + +void Texture2D::unbind(const RenderPass& renderPass, int32_t location) noexcept { + const auto& encoder = renderPass.getMetalEncoder(); + encoder->setFragmentTexture(nullptr, location); + encoder->setFragmentSamplerState(nullptr, location); +} + +void Texture2D::upload(const void* pixelData, const Size& size_) noexcept { + setSize(size_); + if (textureDirty) { + createMetalTexture(); + } + if (samplerStateDirty) { + updateSamplerConfiguration(); + } + if (pixelData) { + uploadSubRegion(pixelData, size, 0, 0); + } +} + +void Texture2D::uploadSubRegion(const void* pixelData, const Size& size_, uint16_t xOffset, uint16_t yOffset) noexcept { + assert(metalTexture.get()); + assert(!textureDirty); + + MTL::Region region = MTL::Region::Make2D(xOffset, yOffset, size_.width, size_.height); + NS::UInteger bytesPerRow = size_.width * getPixelStride(); + metalTexture->replaceRegion(region, 0, pixelData, bytesPerRow); +} + +void Texture2D::upload() noexcept { + if (image && image->valid()) { + setFormat(gfx::TexturePixelType::RGBA, gfx::TextureChannelDataType::UnsignedByte); + upload(image->data.get(), image->size); + image.reset(); + } +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/tile_layer_group.cpp b/src/mbgl/mtl/tile_layer_group.cpp new file mode 100644 index 000000000..b223b60e9 --- /dev/null +++ b/src/mbgl/mtl/tile_layer_group.cpp @@ -0,0 +1,113 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace mbgl { +namespace mtl { + +TileLayerGroup::TileLayerGroup(int32_t layerIndex_, std::size_t initialCapacity, std::string name_) + : mbgl::TileLayerGroup(layerIndex_, initialCapacity, std::move(name_)) {} + +void TileLayerGroup::upload(gfx::UploadPass& uploadPass) { + if (!enabled || !getDrawableCount()) { + return; + } + +#if !defined(NDEBUG) + const auto debugGroup = uploadPass.createDebugGroup(getName() + "-upload"); +#endif + + visitDrawables([&](gfx::Drawable& drawable) { + if (drawable.getEnabled()) { + auto& drawableMTL = static_cast(drawable); + drawableMTL.upload(uploadPass); + } + }); +} + +void TileLayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) { + if (!enabled || !getDrawableCount()) { + return; + } + + auto& context = static_cast(parameters.context); + + // `stencilModeFor3D` uses a different stencil mask value each time its called, so if the + // drawables in this layer use 3D stencil mode, we need to set it up here so that all the + // drawables end up using the same mode value. + // 2D and 3D features in the same layer group is not supported. + bool features3d = false; + bool stencil3d = false; + gfx::StencilMode stencilMode3d; + + // Collect the tile IDs relevant to stenciling and update the stencil buffer, if necessary. + std::set tileIDs; + std::size_t numEnabled = 0; + visitDrawables([&](const gfx::Drawable& drawable) { + if (!drawable.getEnabled() || !drawable.hasRenderPass(parameters.pass)) { + return; + } + numEnabled += 1; + if (drawable.getIs3D()) { + features3d = true; + if (drawable.getEnableStencil()) { + stencil3d = true; + } + } + if (!features3d && drawable.getEnableStencil() && drawable.getTileID()) { + tileIDs.emplace(drawable.getTileID()->toUnwrapped()); + } + }); + + if (!numEnabled) { + return; + } + +#if !defined(NDEBUG) + const auto debugGroupRender = parameters.encoder->createDebugGroup(getName() + "-render"); +#endif + + // If we're doing 3D stenciling and have any features + // to draw, set up the single-value stencil mask. + // If we're doing 2D stenciling and have any drawables with tile IDs, + // render each tile into the stencil buffer with a different value. + if (features3d) { + stencilMode3d = stencil3d ? parameters.stencilModeFor3D() : gfx::StencilMode::disabled(); + } else if (!tileIDs.empty()) { +#if !defined(NDEBUG) + const auto debugGroup = parameters.encoder->createDebugGroup("tile-clip-masks"); +#endif + + parameters.renderTileClippingMasks(tileIDs); + } + + visitDrawables([&](gfx::Drawable& drawable) { + if (!drawable.getEnabled() || !drawable.hasRenderPass(parameters.pass)) { + return; + } + + for (const auto& tweaker : drawable.getTweakers()) { + tweaker->execute(drawable, parameters); + } + + // For layer groups with 3D features, enable either the single-value + // stencil mode for features with stencil enabled or disable stenciling. + // 2D drawables will set their own stencil mode within `draw`. + // if (features3d) { + // context.setStencilMode(drawable.getEnableStencil() ? stencilMode3d : gfx::StencilMode::disabled()); + //} + + drawable.draw(parameters); + }); +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/uniform_block.cpp b/src/mbgl/mtl/uniform_block.cpp new file mode 100644 index 000000000..e2b436a5c --- /dev/null +++ b/src/mbgl/mtl/uniform_block.cpp @@ -0,0 +1,17 @@ +#include + +#include + +#include + +namespace mbgl { +namespace mtl { + +void UniformBlock::bindBuffer(const gfx::UniformBuffer& uniformBuffer) { + assert(size == uniformBuffer.getSize()); +} + +void UniformBlock::unbindBuffer() {} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/uniform_buffer.cpp b/src/mbgl/mtl/uniform_buffer.cpp new file mode 100644 index 000000000..38a9449e7 --- /dev/null +++ b/src/mbgl/mtl/uniform_buffer.cpp @@ -0,0 +1,30 @@ +#include + +#include + +#include + +namespace mbgl { +namespace mtl { + +UniformBuffer::UniformBuffer(BufferResource&& buffer_) + : gfx::UniformBuffer(buffer_.getSizeInBytes()), + buffer(std::move(buffer_)) {} +UniformBuffer::UniformBuffer(UniformBuffer&& other) + : gfx::UniformBuffer(std::move(other)), + buffer(std::move(other.buffer)) {} + +void UniformBuffer::update(const void* data, std::size_t size_) { + assert(size == size_); + if (size != size_ || size != buffer.getSizeInBytes()) { + Log::Error( + Event::General, + "Mismatched size given to UBO update, expected " + std::to_string(size) + ", got " + std::to_string(size_)); + return; + } + + buffer.update(data, size, /*offset=*/0); +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/upload_pass.cpp b/src/mbgl/mtl/upload_pass.cpp new file mode 100644 index 000000000..3a81c4630 --- /dev/null +++ b/src/mbgl/mtl/upload_pass.cpp @@ -0,0 +1,268 @@ +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace mbgl { +namespace mtl { + +UploadPass::UploadPass(gfx::Renderable& renderable, CommandEncoder& commandEncoder_, const char* name) + : commandEncoder(commandEncoder_) { + auto& resource = renderable.getResource(); + + if (!resource.getCommandBuffer()) { + resource.bind(); + } + + if (const auto& buffer_ = resource.getCommandBuffer()) { + buffer = buffer_; + if (auto upd = resource.getUploadPassDescriptor()) { + encoder = NS::RetainPtr(buffer->blitCommandEncoder(upd.get())); + } + } + + assert(encoder); + + // Push the groups already accumulated by the encoder + commandEncoder.visitDebugGroups([this](const auto& group) { + debugGroups.emplace_back(gfx::DebugGroup{*this, group.c_str()}); + }); + + // Push the group for the name provided + debugGroups.emplace_back(gfx::DebugGroup{*this, name}); + + // Let the encoder pass along any groups pushed to it after this + commandEncoder.trackUploadPass(this); +} + +UploadPass::~UploadPass() { + commandEncoder.forgetUploadPass(this); + endEncoding(); +} + +void UploadPass::endEncoding() { + debugGroups.clear(); + + if (encoder) { + encoder->endEncoding(); + encoder.reset(); + } +} + +std::unique_ptr UploadPass::createVertexBufferResource(const void* data, + const std::size_t size, + const gfx::BufferUsageType usage) { + return std::make_unique(commandEncoder.context.createBuffer(data, size, usage)); +} + +void UploadPass::updateVertexBufferResource(gfx::VertexBufferResource& resource, const void* data, std::size_t size) { + static_cast(resource).get().update(data, size, /*offset=*/0); +} + +std::unique_ptr UploadPass::createIndexBufferResource(const void* data, + const std::size_t size, + const gfx::BufferUsageType usage) { + return std::make_unique(commandEncoder.context.createBuffer(data, size, usage)); +} + +void UploadPass::updateIndexBufferResource(gfx::IndexBufferResource& resource, const void* data, std::size_t size) { + static_cast(resource).get().update(data, size, /*offset=*/0); +} + +std::unique_ptr UploadPass::createTextureResource(const Size size, + const void* data, + gfx::TexturePixelType format, + gfx::TextureChannelDataType type) { + assert(false); + throw std::runtime_error("UploadPass::createTextureResource not implemented on Metal!"); +} + +void UploadPass::updateTextureResource(gfx::TextureResource& resource, + const Size size, + const void* data, + gfx::TexturePixelType format, + gfx::TextureChannelDataType type) { + assert(false); + throw std::runtime_error("UploadPass::updateTextureResource not implemented on Metal!"); +} + +void UploadPass::updateTextureResourceSub(gfx::TextureResource& resource, + const uint16_t xOffset, + const uint16_t yOffset, + const Size size, + const void* data, + gfx::TexturePixelType format, + gfx::TextureChannelDataType type) { + assert(false); + throw std::runtime_error("UploadPass::updateTextureResourceSub not implemented on Metal!"); +} + +struct VertexBuffer : public gfx::VertexBufferBase { + ~VertexBuffer() override = default; + + std::unique_ptr resource; +}; + +namespace { +const std::unique_ptr noBuffer; +} +const gfx::UniqueVertexBufferResource& UploadPass::getBuffer(const gfx::VertexVectorBasePtr& vec, + const gfx::BufferUsageType usage) { + if (vec) { + const auto* rawBufPtr = vec->getRawData(); + const auto rawBufSize = vec->getRawCount() * vec->getRawSize(); + + // If we already have a buffer... + if (auto* rawData = static_cast(vec->getBuffer()); rawData && rawData->resource) { + auto& resource = static_cast(*rawData->resource); + + // If it's changed, update it + if (rawBufSize <= resource.getSizeInBytes()) { + if (vec->getDirty()) { + updateVertexBufferResource(resource, rawBufPtr, rawBufSize); + vec->setDirty(false); + } + return rawData->resource; + } + } + // Otherwise, create a new one + if (rawBufSize > 0) { + auto buffer = std::make_unique(); + buffer->resource = createVertexBufferResource(rawBufPtr, rawBufSize, usage); + vec->setBuffer(std::move(buffer)); + vec->setDirty(false); + return static_cast(vec->getBuffer())->resource; + } + } + return noBuffer; +} + +gfx::AttributeBindingArray UploadPass::buildAttributeBindings( + const std::size_t vertexCount, + const gfx::AttributeDataType vertexType, + const std::size_t vertexAttributeIndex, + const std::vector& vertexData, + const gfx::VertexAttributeArray& defaults, + const gfx::VertexAttributeArray& overrides, + const gfx::BufferUsageType usage, + /*out*/ std::vector>& outBuffers) { + gfx::AttributeBindingArray bindings; + bindings.resize(defaults.size()); + + constexpr std::size_t align = 16; + constexpr std::uint8_t padding = 0; + + std::vector allData; + allData.reserve((defaults.getTotalSize() + align) * vertexCount); + + uint32_t vertexStride = 0; + + // For each attribute in the program, with the corresponding default and optional override... + const auto resolveAttr = [&](const std::string& name, auto& default_, auto& override_) -> void { + auto& effectiveAttr = override_ ? *override_ : default_; + const auto& defaultAttr = static_cast(default_); + const auto stride = defaultAttr.getStride(); + const auto offset = static_cast(allData.size()); + const auto index = static_cast(defaultAttr.getIndex()); + + bindings.resize(std::max(bindings.size(), index + 1)); + + if (!override_) { + bindings[index] = { + /*.attribute = */ {defaultAttr.getDataType(), /*offset=*/0}, + /*.vertexStride = */ static_cast(VertexAttribute::getStrideOf(defaultAttr.getDataType())), + /*.vertexBufferResource = */ nullptr, + /*.vertexOffset = */ 0, + }; + return; + } + + // If the attribute references data shared with a bucket, get the corresponding buffer. + if (const auto& buffer = getBuffer(effectiveAttr.getSharedRawData(), usage)) { + bindings[index] = { + /*.attribute = */ {effectiveAttr.getSharedType(), effectiveAttr.getSharedOffset()}, + /*.vertexStride = */ effectiveAttr.getSharedStride(), + /*.vertexBufferResource = */ buffer.get(), + /*.vertexOffset = */ effectiveAttr.getSharedVertexOffset(), + }; + return; + } + + assert(effectiveAttr.getStride() > 0); + + // Otherwise, turn the data managed by the attribute into a buffer. + if (const auto& buffer = VertexAttribute::getBuffer(effectiveAttr, *this, gfx::BufferUsageType::StaticDraw)) { + bindings[index] = { + /*.attribute = */ {effectiveAttr.getDataType(), /*offset=*/0}, + /*.vertexStride = */ static_cast(effectiveAttr.getStride()), + /*.vertexBufferResource = */ buffer.get(), + /*.vertexOffset = */ 0, + }; + return; + } + + assert(false); + }; + defaults.resolve(overrides, resolveAttr); + + assert(vertexStride * vertexCount <= allData.size()); + + if (!allData.empty()) { + if (auto vertBuf = createVertexBufferResource(allData.data(), allData.size(), usage)) { + // Fill in the buffer in each binding that was generated without its own buffer + std::for_each(bindings.begin(), bindings.end(), [&](auto& b) { + if (b && !b->vertexBufferResource) { + b->vertexBufferResource = vertBuf.get(); + } + }); + + outBuffers.emplace_back(std::move(vertBuf)); + } else { + assert(false); + return {}; + } + } + + return bindings; +} + +namespace { +constexpr auto missing = ""; +NS::String* toNSString(const char* str) { + return NS::String::string(str ? str : missing, NS::UTF8StringEncoding); +} +} // namespace + +void UploadPass::pushDebugGroup(const char* name) { + assert(encoder); + if (encoder) { + encoder->pushDebugGroup(toNSString(name)); + } +} + +void UploadPass::popDebugGroup() { + assert(encoder); + if (encoder) { + encoder->popDebugGroup(); + } +} + +gfx::Context& UploadPass::getContext() { + return commandEncoder.context; +} + +const gfx::Context& UploadPass::getContext() const { + return commandEncoder.context; +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/mtl/vertex_attribute.cpp b/src/mbgl/mtl/vertex_attribute.cpp new file mode 100644 index 000000000..53250cc2d --- /dev/null +++ b/src/mbgl/mtl/vertex_attribute.cpp @@ -0,0 +1,100 @@ +#include + +#include +#include +#include +#include + +#include +#include + +namespace mbgl { +namespace mtl { + +std::size_t VertexAttribute::getStrideOf(gfx::AttributeDataType type) { + switch (type) { + case gfx::AttributeDataType::Byte: + return 1; + case gfx::AttributeDataType::Byte2: + return 2; + case gfx::AttributeDataType::Byte3: + return 3; + case gfx::AttributeDataType::Byte4: + return 4; + case gfx::AttributeDataType::UByte: + return 1; + case gfx::AttributeDataType::UByte2: + return 2; + case gfx::AttributeDataType::UByte3: + return 3; + case gfx::AttributeDataType::UByte4: + return 4; + case gfx::AttributeDataType::Short: + return 2; + case gfx::AttributeDataType::Short2: + return 4; + case gfx::AttributeDataType::Short3: + return 6; + case gfx::AttributeDataType::Short4: + return 8; + case gfx::AttributeDataType::UShort: + return 2; + case gfx::AttributeDataType::UShort2: + return 4; + case gfx::AttributeDataType::UShort3: + return 6; + case gfx::AttributeDataType::UShort4: + return 8; + case gfx::AttributeDataType::UShort8: + return 16; + case gfx::AttributeDataType::Int: + return 4; + case gfx::AttributeDataType::Int2: + return 8; + case gfx::AttributeDataType::Int3: + return 12; + case gfx::AttributeDataType::Int4: + return 16; + case gfx::AttributeDataType::UInt: + return 4; + case gfx::AttributeDataType::UInt2: + return 8; + case gfx::AttributeDataType::UInt3: + return 12; + case gfx::AttributeDataType::UInt4: + return 16; + case gfx::AttributeDataType::Float: + return 4; + case gfx::AttributeDataType::Float2: + return 8; + case gfx::AttributeDataType::Float3: + return 12; + case gfx::AttributeDataType::Float4: + return 16; + default: + assert(false); + return 0; + } +} + +const gfx::UniqueVertexBufferResource& VertexAttribute::getBuffer(gfx::VertexAttribute& attrib_, + UploadPass& uploadPass, + const gfx::BufferUsageType usage) { + if (!attrib_.getBuffer()) { + auto& attrib = static_cast(attrib_); + if (attrib.sharedRawData) { + return uploadPass.getBuffer(attrib.sharedRawData, usage); + } else if (!attrib.rawData.empty()) { + auto buffer = uploadPass.createVertexBufferResource(attrib.rawData.data(), attrib.rawData.size(), usage); + attrib.setBuffer(std::move(buffer)); + attrib.setRawData({}); + } else { + // TODO: vertex building + assert(false); + } + } + return attrib_.getBuffer(); +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp index ceb94c596..44d8d7d16 100644 --- a/src/mbgl/programs/program.hpp +++ b/src/mbgl/programs/program.hpp @@ -14,7 +14,7 @@ #include #include -#ifdef MBGL_RENDER_BACKEND_OPENGL +#if !MLN_RENDER_BACKEND_METAL #include #endif @@ -54,7 +54,11 @@ public: Program(const ProgramParameters& programParameters) { switch (gfx::Backend::GetType()) { -#ifdef MBGL_RENDER_BACKEND_OPENGL +#if MLN_RENDER_BACKEND_METAL + case gfx::Backend::Type::Metal: { + break; + } +#else // MLN_RENDER_BACKEND_OPENGL case gfx::Backend::Type::OpenGL: { program = std::make_unique>(programParameters.withDefaultSource( {gfx::Backend::Type::OpenGL, diff --git a/src/mbgl/programs/program_parameters.cpp b/src/mbgl/programs/program_parameters.cpp index 7ff1cc3bc..7fefa7701 100644 --- a/src/mbgl/programs/program_parameters.cpp +++ b/src/mbgl/programs/program_parameters.cpp @@ -1,22 +1,19 @@ #include + #include + #include #include namespace mbgl { ProgramParameters::ProgramParameters(const float pixelRatio, const bool overdraw) - : defines([&] { - std::string result; - result.reserve(32); - result += "#define DEVICE_PIXEL_RATIO "; - result += util::toString(pixelRatio, true); - result += '\n'; - if (overdraw) { - result += "#define OVERDRAW_INSPECTOR\n"; - } - return result; - }()) {} + : defines(2) { + defines["DEVICE_PIXEL_RATIO"] = util::toString(pixelRatio, true); + if (overdraw) { + defines["OVERDRAW_INSPECTOR"] = std::string(); + } +} ProgramParameters ProgramParameters::withShaderSource(const ProgramSource& source) const noexcept { assert(gfx::Backend::Type::TYPE_MAX != source.backend); @@ -34,8 +31,19 @@ ProgramParameters ProgramParameters::withDefaultSource(const ProgramSource& sour return params; } -const std::string& ProgramParameters::getDefines() const { - return defines; +const std::string& ProgramParameters::getDefinesString() const { + if (definesStr.empty() && !defines.empty()) { + definesStr.assign(defines.size() * 32, '\0'); + definesStr.clear(); + for (const auto& pair : defines) { + definesStr.append("#define ").append(pair.first); + if (!pair.second.empty()) { + definesStr.append(" ").append(pair.second); + } + definesStr.append("\n"); + } + } + return definesStr; } const std::string& ProgramParameters::vertexSource(gfx::Backend::Type backend) const { diff --git a/src/mbgl/programs/program_parameters.hpp b/src/mbgl/programs/program_parameters.hpp index 3bd165132..700417033 100644 --- a/src/mbgl/programs/program_parameters.hpp +++ b/src/mbgl/programs/program_parameters.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace mbgl { @@ -18,8 +19,7 @@ public: ProgramSource() = default; /// @brief Construct a new ProgramSource object - /// @param forBackend The provided source code is intended for use with the give - /// rendering backend. + /// @param forBackend The provided source code is intended for use with the given rendering backend. /// @param vertex_ The vertex shader source code, or empty string if not provided. /// @param fragment_ The fragment shader source code, or empty string if not provided. ProgramSource(gfx::Backend::Type forBackend, const std::string& vertex_, const std::string& fragment_) @@ -45,7 +45,11 @@ public: /// @brief Get a list of built-in shader preprocessor defines /// @return Shader source string /// @todo With the addition of future backends, defines should also be backend-aware - const std::string& getDefines() const; + const std::string& getDefinesString() const; + + /// @brief Get a list of built-in shader preprocessor defines + /// @return Map of key-value pairs representing preprocessor definitions + const std::unordered_map& getDefines() const { return defines; } /// @brief Get source code for the vertex shader compatible with the requested backend /// @param backend Backend type @@ -58,7 +62,10 @@ public: const std::string& fragmentSource(gfx::Backend::Type backend) const; private: - std::string defines; + std::unordered_map defines; + + // cached value of `defines` converted to string format + mutable std::string definesStr; std::array(gfx::Backend::Type::TYPE_MAX)> defaultSources; std::array(gfx::Backend::Type::TYPE_MAX)> userSources; diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index e9507fb84..f209d16d8 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -18,7 +18,7 @@ #include #include -#ifdef MBGL_RENDER_BACKEND_OPENGL +#if !MLN_RENDER_BACKEND_METAL #include #endif @@ -263,7 +263,7 @@ public: SymbolProgram(const ProgramParameters& programParameters) { switch (gfx::Backend::GetType()) { -#ifdef MBGL_RENDER_BACKEND_OPENGL +#if !MLN_RENDER_BACKEND_METAL case gfx::Backend::Type::OpenGL: { program = std::make_unique>(programParameters.withDefaultSource( {gfx::Backend::Type::OpenGL, diff --git a/src/mbgl/renderer/layer_tweaker.cpp b/src/mbgl/renderer/layer_tweaker.cpp index 781513c81..42991269b 100644 --- a/src/mbgl/renderer/layer_tweaker.cpp +++ b/src/mbgl/renderer/layer_tweaker.cpp @@ -6,10 +6,17 @@ #include #include +#if MLN_RENDER_BACKEND_METAL +#include +#include +#include +#endif // MLN_RENDER_BACKEND_METAL + namespace mbgl { -LayerTweaker::LayerTweaker(Immutable properties) - : evaluatedProperties(std::move(properties)) {} +LayerTweaker::LayerTweaker(std::string id_, Immutable properties) + : id(std::move(id_)), + evaluatedProperties(std::move(properties)) {} mat4 LayerTweaker::getTileMatrix(const UnwrappedTileID& tileID, const RenderTree& renderTree, @@ -33,4 +40,41 @@ mat4 LayerTweaker::getTileMatrix(const UnwrappedTileID& tileID, return RenderTile::translateVtxMatrix(tileID, tileMatrix, translation, anchor, state, inViewportPixelUnits); } +#if MLN_RENDER_BACKEND_METAL +shaders::ExpressionInputsUBO LayerTweaker::buildExpressionUBO(double zoom, uint64_t frameCount) { + const auto time = util::MonotonicTimer::now(); + const auto time_ns = std::chrono::duration_cast(time).count(); + return {/* .time_lo = */ static_cast(time_ns), + /* .time_hi = */ static_cast(time_ns >> 32), + /* .frame_lo = */ static_cast(frameCount), + /* .frame_hi = */ static_cast(frameCount >> 32), + /* .zoom = */ static_cast(zoom), + /* .zoom_frac = */ static_cast(zoom - static_cast(zoom)), + /* .pad = */ 0, + 0}; +} + +void LayerTweaker::setPropertiesAsUniforms(std::vector props) { + if (props != propertiesAsUniforms) { + propertiesAsUniforms = std::move(props); + propertiesChanged = true; + } +} +bool LayerTweaker::hasPropertyAsUniform(const std::string_view attrName) const { + // `attrName` is expected to have the "a_" prefix, while the values in `propertiesAsUniforms` + // do not. Search for the former within the latter without allocating temporary strings. + return propertiesAsUniforms.end() != + std::find_if(propertiesAsUniforms.begin(), propertiesAsUniforms.end(), [&](const auto& name) { + return name.size() + 2 == attrName.size() && 0 == std::strcmp(name.data(), attrName.data() + 2); + }); +} +#endif // MLN_RENDER_BACKEND_METAL + +void LayerTweaker::enableOverdrawInspector(bool value) { + if (overdrawInspector != value) { + overdrawInspector = value; + propertiesChanged = true; + } +} + } // namespace mbgl diff --git a/src/mbgl/renderer/layers/background_layer_tweaker.cpp b/src/mbgl/renderer/layers/background_layer_tweaker.cpp index 4ae21fb9e..bb2f97ed2 100644 --- a/src/mbgl/renderer/layers/background_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/background_layer_tweaker.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -12,45 +13,9 @@ namespace mbgl { using namespace style; +using namespace shaders; -struct alignas(16) BackgroundDrawableUBO { - std::array matrix; -}; -static_assert(sizeof(BackgroundDrawableUBO) % 16 == 0); - -struct alignas(16) BackgroundLayerUBO { - /* 0 */ Color color; - /* 16 */ float opacity; - /* 20 */ float pad1, pad2, pad3; - /* 32 */ -}; -static_assert(sizeof(BackgroundLayerUBO) == 32); - -struct alignas(16) BackgroundPatternLayerUBO { - /* 0 */ std::array pattern_tl_a; - /* 8 */ std::array pattern_br_a; - /* 16 */ std::array pattern_tl_b; - /* 24 */ std::array pattern_br_b; - /* 32 */ std::array texsize; - /* 40 */ std::array pattern_size_a; - /* 48 */ std::array pattern_size_b; - /* 56 */ std::array pixel_coord_upper; - /* 64 */ std::array pixel_coord_lower; - /* 72 */ float tile_units_to_pixels; - /* 76 */ float scale_a; - /* 80 */ float scale_b; - /* 84 */ float mix; - /* 88 */ float opacity; - /* 92 */ float pad; - /* 96 */ -}; -static_assert(sizeof(BackgroundPatternLayerUBO) == 96); - -#if !defined(NDEBUG) static constexpr auto BackgroundPatternShaderName = "BackgroundPatternShader"; -#endif -static constexpr auto BackgroundDrawableUBOName = "BackgroundDrawableUBO"; -static constexpr auto BackgroundLayerUBOName = "BackgroundLayerUBO"; static constexpr auto texUniformName = "u_image"; void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTree&, const PaintParameters& parameters) { @@ -96,7 +61,7 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTre const BackgroundDrawableUBO drawableUBO = {/* .matrix = */ util::cast(matrix)}; auto& uniforms = drawable.mutableUniformBuffers(); - uniforms.createOrUpdate(BackgroundDrawableUBOName, &drawableUBO, context); + uniforms.createOrUpdate("BackgroundDrawableUBO", &drawableUBO, context); if (hasPattern) { if (!samplerLocation.has_value()) { @@ -138,7 +103,7 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTre /* .opacity = */ evaluated.get(), /* .pad = */ 0, }; - uniforms.createOrUpdate(BackgroundLayerUBOName, &layerUBO, context); + uniforms.createOrUpdate("BackgroundLayerUBO", &layerUBO, context); } else { // UBOs can be shared if (!backgroundLayerBuffer) { @@ -149,7 +114,7 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTre 0}; backgroundLayerBuffer = context.createUniformBuffer(&layerUBO, sizeof(layerUBO)); } - uniforms.addOrReplace(BackgroundLayerUBOName, backgroundLayerBuffer); + uniforms.addOrReplace("BackgroundLayerUBO", backgroundLayerBuffer); } }); } diff --git a/src/mbgl/renderer/layers/background_layer_tweaker.hpp b/src/mbgl/renderer/layers/background_layer_tweaker.hpp index 27ba75474..8c750f0a9 100644 --- a/src/mbgl/renderer/layers/background_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/background_layer_tweaker.hpp @@ -19,8 +19,8 @@ using UniformBufferPtr = std::shared_ptr; */ class BackgroundLayerTweaker : public LayerTweaker { public: - BackgroundLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + BackgroundLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~BackgroundLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp index 239756693..bee44691d 100644 --- a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp @@ -5,44 +5,22 @@ #include #include #include +#include +#include #include #include +#if MLN_RENDER_BACKEND_METAL +#include +#endif + +#include + namespace mbgl { using namespace style; -struct alignas(16) CircleDrawableUBO { - std::array matrix; - std::array extrude_scale; - std::array padding; -}; -static_assert(sizeof(CircleDrawableUBO) % 16 == 0); - -struct alignas(16) CirclePaintParamsUBO { - float camera_to_center_distance; - float device_pixel_ratio; - std::array padding; -}; -static_assert(sizeof(CirclePaintParamsUBO) % 16 == 0); - -struct alignas(16) CircleEvaluatedPropsUBO { - Color color; - Color stroke_color; - float radius; - float blur; - float opacity; - float stroke_width; - float stroke_opacity; - int scale_with_map; - int pitch_with_map; - float padding; -}; -static_assert(sizeof(CircleEvaluatedPropsUBO) % 16 == 0); - -static constexpr std::string_view CircleDrawableUBOName = "CircleDrawableUBO"; -static constexpr std::string_view CirclePaintParamsUBOName = "CirclePaintParamsUBO"; -static constexpr std::string_view CircleEvaluatedPropsUBOName = "CircleEvaluatedPropsUBO"; +using namespace shaders; void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTree& renderTree, @@ -63,7 +41,8 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const CirclePaintParamsUBO paintParamsUBO = { /* .camera_to_center_distance = */ parameters.state.getCameraToCenterDistance(), /* .device_pixel_ratio = */ parameters.pixelRatio, - /* .padding = */ {0}}; + /* .padding = */ 0, + 0}; if (!paintParamsUniformBuffer) { paintParamsUniformBuffer = context.createUniformBuffer(&paintParamsUBO, sizeof(paintParamsUBO)); @@ -71,20 +50,56 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, paintParamsUniformBuffer->update(&paintParamsUBO, sizeof(CirclePaintParamsUBO)); } - const bool scaleWithMap = evaluated.get() == CirclePitchScaleType::Map; + const auto zoom = parameters.state.getZoom(); + +#if MLN_RENDER_BACKEND_METAL + using ShaderClass = shaders::ShaderSource; + if (propertiesChanged) { + const auto source = [this](const std::string_view& attrName) { + return hasPropertyAsUniform(attrName) ? AttributeSource::Constant : AttributeSource::PerVertex; + }; + + const CirclePermutationUBO permutationUBO = { + /* .color = */ {/*.source=*/source(ShaderClass::attributes[1].name), /*.expression=*/{}}, + /* .radius = */ {/*.source=*/source(ShaderClass::attributes[2].name), /*.expression=*/{}}, + /* .blur = */ {/*.source=*/source(ShaderClass::attributes[3].name), /*.expression=*/{}}, + /* .opacity = */ {/*.source=*/source(ShaderClass::attributes[4].name), /*.expression=*/{}}, + /* .stroke_color = */ {/*.source=*/source(ShaderClass::attributes[5].name), /*.expression=*/{}}, + /* .stroke_width = */ {/*.source=*/source(ShaderClass::attributes[6].name), /*.expression=*/{}}, + /* .stroke_opacity = */ {/*.source=*/source(ShaderClass::attributes[7].name), /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + /* .pad = */ 0, + 0, + 0, + 0}; + + if (permutationUniformBuffer) { + permutationUniformBuffer->update(&permutationUBO, sizeof(permutationUBO)); + } else { + permutationUniformBuffer = context.createUniformBuffer(&permutationUBO, sizeof(permutationUBO)); + } + + propertiesChanged = false; + } + if (!expressionUniformBuffer) { + const auto expressionUBO = buildExpressionUBO(zoom, parameters.frameCount); + expressionUniformBuffer = context.createUniformBuffer(&expressionUBO, sizeof(expressionUBO)); + } +#endif + const bool pitchWithMap = evaluated.get() == AlignmentType::Map; + const bool scaleWithMap = evaluated.get() == CirclePitchScaleType::Map; // Updated only with evaluated properties if (!evaluatedPropsUniformBuffer) { const CircleEvaluatedPropsUBO evaluatedPropsUBO = { - /* .color = */ evaluated.get().constantOr(CircleColor::defaultValue()), - /* .stroke_color = */ evaluated.get().constantOr(CircleStrokeColor::defaultValue()), - /* .radius = */ evaluated.get().constantOr(CircleRadius::defaultValue()), - /* .blur = */ evaluated.get().constantOr(CircleBlur::defaultValue()), - /* .opacity = */ evaluated.get().constantOr(CircleOpacity::defaultValue()), - /* .stroke_width = */ evaluated.get().constantOr(CircleStrokeWidth::defaultValue()), - /* .stroke_opacity = */ - evaluated.get().constantOr(CircleStrokeOpacity::defaultValue()), + /* .color = */ constOrDefault(evaluated), + /* .stroke_color = */ constOrDefault(evaluated), + /* .radius = */ constOrDefault(evaluated), + /* .blur = */ constOrDefault(evaluated), + /* .opacity = */ constOrDefault(evaluated), + /* .stroke_width = */ constOrDefault(evaluated), + /* .stroke_opacity = */ constOrDefault(evaluated), /* .scale_with_map = */ scaleWithMap, /* .pitch_with_map = */ pitchWithMap, /* .padding = */ 0}; @@ -93,10 +108,11 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, layerGroup.visitDrawables([&](gfx::Drawable& drawable) { auto& uniforms = drawable.mutableUniformBuffers(); - uniforms.addOrReplace(CirclePaintParamsUBOName, paintParamsUniformBuffer); - uniforms.addOrReplace(CircleEvaluatedPropsUBOName, evaluatedPropsUniformBuffer); + uniforms.addOrReplace("CirclePaintParamsUBO", paintParamsUniformBuffer); + uniforms.addOrReplace("CircleEvaluatedPropsUBO", evaluatedPropsUniformBuffer); if (!drawable.getTileID()) { + assert(!"Circles only render with tiles"); return; } const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped(); @@ -108,16 +124,20 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const auto matrix = getTileMatrix( tileID, renderTree, parameters.state, translation, anchor, nearClipped, inViewportPixelUnits); - const auto pixelsToTileUnits = tileID.pixelsToTileUnits(1.0f, static_cast(parameters.state.getZoom())); + const auto pixelsToTileUnits = tileID.pixelsToTileUnits(1.0f, static_cast(zoom)); + const auto extrudeScale = pitchWithMap ? std::array{pixelsToTileUnits, pixelsToTileUnits} + : parameters.pixelsToGLUnits; // Updated for each drawable on each frame - const CircleDrawableUBO drawableUBO = { - /* .matrix = */ util::cast(matrix), - /* .extrude_scale = */ - pitchWithMap ? std::array{{pixelsToTileUnits, pixelsToTileUnits}} : parameters.pixelsToGLUnits, - /* .padding = */ {0}}; + const CircleDrawableUBO drawableUBO = {/* .matrix = */ util::cast(matrix), + /* .extrude_scale = */ extrudeScale, + /* .padding = */ 0}; + uniforms.createOrUpdate("CircleDrawableUBO", &drawableUBO, context); - uniforms.createOrUpdate(CircleDrawableUBOName, &drawableUBO, context); +#if MLN_RENDER_BACKEND_METAL + uniforms.addOrReplace("ExpressionInputsUBO", expressionUniformBuffer); + uniforms.addOrReplace("CirclePermutationUBO", permutationUniformBuffer); +#endif // MLN_RENDER_BACKEND_METAL }); } diff --git a/src/mbgl/renderer/layers/circle_layer_tweaker.hpp b/src/mbgl/renderer/layers/circle_layer_tweaker.hpp index 2016d299e..5bdfd24fa 100644 --- a/src/mbgl/renderer/layers/circle_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/circle_layer_tweaker.hpp @@ -2,6 +2,9 @@ #include +#include +#include + namespace mbgl { /** @@ -9,10 +12,8 @@ namespace mbgl { */ class CircleLayerTweaker : public LayerTweaker { public: - CircleLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; - -public: + CircleLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} ~CircleLayerTweaker() override = default; void execute(LayerGroupBase&, const RenderTree&, const PaintParameters&) override; @@ -20,6 +21,11 @@ public: protected: gfx::UniformBufferPtr paintParamsUniformBuffer; gfx::UniformBufferPtr evaluatedPropsUniformBuffer; + +#if MLN_RENDER_BACKEND_METAL + gfx::UniformBufferPtr permutationUniformBuffer; + gfx::UniformBufferPtr expressionUniformBuffer; +#endif // MLN_RENDER_BACKEND_METAL }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/collision_layer_tweaker.hpp b/src/mbgl/renderer/layers/collision_layer_tweaker.hpp index e9d854fff..dc915ddc8 100644 --- a/src/mbgl/renderer/layers/collision_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/collision_layer_tweaker.hpp @@ -11,8 +11,8 @@ namespace mbgl { */ class CollisionLayerTweaker : public LayerTweaker { public: - CollisionLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + CollisionLayerTweaker(std::string name, Immutable properties) + : LayerTweaker(std::move(name), properties) {} public: ~CollisionLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp index ea5045472..e94fbe808 100644 --- a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -49,16 +50,8 @@ struct alignas(16) FillExtrusionDrawablePropsUBO { }; static_assert(sizeof(FillExtrusionDrawablePropsUBO) == 5 * 16); -constexpr auto FillExtrusionDrawableUBOName = "FillExtrusionDrawableUBO"; -constexpr auto FillExtrusionDrawablePropsUBOName = "FillExtrusionDrawablePropsUBO"; - constexpr auto texUniformName = "u_image"; -template -auto constOrDefault(const IndexedTuple, TypeList>& evaluated) { - return evaluated.template get().constantOr(T::defaultValue()); -} - } // namespace void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, @@ -103,7 +96,7 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, layerGroup.visitDrawables([&](gfx::Drawable& drawable) { auto& uniforms = drawable.mutableUniformBuffers(); - uniforms.addOrReplace(FillExtrusionDrawablePropsUBOName, propsBuffer); + uniforms.addOrReplace("FillExtrusionDrawablePropsUBO", propsBuffer); if (!drawable.getTileID()) { return; @@ -147,7 +140,7 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, /* .height_factor = */ heightFactor, /* .pad = */ 0}; - uniforms.createOrUpdate(FillExtrusionDrawableUBOName, &drawableUBO, context); + uniforms.createOrUpdate("FillExtrusionDrawableUBO", &drawableUBO, context); }); } diff --git a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.hpp b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.hpp index ed45b1105..7d1a775ee 100644 --- a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.hpp @@ -11,8 +11,8 @@ namespace mbgl { */ class FillExtrusionLayerTweaker : public LayerTweaker { public: - FillExtrusionLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + FillExtrusionLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~FillExtrusionLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp index 5bfb800db..9880b369a 100644 --- a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp @@ -8,38 +8,21 @@ #include #include #include +#include #include +#include #include #include #include +#if MLN_RENDER_BACKEND_METAL +#include +#endif + namespace mbgl { using namespace style; - -struct alignas(16) FillDrawableUBO { - /* 0 */ std::array matrix; - /* 64 */ std::array scale; - /* 80 */ std::array world; - /* 88 */ std::array pixel_coord_upper; - /* 96 */ std::array pixel_coord_lower; - /* 104 */ std::array texsize; - /* 112 */ -}; -static_assert(sizeof(FillDrawableUBO) == 112); - -/// Evaluated properties that do not depend on the tile -struct alignas(16) FillDrawablePropsUBO { - /* 0 */ Color color; - /* 16 */ Color outline_color; - /* 32 */ float opacity; - /* 36 */ float pad1, pad2, pad3; - /* 48 */ -}; -static_assert(sizeof(FillDrawablePropsUBO) == 48); - -static constexpr std::string_view FillDrawableUBOName = "FillDrawableUBO"; -static constexpr std::string_view FillDrawablePropsUBOName = "FillDrawablePropsUBO"; +using namespace shaders; void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTree& renderTree, @@ -58,24 +41,186 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const auto debugGroup = parameters.encoder->createDebugGroup(label.c_str()); #endif - if (!propsBuffer) { - const FillDrawablePropsUBO paramsUBO = { - /* .color = */ evaluated.get().constantOr(FillColor::defaultValue()), - /* .outline_color = */ evaluated.get().constantOr(FillOutlineColor::defaultValue()), - /* .opacity = */ evaluated.get().constantOr(FillOpacity::defaultValue()), - /* .padding = */ 0, - 0, - 0}; - propsBuffer = context.createUniformBuffer(¶msUBO, sizeof(paramsUBO)); +#if MLN_RENDER_BACKEND_METAL + const auto source = [this](const std::string_view& attrName) { + return hasPropertyAsUniform(attrName) ? AttributeSource::Constant : AttributeSource::PerVertex; + }; +#endif + + bool fillUniformBufferUpdated = false; + bool fillOutlineUniformBufferUpdated = false; + bool fillPatternUniformBufferUpdated = false; + bool fillOutlinePatternUniformBufferUpdated = false; + + auto UpdateFillUniformBuffers = [&]() { + if (fillUniformBufferUpdated) return; + +#if MLN_RENDER_BACKEND_METAL + using ShaderClass = ShaderSource; + if (propertiesChanged || !fillPermutationUniformBuffer) { + const FillPermutationUBO permutationUBO = { + /* .color = */ {/*.source=*/source(ShaderClass::attributes[1].name), /*.expression=*/{}}, + /* .opacity = */ {/*.source=*/source(ShaderClass::attributes[2].name), /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + 0, + 0, + 0, + 0, + 0, + 0, + }; + + if (fillPermutationUniformBuffer) { + fillPermutationUniformBuffer->update(&permutationUBO, sizeof(permutationUBO)); + } else { + fillPermutationUniformBuffer = context.createUniformBuffer(&permutationUBO, sizeof(permutationUBO)); + } + fillUniformBufferUpdated = true; + } +#endif + + if (!fillPropsUniformBuffer) { + const FillEvaluatedPropsUBO paramsUBO = { + /* .color = */ evaluated.get().constantOr(FillColor::defaultValue()), + /* .opacity = */ evaluated.get().constantOr(FillOpacity::defaultValue()), + 0, + 0, + 0, + }; + fillPropsUniformBuffer = context.createUniformBuffer(¶msUBO, sizeof(paramsUBO)); + } + }; + + auto UpdateFillOutlineUniformBuffers = [&]() { + if (fillOutlineUniformBufferUpdated) return; + +#if MLN_RENDER_BACKEND_METAL + using ShaderClass = ShaderSource; + if (propertiesChanged || !fillOutlinePermutationUniformBuffer) { + const FillOutlinePermutationUBO permutationUBO = { + /* .outline_color = */ {/*.source=*/source(ShaderClass::attributes[1].name), /*.expression=*/{}}, + /* .opacity = */ {/*.source=*/source(ShaderClass::attributes[2].name), /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + 0, + 0, + 0, + 0, + 0, + 0, + }; + + if (fillOutlinePermutationUniformBuffer) { + fillOutlinePermutationUniformBuffer->update(&permutationUBO, sizeof(permutationUBO)); + } else { + fillOutlinePermutationUniformBuffer = context.createUniformBuffer(&permutationUBO, + sizeof(permutationUBO)); + } + } +#endif + + if (!fillOutlinePropsUniformBuffer) { + const FillOutlineEvaluatedPropsUBO paramsUBO = { + /* .outline_color = */ evaluated.get().constantOr(FillOutlineColor::defaultValue()), + /* .opacity = */ evaluated.get().constantOr(FillOpacity::defaultValue()), + 0, + 0, + 0, + }; + fillOutlinePropsUniformBuffer = context.createUniformBuffer(¶msUBO, sizeof(paramsUBO)); + } + + fillOutlineUniformBufferUpdated = true; + }; + + auto UpdateFillPatternUniformBuffers = [&]() { + if (fillPatternUniformBufferUpdated) return; + +#if MLN_RENDER_BACKEND_METAL + using ShaderClass = ShaderSource; + if (propertiesChanged || !fillPatternPermutationUniformBuffer) { + const FillPatternPermutationUBO permutationUBO = { + /* .pattern_from = */ {/*.source=*/source(ShaderClass::attributes[1].name), /*.expression=*/{}}, + /* .pattern_to = */ {/*.source=*/source(ShaderClass::attributes[2].name), /*.expression=*/{}}, + /* .opacity = */ {/*.source=*/source(ShaderClass::attributes[3].name), /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + 0, + 0, + 0, + 0, + }; + + if (fillPatternPermutationUniformBuffer) { + fillPatternPermutationUniformBuffer->update(&permutationUBO, sizeof(permutationUBO)); + } else { + fillPatternPermutationUniformBuffer = context.createUniformBuffer(&permutationUBO, + sizeof(permutationUBO)); + } + } +#endif + + if (!fillPatternPropsUniformBuffer) { + const FillPatternEvaluatedPropsUBO paramsUBO = { + /* .opacity = */ evaluated.get().constantOr(FillOpacity::defaultValue()), + /* .fade = */ crossfade.t, + 0, + 0, + }; + fillPatternPropsUniformBuffer = context.createUniformBuffer(¶msUBO, sizeof(paramsUBO)); + } + + fillPatternUniformBufferUpdated = true; + }; + + auto UpdateFillOutlinePatternUniformBuffers = [&]() { + if (fillOutlinePatternUniformBufferUpdated) return; + +#if MLN_RENDER_BACKEND_METAL + using ShaderClass = ShaderSource; + if (propertiesChanged || !fillOutlinePermutationUniformBuffer) { + const FillOutlinePatternPermutationUBO permutationUBO = { + /* .pattern_from = */ {/*.source=*/source(ShaderClass::attributes[1].name), /*.expression=*/{}}, + /* .pattern_to = */ {/*.source=*/source(ShaderClass::attributes[2].name), /*.expression=*/{}}, + /* .opacity = */ {/*.source=*/source(ShaderClass::attributes[3].name), /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + 0, + 0, + 0, + 0, + }; + + if (fillOutlinePatternPermutationUniformBuffer) { + fillOutlinePatternPermutationUniformBuffer->update(&permutationUBO, sizeof(permutationUBO)); + } else { + fillOutlinePatternPermutationUniformBuffer = context.createUniformBuffer(&permutationUBO, + sizeof(permutationUBO)); + } + } +#endif + + if (!fillOutlinePatternPropsUniformBuffer) { + const FillOutlinePatternEvaluatedPropsUBO paramsUBO = { + /* .opacity = */ evaluated.get().constantOr(FillOpacity::defaultValue()), + /* .fade = */ crossfade.t, + 0, + 0, + }; + fillOutlinePatternPropsUniformBuffer = context.createUniformBuffer(¶msUBO, sizeof(paramsUBO)); + } + + fillOutlinePatternUniformBufferUpdated = true; + }; + +#if MLN_RENDER_BACKEND_METAL + if (!expressionUniformBuffer) { + const auto zoom = parameters.state.getZoom(); + const auto expressionUBO = buildExpressionUBO(zoom, parameters.frameCount); + expressionUniformBuffer = context.createUniformBuffer(&expressionUBO, sizeof(expressionUBO)); } +#endif layerGroup.visitDrawables([&](gfx::Drawable& drawable) { auto& uniforms = drawable.mutableUniformBuffers(); - uniforms.addOrReplace(FillDrawablePropsUBOName, propsBuffer); - - if (!drawable.getTileID()) { - return; - } + // auto& drawableType = drawable.getShader()->typeName(); const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped(); @@ -106,18 +251,80 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, } } } + if (!drawable.getTileID()) { + return; + } - const FillDrawableUBO drawableUBO = { - /*.matrix=*/util::cast(matrix), - /*.scale=*/{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}, - /*.world=*/{(float)renderableSize.width, (float)renderableSize.height}, - /*.pixel_coord_upper=*/{static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, - /*.pixel_coord_lower=*/{static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, - /*.texsize=*/{static_cast(textureSize.width), static_cast(textureSize.height)}, - }; + if (uniforms.get("FillInterpolateUBO")) { + UpdateFillUniformBuffers(); - uniforms.createOrUpdate(FillDrawableUBOName, &drawableUBO, context); + uniforms.addOrReplace("FillEvaluatedPropsUBO", fillPropsUniformBuffer); + const FillDrawableUBO drawableUBO = {/*.matrix=*/util::cast(matrix)}; + + uniforms.createOrUpdate("FillDrawableUBO", &drawableUBO, context); + +#if MLN_RENDER_BACKEND_METAL + uniforms.addOrReplace("FillPermutationUBO", fillPermutationUniformBuffer); +#endif // MLN_RENDER_BACKEND_METAL + } else if (uniforms.get("FillOutlineInterpolateUBO")) { + UpdateFillOutlineUniformBuffers(); + + uniforms.addOrReplace("FillOutlineEvaluatedPropsUBO", fillOutlinePropsUniformBuffer); + const FillOutlineDrawableUBO drawableUBO = { + /*.matrix=*/util::cast(matrix), + /*.world=*/{(float)renderableSize.width, (float)renderableSize.height}, + }; + + uniforms.createOrUpdate("FillOutlineDrawableUBO", &drawableUBO, context); + +#if MLN_RENDER_BACKEND_METAL + uniforms.addOrReplace("FillOutlinePermutationUBO", fillOutlinePermutationUniformBuffer); +#endif // MLN_RENDER_BACKEND_METAL + } else if (uniforms.get("FillPatternInterpolateUBO")) { + UpdateFillPatternUniformBuffers(); + + uniforms.addOrReplace("FillPatternEvaluatedPropsUBO", fillPatternPropsUniformBuffer); + const FillPatternDrawableUBO drawableUBO = { + /*.matrix=*/util::cast(matrix), + /*.scale=*/{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}, + /*.pixel_coord_upper=*/{static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, + /*.pixel_coord_lower=*/{static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, + /*.texsize=*/{static_cast(textureSize.width), static_cast(textureSize.height)}, + 0, + 0, + }; + + uniforms.createOrUpdate("FillPatternDrawableUBO", &drawableUBO, context); + +#if MLN_RENDER_BACKEND_METAL + uniforms.addOrReplace("FillPatternPermutationUBO", fillPatternPermutationUniformBuffer); +#endif // MLN_RENDER_BACKEND_METAL + } else if (uniforms.get("FillOutlinePatternInterpolateUBO")) { + UpdateFillOutlinePatternUniformBuffers(); + + uniforms.addOrReplace("FillOutlinePatternEvaluatedPropsUBO", fillOutlinePatternPropsUniformBuffer); + const FillOutlinePatternDrawableUBO drawableUBO = { + /*.matrix=*/util::cast(matrix), + /*.scale=*/{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}, + /*.world=*/{(float)renderableSize.width, (float)renderableSize.height}, + /*.pixel_coord_upper=*/{static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, + /*.pixel_coord_lower=*/{static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, + /*.texsize=*/{static_cast(textureSize.width), static_cast(textureSize.height)}, + }; + + uniforms.createOrUpdate("FillOutlinePatternDrawableUBO", &drawableUBO, context); + +#if MLN_RENDER_BACKEND_METAL + uniforms.addOrReplace("FillOutlinePatternPermutationUBO", fillOutlinePatternPermutationUniformBuffer); +#endif // MLN_RENDER_BACKEND_METAL + } + +#if MLN_RENDER_BACKEND_METAL + uniforms.addOrReplace("ExpressionInputsUBO", expressionUniformBuffer); +#endif // MLN_RENDER_BACKEND_METAL }); + + propertiesChanged = false; } } // namespace mbgl diff --git a/src/mbgl/renderer/layers/fill_layer_tweaker.hpp b/src/mbgl/renderer/layers/fill_layer_tweaker.hpp index e3015d488..7dd2bf73b 100644 --- a/src/mbgl/renderer/layers/fill_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/fill_layer_tweaker.hpp @@ -11,40 +11,27 @@ namespace mbgl { */ class FillLayerTweaker : public LayerTweaker { public: - FillLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + FillLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~FillLayerTweaker() override = default; void execute(LayerGroupBase&, const RenderTree&, const PaintParameters&) override; - static constexpr std::string_view FillTilePropsUBOName = "FillDrawableTilePropsUBO"; - static constexpr std::string_view FillInterpolateUBOName = "FillInterpolateUBO"; - private: - gfx::UniformBufferPtr propsBuffer; -}; + gfx::UniformBufferPtr fillPropsUniformBuffer; + gfx::UniformBufferPtr fillOutlinePropsUniformBuffer; + gfx::UniformBufferPtr fillPatternPropsUniformBuffer; + gfx::UniformBufferPtr fillOutlinePatternPropsUniformBuffer; -/// Evaluated properties that depend on the tile -struct alignas(16) FillDrawableTilePropsUBO { - /* 0 */ std::array pattern_from; - /* 16 */ std::array pattern_to; - /* 32 */ + gfx::UniformBufferPtr fillPermutationUniformBuffer; + gfx::UniformBufferPtr fillOutlinePermutationUniformBuffer; + gfx::UniformBufferPtr fillPatternPermutationUniformBuffer; + gfx::UniformBufferPtr fillOutlinePatternPermutationUniformBuffer; +#if MLN_RENDER_BACKEND_METAL + gfx::UniformBufferPtr expressionUniformBuffer; +#endif // MLN_RENDER_BACKEND_METAL }; -static_assert(sizeof(FillDrawableTilePropsUBO) == 32); - -/// Attribute interpolations -struct alignas(16) FillInterpolateUBO { - /* 0 */ float color_t; - /* 4 */ float opacity_t; - /* 8 */ float outline_color_t; - /* 12 */ float pattern_from_t; - /* 16 */ float pattern_to_t; - /* 20 */ float fade; - /* 24 */ float pad1, pad2; - /* 32 */ -}; -static_assert(sizeof(FillInterpolateUBO) == 32); } // namespace mbgl diff --git a/src/mbgl/renderer/layers/heatmap_layer_tweaker.hpp b/src/mbgl/renderer/layers/heatmap_layer_tweaker.hpp index 93e1c9084..7a2f0368d 100644 --- a/src/mbgl/renderer/layers/heatmap_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/heatmap_layer_tweaker.hpp @@ -9,8 +9,8 @@ namespace mbgl { */ class HeatmapLayerTweaker : public LayerTweaker { public: - HeatmapLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + HeatmapLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~HeatmapLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp b/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp index 0e6e58db1..7f4b47aa9 100644 --- a/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp @@ -9,8 +9,8 @@ namespace mbgl { */ class HeatmapTextureLayerTweaker : public LayerTweaker { public: - HeatmapTextureLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + HeatmapTextureLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~HeatmapTextureLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/hillshade_layer_tweaker.hpp b/src/mbgl/renderer/layers/hillshade_layer_tweaker.hpp index 03540dac1..3bb495866 100644 --- a/src/mbgl/renderer/layers/hillshade_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/hillshade_layer_tweaker.hpp @@ -9,8 +9,8 @@ namespace mbgl { */ class HillshadeLayerTweaker : public LayerTweaker { public: - HillshadeLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + HillshadeLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~HillshadeLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp b/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp index e7e220f5e..85afa3fe1 100644 --- a/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp @@ -9,8 +9,8 @@ namespace mbgl { */ class HillshadePrepareLayerTweaker : public LayerTweaker { public: - HillshadePrepareLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + HillshadePrepareLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~HillshadePrepareLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/line_layer_tweaker.cpp b/src/mbgl/renderer/layers/line_layer_tweaker.cpp index 5eb2e2f7e..de80f9b09 100644 --- a/src/mbgl/renderer/layers/line_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/line_layer_tweaker.cpp @@ -1,121 +1,28 @@ #include -#include -#include -#include + #include #include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if MLN_RENDER_BACKEND_METAL +#include +#endif // MLN_RENDER_BACKEND_METAL namespace mbgl { using namespace style; -struct alignas(16) LineUBO { - std::array matrix; - std::array units_to_pixels; - float ratio; - float device_pixel_ratio; -}; -static_assert(sizeof(LineUBO) % 16 == 0); -static constexpr std::string_view LineUBOName = "LineUBO"; - -struct alignas(16) LinePropertiesUBO { - Color color; - float blur; - float opacity; - float gapwidth; - float offset; - float width; - - float pad1; - std::array pad2; -}; -static_assert(sizeof(LinePropertiesUBO) % 16 == 0); -static constexpr std::string_view LinePropertiesUBOName = "LinePropertiesUBO"; - -struct alignas(16) LineGradientUBO { - std::array matrix; - std::array units_to_pixels; - float ratio; - float device_pixel_ratio; -}; -static_assert(sizeof(LineGradientUBO) % 16 == 0); -static constexpr std::string_view LineGradientUBOName = "LineGradientUBO"; - -struct alignas(16) LineGradientPropertiesUBO { - float blur; - float opacity; - float gapwidth; - float offset; - float width; - - float pad1; - std::array pad2; -}; -static_assert(sizeof(LineGradientPropertiesUBO) % 16 == 0); -static constexpr std::string_view LineGradientPropertiesUBOName = "LineGradientPropertiesUBO"; - -struct alignas(16) LinePatternUBO { - std::array matrix; - std::array scale; - std::array texsize; - std::array units_to_pixels; - float ratio; - float device_pixel_ratio; - float fade; - - float pad1; -}; -static_assert(sizeof(LinePatternUBO) % 16 == 0); -static constexpr std::string_view LinePatternUBOName = "LinePatternUBO"; - -struct alignas(16) LinePatternPropertiesUBO { - float blur; - float opacity; - float offset; - float gapwidth; - float width; - - float pad1; - std::array pad2; -}; -static_assert(sizeof(LinePatternPropertiesUBO) % 16 == 0); -static constexpr std::string_view LinePatternPropertiesUBOName = "LinePatternPropertiesUBO"; - -struct alignas(16) LineSDFUBO { - std::array matrix; - std::array units_to_pixels; - std::array patternscale_a; - std::array patternscale_b; - float ratio; - float device_pixel_ratio; - float tex_y_a; - float tex_y_b; - float sdfgamma; - float mix; -}; -static_assert(sizeof(LineSDFUBO) % 16 == 0); -static constexpr std::string_view LineSDFUBOName = "LineSDFUBO"; - -struct alignas(16) LineSDFPropertiesUBO { - Color color; - float blur; - float opacity; - float gapwidth; - float offset; - float width; - float floorwidth; - - std::array pad1; -}; -static_assert(sizeof(LineSDFPropertiesUBO) % 16 == 0); -static constexpr std::string_view LineSDFPropertiesUBOName = "LineSDFPropertiesUBO"; +using namespace shaders; void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTree& renderTree, @@ -124,6 +31,8 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const auto& evaluated = static_cast(*evaluatedProperties).evaluated; const auto& crossfade = static_cast(*evaluatedProperties).crossfade; + const auto zoom = parameters.state.getZoom(); + const auto getLinePropsBuffer = [&]() { if (!linePropertiesBuffer) { const LinePropertiesUBO linePropertiesUBO{ @@ -134,7 +43,8 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, /*offset =*/evaluated.get().constantOr(LineOffset::defaultValue()), /*width =*/evaluated.get().constantOr(LineWidth::defaultValue()), 0, - {0, 0}}; + 0, + 0}; linePropertiesBuffer = context.createUniformBuffer(&linePropertiesUBO, sizeof(linePropertiesUBO)); } return linePropertiesBuffer; @@ -148,7 +58,8 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, /*offset =*/evaluated.get().constantOr(LineOffset::defaultValue()), /*width =*/evaluated.get().constantOr(LineWidth::defaultValue()), 0, - {0, 0}}; + 0, + 0}; lineGradientPropertiesBuffer = context.createUniformBuffer(&lineGradientPropertiesUBO, sizeof(lineGradientPropertiesUBO)); } @@ -163,7 +74,8 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, /*gapwidth =*/evaluated.get().constantOr(LineGapWidth::defaultValue()), /*width =*/evaluated.get().constantOr(LineWidth::defaultValue()), 0, - {0, 0}}; + 0, + 0}; linePatternPropertiesBuffer = context.createUniformBuffer(&linePatternPropertiesUBO, sizeof(linePatternPropertiesUBO)); } @@ -179,12 +91,49 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, /*offset =*/evaluated.get().constantOr(LineOffset::defaultValue()), /*width =*/evaluated.get().constantOr(LineWidth::defaultValue()), /*floorwidth =*/evaluated.get().constantOr(LineFloorWidth::defaultValue()), - {0, 0}}; + 0, + 0}; lineSDFPropertiesBuffer = context.createUniformBuffer(&lineSDFPropertiesUBO, sizeof(lineSDFPropertiesUBO)); } return lineSDFPropertiesBuffer; }; +#if MLN_RENDER_BACKEND_METAL + using LineShaderClass = shaders::ShaderSource; + if (propertiesChanged) { + const auto source = [this](const std::string_view& attrName) { + return hasPropertyAsUniform(attrName) ? AttributeSource::Constant : AttributeSource::PerVertex; + }; + + const LinePermutationUBO permutationUBO = { + /* .color = */ {/*.source=*/source(LineShaderClass::attributes[2].name), /*.expression=*/{}}, + /* .blur = */ {/*.source=*/source(LineShaderClass::attributes[3].name), /*.expression=*/{}}, + /* .opacity = */ {/*.source=*/source(LineShaderClass::attributes[4].name), /*.expression=*/{}}, + /* .gapwidth = */ {/*.source=*/source(LineShaderClass::attributes[5].name), /*.expression=*/{}}, + /* .offset = */ {/*.source=*/source(LineShaderClass::attributes[6].name), /*.expression=*/{}}, + /* .width = */ {/*.source=*/source(LineShaderClass::attributes[7].name), /*.expression=*/{}}, + /* .floorwidth = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_from = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .pattern_to = */ {/*.source=*/AttributeSource::Constant, /*.expression=*/{}}, + /* .overdrawInspector = */ overdrawInspector, + /* .pad = */ 0, + 0, + 0, + 0}; + + if (permutationUniformBuffer) { + permutationUniformBuffer->update(&permutationUBO, sizeof(permutationUBO)); + } else { + permutationUniformBuffer = context.createUniformBuffer(&permutationUBO, sizeof(permutationUBO)); + } + propertiesChanged = false; + } + if (!expressionUniformBuffer) { + const auto expressionUBO = buildExpressionUBO(zoom, parameters.frameCount); + expressionUniformBuffer = context.createUniformBuffer(&expressionUBO, sizeof(expressionUBO)); + } +#endif + layerGroup.visitDrawables([&](gfx::Drawable& drawable) { const auto shader = drawable.getShader(); if (!drawable.getTileID() || !shader) { @@ -201,37 +150,31 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const auto matrix = getTileMatrix( tileID, renderTree, parameters.state, translation, anchor, nearClipped, inViewportPixelUnits); - LineType type = static_cast(drawable.getType()); + const LineType type = static_cast(drawable.getType()); switch (type) { case LineType::Simple: { - // main UBO const LineUBO lineUBO{ /*matrix = */ util::cast(matrix), /*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, - /*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(parameters.state.getZoom())), + /*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), /*device_pixel_ratio = */ parameters.pixelRatio}; - uniforms.createOrUpdate(LineUBOName, &lineUBO, context); - // properties UBO - uniforms.addOrReplace(LinePropertiesUBOName, getLinePropsBuffer()); + uniforms.createOrUpdate("LineUBO", &lineUBO, context); + uniforms.addOrReplace("LinePropertiesUBO", getLinePropsBuffer()); } break; case LineType::Gradient: { - // main UBO const LineGradientUBO lineGradientUBO{ /*matrix = */ util::cast(matrix), /*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, - /*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(parameters.state.getZoom())), + /*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), /*device_pixel_ratio = */ parameters.pixelRatio}; - uniforms.createOrUpdate(LineGradientUBOName, &lineGradientUBO, context); - - // properties UBO - uniforms.addOrReplace(LineGradientPropertiesUBOName, getLineGradientPropsBuffer()); + uniforms.createOrUpdate("LineGradientUBO", &lineGradientUBO, context); + uniforms.addOrReplace("LineGradientPropertiesUBO", getLineGradientPropsBuffer()); } break; case LineType::Pattern: { - // main UBO Size textureSize{0, 0}; if (const auto index = shader->getSamplerLocation("u_image")) { if (const auto& texture = drawable.getTexture(index.value())) { @@ -240,21 +183,19 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, } const LinePatternUBO linePatternUBO{ /*matrix =*/util::cast(matrix), - /*scale =*/ {parameters.pixelRatio, 1 / tileID.pixelsToTileUnits(1, parameters.state.getIntegerZoom()), crossfade.fromScale, crossfade.toScale}, /*texsize =*/{static_cast(textureSize.width), static_cast(textureSize.height)}, /*units_to_pixels =*/{1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, - /*ratio =*/1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(parameters.state.getZoom())), + /*ratio =*/1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), /*device_pixel_ratio =*/parameters.pixelRatio, /*fade =*/crossfade.t, 0}; - uniforms.createOrUpdate(LinePatternUBOName, &linePatternUBO, context); + uniforms.createOrUpdate("LinePatternUBO", &linePatternUBO, context); - // properties UBO - uniforms.addOrReplace(LinePatternPropertiesUBOName, getLinePatternPropsBuffer()); + uniforms.addOrReplace("LinePatternPropertiesUBO", getLinePatternPropsBuffer()); } break; case LineType::SDF: { @@ -265,7 +206,6 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, evaluated.get().to, lineData.linePatternCap); - // texture if (const auto index = shader->getSamplerLocation("u_image")) { if (!drawable.getTexture(index.value())) { const auto& texture = dashPatternTexture.getTexture(); @@ -276,16 +216,13 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, } } - // main UBO const LinePatternPos& posA = dashPatternTexture.getFrom(); const LinePatternPos& posB = dashPatternTexture.getTo(); const float widthA = posA.width * crossfade.fromScale; const float widthB = posB.width * crossfade.toScale; const LineSDFUBO lineSDFUBO{ /* matrix = */ util::cast(matrix), - /* units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, - /* patternscale_a = */ {1.0f / tileID.pixelsToTileUnits(widthA, parameters.state.getIntegerZoom()), -posA.height / 2.0f}, /* patternscale_b = */ @@ -299,10 +236,9 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, /* sdfgamma = */ static_cast(dashPatternTexture.getSize().width) / (std::min(widthA, widthB) * 256.0f * parameters.pixelRatio) / 2.0f, /* mix = */ crossfade.t}; - uniforms.createOrUpdate(LineSDFUBOName, &lineSDFUBO, context); + uniforms.createOrUpdate("LineSDFUBO", &lineSDFUBO, context); - // properties UBO - uniforms.addOrReplace(LineSDFPropertiesUBOName, getLineSDFPropsBuffer()); + uniforms.addOrReplace("LineSDFPropertiesUBO", getLineSDFPropsBuffer()); } } break; @@ -312,6 +248,11 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, "LineLayerTweaker: unknown line type: "s + std::to_string(mbgl::underlying_type(type))); } break; } + +#if MLN_RENDER_BACKEND_METAL + uniforms.addOrReplace("ExpressionInputsUBO", expressionUniformBuffer); + uniforms.addOrReplace("LinePermutationUBO", permutationUniformBuffer); +#endif // MLN_RENDER_BACKEND_METAL }); } diff --git a/src/mbgl/renderer/layers/line_layer_tweaker.hpp b/src/mbgl/renderer/layers/line_layer_tweaker.hpp index c7419f425..bb7f9eb68 100644 --- a/src/mbgl/renderer/layers/line_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/line_layer_tweaker.hpp @@ -23,9 +23,8 @@ public: SDF }; -public: - LineLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + LineLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} ~LineLayerTweaker() override = default; @@ -36,6 +35,11 @@ protected: gfx::UniformBufferPtr lineGradientPropertiesBuffer; gfx::UniformBufferPtr linePatternPropertiesBuffer; gfx::UniformBufferPtr lineSDFPropertiesBuffer; + +#if MLN_RENDER_BACKEND_METAL + gfx::UniformBufferPtr permutationUniformBuffer; + gfx::UniformBufferPtr expressionUniformBuffer; +#endif // MLN_RENDER_BACKEND_METAL }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/raster_layer_tweaker.cpp b/src/mbgl/renderer/layers/raster_layer_tweaker.cpp index 05479b0e6..1c9ae47e9 100644 --- a/src/mbgl/renderer/layers/raster_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/raster_layer_tweaker.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -14,23 +15,7 @@ namespace mbgl { using namespace style; -struct alignas(16) RasterDrawableUBO { - std::array matrix; - std::array spin_weights; - std::array tl_parent; - float scale_parent; - float buffer_scale; - float fade_t; - float opacity; - float brightness_low; - float brightness_high; - float saturation_factor; - float contrast_factor; - float pad1; - float pad2; -}; -static_assert(sizeof(RasterDrawableUBO) == 128); -static_assert(sizeof(RasterDrawableUBO) % 16 == 0); +using namespace shaders; void RasterLayerTweaker::execute([[maybe_unused]] LayerGroupBase& layerGroup, [[maybe_unused]] const RenderTree& renderTree, @@ -90,6 +75,9 @@ void RasterLayerTweaker::execute([[maybe_unused]] LayerGroupBase& layerGroup, /*.brightness_high = */ evaluated.get(), /*.saturation_factor = */ saturationFactor(evaluated.get()), /*.contrast_factor = */ contrastFactor(evaluated.get()), + /* .overdrawInspector = */ overdrawInspector, + 0, + 0, 0, 0}; auto& uniforms = drawable.mutableUniformBuffers(); diff --git a/src/mbgl/renderer/layers/raster_layer_tweaker.hpp b/src/mbgl/renderer/layers/raster_layer_tweaker.hpp index e03a55199..2d39ead75 100644 --- a/src/mbgl/renderer/layers/raster_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/raster_layer_tweaker.hpp @@ -14,8 +14,8 @@ using UniformBufferPtr = std::shared_ptr; */ class RasterLayerTweaker : public LayerTweaker { public: - RasterLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + RasterLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~RasterLayerTweaker() override = default; diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp index e55c5a68c..b13b44914 100644 --- a/src/mbgl/renderer/layers/render_background_layer.cpp +++ b/src/mbgl/renderer/layers/render_background_layer.cpp @@ -67,7 +67,7 @@ void RenderBackgroundLayer::evaluate(const PropertyEvaluationParameters& paramet #if MLN_DRAWABLE_RENDERER if (layerGroup) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); } #endif } @@ -216,6 +216,7 @@ static constexpr std::string_view BackgroundPatternShaderName = "BackgroundPatte void RenderBackgroundLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& state, + const std::shared_ptr&, [[maybe_unused]] const RenderTree& renderTree, [[maybe_unused]] UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); @@ -249,7 +250,7 @@ void RenderBackgroundLayer::update(gfx::ShaderRegistry& shaders, if (!layerGroup) { if (auto layerGroup_ = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID())) { - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup_->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); } } diff --git a/src/mbgl/renderer/layers/render_background_layer.hpp b/src/mbgl/renderer/layers/render_background_layer.hpp index fda0d7321..df3025941 100644 --- a/src/mbgl/renderer/layers/render_background_layer.hpp +++ b/src/mbgl/renderer/layers/render_background_layer.hpp @@ -28,6 +28,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index 4479a8f43..37b093170 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -1,23 +1,26 @@ #include -#include -#include -#include -#include -#include -#include -#include + #include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #if MLN_DRAWABLE_RENDERER +#include #include #include +#include +#include #include -#include #endif namespace mbgl { @@ -88,10 +91,8 @@ void RenderCircleLayer::evaluate(const PropertyEvaluationParameters& parameters) evaluatedProperties = std::move(properties); #if MLN_DRAWABLE_RENDERER - if (layerGroup) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); - } -#endif + updateLayerTweaker(); +#endif // MLN_DRAWABLE_RENDERER } bool RenderCircleLayer::hasTransition() const { @@ -265,27 +266,30 @@ bool RenderCircleLayer::queryIntersectsFeature(const GeometryCoordinates& queryG #if MLN_DRAWABLE_RENDERER namespace { -struct alignas(16) CircleInterpolateUBO { - float color_t; - float radius_t; - float blur_t; - float opacity_t; - float stroke_color_t; - float stroke_width_t; - float stroke_opacity_t; - float padding; -}; -static_assert(sizeof(CircleInterpolateUBO) % 16 == 0); - constexpr auto CircleShaderGroupName = "CircleShader"; -constexpr auto CircleInterpolateUBOName = "CircleInterpolateUBO"; constexpr auto VertexAttribName = "a_pos"; } // namespace +using namespace shaders; + +#if MLN_DRAWABLE_RENDERER +void RenderCircleLayer::updateLayerTweaker() { + if (layerGroup) { + tweaker = std::make_shared(getID(), evaluatedProperties); +#if MLN_RENDER_BACKEND_METAL + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); +#endif // MLN_RENDER_BACKEND_METAL + tweaker->enableOverdrawInspector(overdrawInspector); + layerGroup->setLayerTweaker(tweaker); + } +} +#endif // MLN_DRAWABLE_RENDERER + void RenderCircleLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& state, + [[maybe_unused]] const std::shared_ptr& updateParameters, [[maybe_unused]] const RenderTree& renderTree, UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); @@ -298,7 +302,7 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders, // Set up a layer group if (!layerGroup) { if (auto layerGroup_ = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID())) { - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup_->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); } } @@ -312,6 +316,14 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders, return; } + const bool overdraw = !!(updateParameters->debugOptions & MapDebugOptions::Overdraw); + if (overdrawInspector != overdraw) { + overdrawInspector = overdraw; + if (tweaker) { + tweaker->enableOverdrawInspector(overdrawInspector); + } + } + std::unique_ptr circleBuilder; constexpr auto renderPass = RenderPass::Translucent; @@ -361,7 +373,7 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders, // If there are already drawables for this tile, update their UBOs and move on to the next tile. auto updateExisting = [&](gfx::Drawable& drawable) { auto& uniforms = drawable.mutableUniformBuffers(); - uniforms.createOrUpdate(CircleInterpolateUBOName, &interpolateUBO, context); + uniforms.createOrUpdate("CircleInterpolateUBO", &interpolateUBO, context); }; if (0 < tileLayerGroup->visitDrawables(renderPass, tileID, std::move(updateExisting))) { continue; @@ -370,20 +382,30 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders, const auto interpBuffer = context.createUniformBuffer(&interpolateUBO, sizeof(interpolateUBO)); gfx::VertexAttributeArray circleVertexAttrs; - const auto propertiesAsUniforms = circleVertexAttrs.readDataDrivenPaintProperties( + auto propertiesAsUniforms_ = circleVertexAttrs.readDataDrivenPaintProperties( paintPropertyBinders, evaluated); - const auto circleShader = circleShaderGroup->getOrCreateShader(context, propertiesAsUniforms); + if (!circleShaderGroup) { + continue; + } + const auto circleShader = circleShaderGroup->getOrCreateShader(context, propertiesAsUniforms_); if (!circleShader) { continue; } +#if MLN_RENDER_BACKEND_METAL + propertiesAsUniforms = std::move(propertiesAsUniforms_); + if (tweaker) { + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); + } +#endif // MLN_RENDER_BACKEND_METAL + if (const auto& attr = circleVertexAttrs.add(VertexAttribName)) { attr->setSharedRawData(bucket.sharedVertices, offsetof(CircleLayoutVertex, a1), @@ -411,7 +433,7 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders, drawable->setTileID(tileID); auto& uniforms = drawable->mutableUniformBuffers(); - uniforms.addOrReplace(CircleInterpolateUBOName, interpBuffer); + uniforms.addOrReplace("CircleInterpolateUBO", interpBuffer); tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); ++stats.drawablesAdded; diff --git a/src/mbgl/renderer/layers/render_circle_layer.hpp b/src/mbgl/renderer/layers/render_circle_layer.hpp index 322d4804d..43ed687c3 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.hpp +++ b/src/mbgl/renderer/layers/render_circle_layer.hpp @@ -6,7 +6,14 @@ namespace mbgl { +#if MLN_LEGACY_RENDERER class CircleProgram; +#endif // MLN_LEGACY_RENDERER + +#if MLN_DRAWABLE_RENDERER +class CircleLayerTweaker; +using CircleLayerTweakerPtr = std::shared_ptr; +#endif // MLN_DRAWABLE_RENDERER class RenderCircleLayer final : public RenderLayer { public: @@ -18,6 +25,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif @@ -29,10 +37,6 @@ private: bool hasTransition() const override; bool hasCrossfade() const override; -#if MLN_LEGACY_RENDERER - void render(PaintParameters&) override; -#endif - bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, float, @@ -41,6 +45,15 @@ private: const mat4&, const FeatureState&) const override; +#if MLN_LEGACY_RENDERER + void render(PaintParameters&) override; +#endif // MLN_LEGACY_RENDERER + +#if MLN_DRAWABLE_RENDERER + void updateLayerTweaker(); +#endif // MLN_DRAWABLE_RENDERER + +private: // Paint properties style::CirclePaintProperties::Unevaluated unevaluated; @@ -48,8 +61,16 @@ private: // Programs std::shared_ptr circleProgram; #endif + #if MLN_DRAWABLE_RENDERER gfx::ShaderGroupPtr circleShaderGroup; + + CircleLayerTweakerPtr tweaker; +#if MLN_RENDER_BACKEND_METAL + std::vector propertiesAsUniforms; +#endif // MLN_RENDER_BACKEND_METAL + + bool overdrawInspector = false; #endif }; diff --git a/src/mbgl/renderer/layers/render_custom_layer.cpp b/src/mbgl/renderer/layers/render_custom_layer.cpp index cd7c233c7..16cba64f0 100644 --- a/src/mbgl/renderer/layers/render_custom_layer.cpp +++ b/src/mbgl/renderer/layers/render_custom_layer.cpp @@ -122,6 +122,7 @@ void RenderCustomLayer::render(PaintParameters& paintParameters) { void RenderCustomLayer::update([[maybe_unused]] gfx::ShaderRegistry& shaders, gfx::Context& context, [[maybe_unused]] const TransformState& state, + const std::shared_ptr&, [[maybe_unused]] const RenderTree& renderTree, [[maybe_unused]] UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); diff --git a/src/mbgl/renderer/layers/render_custom_layer.hpp b/src/mbgl/renderer/layers/render_custom_layer.hpp index 0cd7b16b6..876516c13 100644 --- a/src/mbgl/renderer/layers/render_custom_layer.hpp +++ b/src/mbgl/renderer/layers/render_custom_layer.hpp @@ -15,6 +15,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 0399a9cae..a63fbd967 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -76,7 +76,7 @@ void RenderFillExtrusionLayer::evaluate(const PropertyEvaluationParameters& para #if MLN_DRAWABLE_RENDERER if (layerGroup) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); } #endif // MLN_DRAWABLE_RENDERER } @@ -276,6 +276,7 @@ bool RenderFillExtrusionLayer::queryIntersectsFeature(const GeometryCoordinates& void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& state, + const std::shared_ptr&, const RenderTree& /*renderTree*/, UniqueChangeRequestVec& changes) { if (!renderTiles || renderTiles->empty() || passes == RenderPass::None) { @@ -286,7 +287,7 @@ void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders, // Set up a layer group if (!layerGroup) { if (auto layerGroup_ = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID())) { - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup_->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); } } @@ -403,6 +404,9 @@ void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders, FillExtrusionHeight, FillExtrusionPattern>(binders, evaluated); + if (!shaderGroup) { + continue; + } const auto shader = std::static_pointer_cast( shaderGroup->getOrCreateShader(context, uniformProps)); if (!shader) { diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp index c0f19017c..4a9af08b1 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp @@ -33,6 +33,7 @@ private: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif // MLN_DRAWABLE_RENDERER diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index ff0cb5779..3f53aa280 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -27,12 +27,15 @@ #include #include #include +#include +#include #include #endif namespace mbgl { using namespace style; +using namespace shaders; namespace { @@ -93,8 +96,9 @@ void RenderFillLayer::evaluate(const PropertyEvaluationParameters& parameters) { #if MLN_DRAWABLE_RENDERER if (layerGroup) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); } + updateLayerTweaker(); #endif } @@ -295,9 +299,22 @@ bool RenderFillLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeo } #if MLN_DRAWABLE_RENDERER + +void RenderFillLayer::updateLayerTweaker() { + if (layerGroup) { + tweaker = std::make_shared(getID(), evaluatedProperties); +#if MLN_RENDER_BACKEND_METAL + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); +#endif // MLN_RENDER_BACKEND_METAL + tweaker->enableOverdrawInspector(overdrawInspector); + layerGroup->setLayerTweaker(tweaker); + } +} + void RenderFillLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& state, + const std::shared_ptr& updateParameters, [[maybe_unused]] const RenderTree& renderTree, [[maybe_unused]] UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); @@ -307,11 +324,20 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, return; } + const bool overdraw = !!(updateParameters->debugOptions & MapDebugOptions::Overdraw); + if (overdrawInspector != overdraw) { + overdrawInspector = overdraw; + if (tweaker) { + tweaker->enableOverdrawInspector(overdrawInspector); + } + } + // Set up a layer group if (!layerGroup) { if (auto layerGroup_ = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID())) { - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup_->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); + updateLayerTweaker(); } } auto* tileLayerGroup = static_cast(layerGroup.get()); @@ -341,22 +367,6 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, const auto layerPrefix = getID() + "/"; const auto renderPass = RenderPass::Translucent; - const auto finish = [&](gfx::DrawableBuilder& builder, - const OverscaledTileID& tileID, - const FillInterpolateUBO& interpUBO, - const FillDrawableTilePropsUBO& tileUBO) { - builder.flush(); - - for (auto& drawable : builder.clearDrawables()) { - drawable->setTileID(tileID); - auto& uniforms = drawable->mutableUniformBuffers(); - uniforms.createOrUpdate(FillLayerTweaker::FillInterpolateUBOName, &interpUBO, context); - uniforms.createOrUpdate(FillLayerTweaker::FillTilePropsUBOName, &tileUBO, context); - tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); - ++stats.drawablesAdded; - } - }; - const auto commonInit = [&](gfx::DrawableBuilder& builder) { builder.setCullFaceMode(gfx::CullFaceMode::disabled()); builder.setEnableStencil(true); @@ -399,24 +409,109 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, binders.setPatternParameters(patternPosA, patternPosB, crossfade); const auto zoom = static_cast(state.getZoom()); - const FillInterpolateUBO interpolateUBO = { - /* .color_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), - /* .outline_color_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), - /* .pattern_from_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), - /* .pattern_to_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), - /* .fade = */ crossfade.t, - /* .padding = */ 0, - 0}; - const FillDrawableTilePropsUBO tileProps = { - /* pattern_from = */ patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, - /* pattern_to = */ patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, + std::optional fillInterpolateUBO = std::nullopt; + std::optional fillOutlineInterpolateUBO = std::nullopt; + std::optional fillPatternInterpolateUBO = std::nullopt; + std::optional fillOutlinePatternInterpolateUBO = std::nullopt; + + auto getFillInterpolateUBO = [&]() -> const FillInterpolateUBO& { + if (!fillInterpolateUBO) { + fillInterpolateUBO = { + /* .color_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + /* .opacity_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + 0, + 0, + }; + } + + return *fillInterpolateUBO; + }; + + auto getFillOutlineInterpolateUBO = [&]() -> const FillOutlineInterpolateUBO& { + if (!fillOutlineInterpolateUBO) { + fillOutlineInterpolateUBO = { + /* .color_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + /* .opacity_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + 0, + 0, + }; + } + + return *fillOutlineInterpolateUBO; + }; + + auto getFillPatternInterpolateUBO = [&]() -> const FillPatternInterpolateUBO& { + if (!fillPatternInterpolateUBO) { + fillPatternInterpolateUBO = { + /* .pattern_from_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + /* .pattern_to_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + /* .opacity_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + 0, + }; + } + + return *fillPatternInterpolateUBO; + }; + + auto getFillOutlinePatternInterpolateUBO = [&]() -> const FillOutlinePatternInterpolateUBO& { + if (!fillOutlinePatternInterpolateUBO) { + fillOutlinePatternInterpolateUBO = { + /* .pattern_from_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + /* .pattern_to_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + /* .opacity_t = */ std::get<0>(binders.get()->interpolationFactor(zoom)), + 0, + }; + } + + return *fillOutlinePatternInterpolateUBO; + }; + + std::optional fillPatternTilePropsUBO = std::nullopt; + auto getFillPatternTilePropsUBO = [&]() -> const FillPatternTilePropsUBO& { + if (!fillPatternTilePropsUBO) { + fillPatternTilePropsUBO = { + /* pattern_from = */ patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, + /* pattern_to = */ patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, + }; + } + + return *fillPatternTilePropsUBO; + }; + + std::optional fillOutlinePatternTilePropsUBO = std::nullopt; + auto getFillOutlinePatternTilePropsUBO = [&]() -> const FillOutlinePatternTilePropsUBO& { + if (!fillOutlinePatternTilePropsUBO) { + fillOutlinePatternTilePropsUBO = { + /* pattern_from = */ patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, + /* pattern_to = */ patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, + }; + } + + return *fillOutlinePatternTilePropsUBO; + }; + + gfx::DrawableTweakerPtr atlasTweaker; + auto getAtlasTweaker = [&]() { + if (!atlasTweaker) { + if (const auto& atlases = tile.getAtlasTextures(); atlases && atlases->icon) { + atlasTweaker = std::make_shared( + atlases, + std::string(), + IconTextureName, + /*isText*/ false, + /*sdfIcons*/ true, // to force linear filter + /*rotationAlignment_*/ AlignmentType::Auto, + /*iconScaled*/ false, + /*textSizeIsZoomConstant_*/ false); + } + } + return atlasTweaker; }; // `Fill*Program` all use `style::FillPaintProperties` gfx::VertexAttributeArray vertexAttrs; - const auto uniformProps = + const auto propertiesAsUniforms_ = vertexAttrs.readDataDrivenPaintProperties(binders, evaluated); @@ -432,28 +527,49 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, // If we already have drawables for this tile, update them. auto updateExisting = [&](gfx::Drawable& drawable) { auto& uniforms = drawable.mutableUniformBuffers(); - uniforms.createOrUpdate(FillLayerTweaker::FillInterpolateUBOName, &interpolateUBO, context); - uniforms.createOrUpdate(FillLayerTweaker::FillTilePropsUBOName, &tileProps, context); + if (uniforms.get("FillInterpolateUBO")) { + uniforms.createOrUpdate("FillInterpolateUBO", &getFillInterpolateUBO(), context); + } else if (uniforms.get("FillOutlineInterpolateUBO")) { + uniforms.createOrUpdate("FillOutlineInterpolateUBO", &getFillOutlineInterpolateUBO(), context); + } else if (uniforms.get("FillPatternInterpolateUBO")) { + uniforms.createOrUpdate("FillPatternInterpolateUBO", &getFillPatternInterpolateUBO(), context); + uniforms.createOrUpdate("FillPatternTilePropsUBO", &getFillPatternTilePropsUBO(), context); + } else if (uniforms.get("FillOutlinePatternInterpolateUBO")) { + uniforms.createOrUpdate( + "FillOutlinePatternInterpolateUBO", &getFillOutlinePatternInterpolateUBO(), context); + uniforms.createOrUpdate( + "FillOutlinePatternTilePropsUBO", &getFillOutlinePatternTilePropsUBO(), context); + } else { + assert(false); + } + drawable.setVertexAttributes(vertexAttrs); }; if (0 < tileLayerGroup->visitDrawables(renderPass, tileID, std::move(updateExisting))) { continue; } - // Share UBO buffers among any drawables created for this tile - const auto interpBuffer = context.createUniformBuffer(&interpolateUBO, sizeof(interpolateUBO)); - const auto tilePropsBuffer = context.createUniformBuffer(&tileProps, sizeof(tileProps)); - if (unevaluated.get().isUndefined()) { // Fill will occur in opaque or translucent pass based on `opaquePassCutoff`. // Outline always occurs in translucent pass, defaults to fill color const auto doOutline = evaluated.get(); + if (!fillShaderGroup || (doOutline && !outlineShaderGroup)) { + continue; + } const auto fillShader = std::static_pointer_cast( - fillShaderGroup->getOrCreateShader(context, uniformProps)); - const auto outlineShader = doOutline ? std::static_pointer_cast( - outlineShaderGroup->getOrCreateShader(context, uniformProps)) - : nullptr; + fillShaderGroup->getOrCreateShader(context, propertiesAsUniforms_)); + const auto outlineShader = doOutline + ? std::static_pointer_cast( + outlineShaderGroup->getOrCreateShader(context, propertiesAsUniforms_)) + : nullptr; + +#if MLN_RENDER_BACKEND_METAL + propertiesAsUniforms = std::move(propertiesAsUniforms_); + if (tweaker) { + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); + } +#endif // MLN_RENDER_BACKEND_METAL if (!fillBuilder && fillShader) { if (auto builder = context.createDrawableBuilder(layerPrefix + "fill")) { @@ -479,7 +595,20 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, } } - if (fillBuilder) { + const auto finish = + [&](gfx::DrawableBuilder& builder, const std::string& interpolateUBOName, const auto& interpolateUBO) { + builder.flush(); + + for (auto& drawable : builder.clearDrawables()) { + drawable->setTileID(tileID); + auto& uniforms = drawable->mutableUniformBuffers(); + uniforms.createOrUpdate(interpolateUBOName, &interpolateUBO, context); + tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); + ++stats.drawablesAdded; + } + }; + + if (fillBuilder && bucket.sharedTriangles->elements()) { fillBuilder->setShader(fillShader); if (outlineBuilder) { fillBuilder->setVertexAttributes(vertexAttrs); @@ -491,15 +620,15 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, bucket.sharedTriangles, bucket.triangleSegments.data(), bucket.triangleSegments.size()); - finish(*fillBuilder, tileID, interpolateUBO, tileProps); + finish(*fillBuilder, "FillInterpolateUBO", getFillInterpolateUBO()); } - if (outlineBuilder) { + if (outlineBuilder && bucket.sharedLines->elements()) { outlineBuilder->setShader(outlineShader); outlineBuilder->setVertexAttributes(std::move(vertexAttrs)); outlineBuilder->setRawVertices({}, vertexCount, gfx::AttributeDataType::Short2); outlineBuilder->setSegments( gfx::Lines(2), bucket.sharedLines, bucket.lineSegments.data(), bucket.lineSegments.size()); - finish(*outlineBuilder, tileID, interpolateUBO, tileProps); + finish(*outlineBuilder, "FillOutlineInterpolateUBO", getFillOutlineInterpolateUBO()); } } else { // FillPattern is defined if ((renderPass & RenderPass::Translucent) == 0) { @@ -509,16 +638,28 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, // Outline does not default to fill in the pattern case const auto doOutline = evaluated.get() && unevaluated.get().isUndefined(); + if (!patternShaderGroup || (doOutline && !outlinePatternShaderGroup)) { + continue; + } + const auto fillShader = std::static_pointer_cast( - patternShaderGroup->getOrCreateShader(context, uniformProps)); - const auto outlineShader = doOutline - ? std::static_pointer_cast( - outlinePatternShaderGroup->getOrCreateShader(context, uniformProps)) - : nullptr; + patternShaderGroup->getOrCreateShader(context, propertiesAsUniforms_)); + const auto outlineShader = doOutline ? std::static_pointer_cast( + outlinePatternShaderGroup->getOrCreateShader( + context, propertiesAsUniforms_)) + : nullptr; + +#if MLN_RENDER_BACKEND_METAL + propertiesAsUniforms = std::move(propertiesAsUniforms_); + if (tweaker) { + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); + } +#endif // MLN_RENDER_BACKEND_METAL if (!patternBuilder) { if (auto builder = context.createDrawableBuilder(layerPrefix + "fill-pattern")) { commonInit(*builder); + builder->setShader(fillShader); builder->setDepthType(gfx::DepthMaskType::ReadWrite); builder->setColorMode(gfx::ColorMode::alphaBlended()); builder->setSubLayerIndex(1); @@ -529,6 +670,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, if (doOutline && !outlinePatternBuilder) { if (auto builder = context.createDrawableBuilder(layerPrefix + "fill-outline-pattern")) { commonInit(*builder); + builder->setShader(outlineShader); builder->setLineWidth(2.0f); builder->setDepthType(gfx::DepthMaskType::ReadOnly); builder->setColorMode(gfx::ColorMode::alphaBlended()); @@ -540,28 +682,29 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, if (patternBuilder) { patternBuilder->clearTweakers(); + patternBuilder->addTweaker(getAtlasTweaker()); } if (outlinePatternBuilder) { outlinePatternBuilder->clearTweakers(); + outlinePatternBuilder->addTweaker(getAtlasTweaker()); } - if (patternBuilder || outlinePatternBuilder) { - if (const auto& atlases = tile.getAtlasTextures()) { - auto tweaker = std::make_shared(atlases, - /*glyphName=*/std::string(), - std::string(IconTextureName), - /*isText=*/false, - false, - style::AlignmentType::Auto, - false, - false); - if (patternBuilder) { - patternBuilder->addTweaker(tweaker); - } - if (outlinePatternBuilder) { - outlinePatternBuilder->addTweaker(std::move(tweaker)); - } + + const auto finish = [&](gfx::DrawableBuilder& builder, + const std::string& interpolateName, + const auto& interpolateUBO, + const std::string& tileUBOName, + const auto& tileUBO) { + builder.flush(); + + for (auto& drawable : builder.clearDrawables()) { + drawable->setTileID(tileID); + auto& uniforms = drawable->mutableUniformBuffers(); + uniforms.createOrUpdate(interpolateName, &interpolateUBO, context); + uniforms.createOrUpdate(tileUBOName, &tileUBO, context); + tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); + ++stats.drawablesAdded; } - } + }; if (patternBuilder) { patternBuilder->setShader(fillShader); @@ -577,7 +720,11 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, bucket.triangleSegments.data(), bucket.triangleSegments.size()); - finish(*patternBuilder, tileID, interpolateUBO, tileProps); + finish(*patternBuilder, + "FillPatternInterpolateUBO", + getFillPatternInterpolateUBO(), + "FillPatternTilePropsUBO", + getFillPatternTilePropsUBO()); } if (outlinePatternBuilder) { outlinePatternBuilder->setShader(outlineShader); @@ -587,7 +734,11 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders, outlinePatternBuilder->setSegments( gfx::Lines(2), bucket.sharedLines, bucket.lineSegments.data(), bucket.lineSegments.size()); - finish(*outlinePatternBuilder, tileID, interpolateUBO, tileProps); + finish(*outlinePatternBuilder, + "FillOutlinePatternInterpolateUBO", + getFillOutlinePatternInterpolateUBO(), + "FillOutlinePatternTilePropsUBO", + getFillOutlinePatternTilePropsUBO()); } } } diff --git a/src/mbgl/renderer/layers/render_fill_layer.hpp b/src/mbgl/renderer/layers/render_fill_layer.hpp index 5e253122c..c077d926f 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_layer.hpp @@ -15,6 +15,11 @@ class FillPatternProgram; class FillOutlineProgram; class FillOutlinePatternProgram; +#if MLN_DRAWABLE_RENDERER +class FillLayerTweaker; +using FillLayerTweakerPtr = std::shared_ptr; +#endif // MLN_DRAWABLE_RENDERER + class RenderFillLayer final : public RenderLayer { public: explicit RenderFillLayer(Immutable); @@ -25,6 +30,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif @@ -40,6 +46,10 @@ private: void render(PaintParameters&) override; #endif +#if MLN_DRAWABLE_RENDERER + void updateLayerTweaker(); +#endif // MLN_DRAWABLE_RENDERER + bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, float, @@ -63,6 +73,13 @@ private: gfx::ShaderGroupPtr outlineShaderGroup; gfx::ShaderGroupPtr patternShaderGroup; gfx::ShaderGroupPtr outlinePatternShaderGroup; + + FillLayerTweakerPtr tweaker; +#if MLN_RENDER_BACKEND_METAL + std::vector propertiesAsUniforms; +#endif // MLN_RENDER_BACKEND_METAL + bool overdrawInspector = false; + #endif }; diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index d611c6e94..17a3900b8 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -68,10 +68,11 @@ void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters #if MLN_DRAWABLE_RENDERER if (renderTarget) { - renderTarget->getLayerGroup(0)->setLayerTweaker(std::make_shared(evaluatedProperties)); + renderTarget->getLayerGroup(0)->setLayerTweaker( + std::make_shared(getID(), evaluatedProperties)); } if (layerGroup) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); } #endif } @@ -280,6 +281,7 @@ constexpr auto VertexAttribName = "a_pos"; void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& state, + const std::shared_ptr&, [[maybe_unused]] const RenderTree& renderTree, UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); @@ -305,7 +307,7 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders, if (!tileLayerGroup) { return; } - tileLayerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + tileLayerGroup->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); renderTarget->addLayerGroup(tileLayerGroup, /*replace=*/true); } @@ -375,6 +377,9 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders, heatmapVertexAttrs.readDataDrivenPaintProperties(paintPropertyBinders, evaluated); + if (!heatmapShaderGroup) { + continue; + } const auto heatmapShader = heatmapShaderGroup->getOrCreateShader(context, propertiesAsUniforms); if (!heatmapShader) { continue; @@ -417,7 +422,7 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders, if (!layerGroup_) { return; } - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup_->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); } diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.hpp b/src/mbgl/renderer/layers/render_heatmap_layer.hpp index c5b64bc67..196454305 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.hpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.hpp @@ -23,6 +23,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp index 48069aefb..3ba9691f0 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp @@ -73,7 +73,7 @@ void RenderHillshadeLayer::evaluate(const PropertyEvaluationParameters& paramete evaluatedProperties = std::move(properties); #if MLN_DRAWABLE_RENDERER if (layerGroup) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); } #endif } @@ -287,6 +287,7 @@ constexpr auto TexturePosAttribName = "a_texture_pos"; void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, [[maybe_unused]] const TransformState& state, + const std::shared_ptr&, [[maybe_unused]] const RenderTree& renderTree, UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); @@ -302,7 +303,7 @@ void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders, if (!layerGroup_) { return; } - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup_->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); } @@ -370,7 +371,8 @@ void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders, if (!singleTileLayerGroup) { return; } - singleTileLayerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + singleTileLayerGroup->setLayerTweaker( + std::make_shared(getID(), evaluatedProperties)); renderTarget->addLayerGroup(singleTileLayerGroup, /*replace=*/true); gfx::VertexAttributeArray hillshadePrepareVertexAttrs; diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.hpp b/src/mbgl/renderer/layers/render_hillshade_layer.hpp index b1f0cb747..ebf0baa7a 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.hpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.hpp @@ -26,6 +26,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 2b50abcbc..5146ce0ca 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -5,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -15,9 +16,10 @@ #include #include #include -#include -#include #include +#include +#include +#include #if MLN_DRAWABLE_RENDERER #include @@ -28,9 +30,21 @@ #include #endif +#if MLN_DRAWABLE_RENDERER +#include +#include +#include +#include +#include +#include +#include +#include +#endif + namespace mbgl { using namespace style; +using namespace shaders; namespace { @@ -75,9 +89,7 @@ void RenderLineLayer::evaluate(const PropertyEvaluationParameters& parameters) { evaluatedProperties = std::move(properties); #if MLN_DRAWABLE_RENDERER - if (layerGroup && layerGroup->getLayerTweaker()) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); - } + updateLayerTweaker(); #endif } @@ -344,74 +356,24 @@ float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature, #if MLN_DRAWABLE_RENDERER /// Property interpolation UBOs -struct alignas(16) LineInterpolationUBO { - float color_t; - float blur_t; - float opacity_t; - float gapwidth_t; - float offset_t; - float width_t; - float pad1; - float pad2; -}; -static_assert(sizeof(LineInterpolationUBO) % 16 == 0); -static constexpr std::string_view LineInterpolationUBOName = "LineInterpolationUBO"; - -struct alignas(16) LineGradientInterpolationUBO { - float blur_t; - float opacity_t; - float gapwidth_t; - float offset_t; - float width_t; - - float pad1; - std::array pad2; -}; -static_assert(sizeof(LineGradientInterpolationUBO) % 16 == 0); -static constexpr std::string_view LineGradientInterpolationUBOName = "LineGradientInterpolationUBO"; - -struct alignas(16) LinePatternInterpolationUBO { - float blur_t; - float opacity_t; - float offset_t; - float gapwidth_t; - float width_t; - float pattern_from_t; - float pattern_to_t; - - float pad1; -}; -static_assert(sizeof(LinePatternInterpolationUBO) % 16 == 0); -static constexpr std::string_view LinePatternInterpolationUBOName = "LinePatternInterpolationUBO"; - -struct alignas(16) LineSDFInterpolationUBO { - float color_t; - float blur_t; - float opacity_t; - float gapwidth_t; - float offset_t; - float width_t; - float floorwidth_t; - - float pad1; -}; -static_assert(sizeof(LineSDFInterpolationUBO) % 16 == 0); -static constexpr std::string_view LineSDFInterpolationUBOName = "LineSDFInterpolationUBO"; - -/// Evaluated properties that depend on the tile -struct alignas(16) LinePatternTilePropertiesUBO { - std::array pattern_from; - std::array pattern_to; -}; -static_assert(sizeof(LinePatternTilePropertiesUBO) % 16 == 0); -static constexpr std::string_view LinePatternTilePropertiesUBOName = "LinePatternTilePropertiesUBO"; +void RenderLineLayer::updateLayerTweaker() { + if (layerGroup) { + tweaker = std::make_shared(getID(), evaluatedProperties); +#if MLN_RENDER_BACKEND_METAL + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); +#endif // MLN_RENDER_BACKEND_METAL + tweaker->enableOverdrawInspector(overdrawInspector); + layerGroup->setLayerTweaker(tweaker); + } +} static constexpr auto LineImageUniformName = "u_image"; void RenderLineLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& state, + const std::shared_ptr& updateParameters, [[maybe_unused]] const RenderTree& renderTree, [[maybe_unused]] UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); @@ -421,11 +383,19 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, return; } + const bool overdraw = !!(updateParameters->debugOptions & MapDebugOptions::Overdraw); + if (overdrawInspector != overdraw) { + overdrawInspector = overdraw; + if (tweaker) { + tweaker->enableOverdrawInspector(overdrawInspector); + } + } + // Set up a layer group if (!layerGroup) { if (auto layerGroup_ = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID())) { - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); + updateLayerTweaker(); } } auto* tileLayerGroup = static_cast(layerGroup.get()); @@ -538,7 +508,8 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, /*offset_t =*/std::get<0>(paintPropertyBinders.get()->interpolationFactor(zoom)), /*width_t =*/std::get<0>(paintPropertyBinders.get()->interpolationFactor(zoom)), 0, - {0, 0}}; + 0, + 0}; const LinePatternInterpolationUBO linePatternInterpolationUBO{ /*blur_t =*/std::get<0>(paintPropertyBinders.get()->interpolationFactor(zoom)), /*opacity_t =*/std::get<0>(paintPropertyBinders.get()->interpolationFactor(zoom)), @@ -568,48 +539,63 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, // update existing drawables tileLayerGroup->visitDrawables(renderPass, tileID, [&](gfx::Drawable& drawable) { - // TODO: use line type + const auto& shader = drawable.getShader(); + const auto& shaderUniforms = shader->getUniformBlocks(); + auto& drawableUniforms = drawable.mutableUniformBuffers(); + // simple line interpolation UBO - if (drawable.getShader()->getUniformBlocks().get(std::string(LineInterpolationUBOName))) { - drawable.mutableUniformBuffers().createOrUpdate( - LineInterpolationUBOName, &lineInterpolationUBO, context); + if (shaderUniforms.get("LineInterpolationUBO")) { + drawableUniforms.createOrUpdate("LineInterpolationUBO", &lineInterpolationUBO, context); } // gradient line interpolation UBO - else if (drawable.getShader()->getUniformBlocks().get(std::string(LineGradientInterpolationUBOName))) { - drawable.mutableUniformBuffers().createOrUpdate( - LineGradientInterpolationUBOName, &lineGradientInterpolationUBO, context); + else if (shaderUniforms.get("LineGradientInterpolationUBO")) { + drawableUniforms.createOrUpdate("LineGradientInterpolationUBO", &lineGradientInterpolationUBO, context); } // pattern line interpolation UBO - else if (drawable.getShader()->getUniformBlocks().get(std::string(LinePatternInterpolationUBOName))) { + else if (shaderUniforms.get("LinePatternInterpolationUBO")) { // interpolation - drawable.mutableUniformBuffers().createOrUpdate( - LinePatternInterpolationUBOName, &linePatternInterpolationUBO, context); + drawableUniforms.createOrUpdate("LinePatternInterpolationUBO", &linePatternInterpolationUBO, context); // tile properties - drawable.mutableUniformBuffers().createOrUpdate( - LinePatternTilePropertiesUBOName, &linePatternTilePropertiesUBO, context); + drawableUniforms.createOrUpdate("LinePatternTilePropertiesUBO", &linePatternTilePropertiesUBO, context); } // SDF line interpolation UBO - else if (drawable.getShader()->getUniformBlocks().get(std::string(LineSDFInterpolationUBOName))) { - drawable.mutableUniformBuffers().createOrUpdate( - LineSDFInterpolationUBOName, &lineSDFInterpolationUBO, context); + else if (shaderUniforms.get("LineSDFInterpolationUBO")) { + drawableUniforms.createOrUpdate("LineSDFInterpolationUBO", &lineSDFInterpolationUBO, context); } }); - if (tileLayerGroup->getDrawableCount(renderPass, tileID) > 0) continue; + if (tileLayerGroup->getDrawableCount(renderPass, tileID) > 0) { + continue; + } if (!evaluated.get().from.empty()) { // dash array line (SDF) gfx::VertexAttributeArray vertexAttrs; - const auto propertiesAsUniforms = vertexAttrs.readDataDrivenPaintProperties( - paintPropertyBinders, evaluated); - auto builder = createLineBuilder("lineSDF", - lineSDFShaderGroup->getOrCreateShader(context, propertiesAsUniforms)); + auto propertiesAsUniforms_ = vertexAttrs.readDataDrivenPaintProperties(paintPropertyBinders, + evaluated); + + if (!lineSDFShaderGroup) { + continue; + } + auto shader = lineSDFShaderGroup->getOrCreateShader(context, propertiesAsUniforms_); + if (!shader) { + continue; + } + +#if MLN_RENDER_BACKEND_METAL + propertiesAsUniforms = std::move(propertiesAsUniforms_); + if (tweaker) { + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); + } +#endif // MLN_RENDER_BACKEND_METAL + + auto builder = createLineBuilder("lineSDF", std::move(shader)); // vertices, attributes and segments addAttributes(*builder, bucket, std::move(vertexAttrs)); @@ -624,7 +610,7 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, drawable->setTileID(tileID); drawable->setData(std::make_unique(cap)); drawable->mutableUniformBuffers().createOrUpdate( - LineSDFInterpolationUBOName, &lineSDFInterpolationUBO, context); + "LineSDFInterpolationUBO", &lineSDFInterpolationUBO, context); tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); ++stats.drawablesAdded; @@ -633,15 +619,30 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, // pattern line gfx::VertexAttributeArray vertexAttrs; paintPropertyBinders.setPatternParameters(patternPosA, patternPosB, crossfade); - auto propertiesAsUniforms = vertexAttrs.readDataDrivenPaintProperties(paintPropertyBinders, - evaluated); - auto builder = createLineBuilder("linePattern", - linePatternShaderGroup->getOrCreateShader(context, propertiesAsUniforms)); + auto propertiesAsUniforms_ = vertexAttrs.readDataDrivenPaintProperties(paintPropertyBinders, + evaluated); + + if (!linePatternShaderGroup) { + continue; + } + auto shader = linePatternShaderGroup->getOrCreateShader(context, propertiesAsUniforms_); + if (!shader) { + continue; + } + +#if MLN_RENDER_BACKEND_METAL + propertiesAsUniforms = std::move(propertiesAsUniforms_); + if (tweaker) { + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); + } +#endif // MLN_RENDER_BACKEND_METAL + + auto builder = createLineBuilder("linePattern", std::move(shader)); // vertices and attributes addAttributes(*builder, bucket, std::move(vertexAttrs)); @@ -662,33 +663,44 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, builder->addTweaker(iconTweaker); - // segments setSegments(builder, bucket); - // finish builder->flush(); for (auto& drawable : builder->clearDrawables()) { drawable->setType(mbgl::underlying_type(LineLayerTweaker::LineType::Pattern)); drawable->setTileID(tileID); drawable->mutableUniformBuffers().createOrUpdate( - LinePatternInterpolationUBOName, &linePatternInterpolationUBO, context); + "LinePatternInterpolationUBO", &linePatternInterpolationUBO, context); drawable->mutableUniformBuffers().createOrUpdate( - LinePatternTilePropertiesUBOName, &linePatternTilePropertiesUBO, context); + "LinePatternTilePropertiesUBO", &linePatternTilePropertiesUBO, context); tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); ++stats.drawablesAdded; } } - } else if (!unevaluated.get().getValue().isUndefined()) { // gradient line gfx::VertexAttributeArray vertexAttrs; - auto propertiesAsUniforms = + auto propertiesAsUniforms_ = vertexAttrs.readDataDrivenPaintProperties( paintPropertyBinders, evaluated); - auto builder = createLineBuilder("lineGradient", - lineGradientShaderGroup->getOrCreateShader(context, propertiesAsUniforms)); + if (!lineGradientShaderGroup) { + continue; + } + auto shader = lineGradientShaderGroup->getOrCreateShader(context, propertiesAsUniforms_); + if (!shader) { + continue; + } + +#if MLN_RENDER_BACKEND_METAL + propertiesAsUniforms = std::move(propertiesAsUniforms_); + if (tweaker) { + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); + } +#endif // MLN_RENDER_BACKEND_METAL + + auto builder = createLineBuilder("lineGradient", std::move(shader)); // vertices and attributes addAttributes(*builder, bucket, std::move(vertexAttrs)); @@ -715,7 +727,7 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, drawable->setType(mbgl::underlying_type(LineLayerTweaker::LineType::Gradient)); drawable->setTileID(tileID); drawable->mutableUniformBuffers().createOrUpdate( - LineGradientInterpolationUBOName, &lineGradientInterpolationUBO, context); + "LineGradientInterpolationUBO", &lineGradientInterpolationUBO, context); tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); ++stats.drawablesAdded; @@ -726,14 +738,35 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, } else { // simple line gfx::VertexAttributeArray vertexAttrs; - const auto propertiesAsUniforms = vertexAttrs.readDataDrivenPaintProperties(paintPropertyBinders, - evaluated); - auto builder = createLineBuilder("line", lineShaderGroup->getOrCreateShader(context, propertiesAsUniforms)); + const auto propertiesAsUniforms_ = vertexAttrs.readDataDrivenPaintProperties( + paintPropertyBinders, evaluated); + + assert(6 == propertiesAsUniforms_.size()); + assert(vertexAttrs.size() == (size_t)std::count_if(propertiesAsUniforms_.begin(), + propertiesAsUniforms_.end(), + [](const auto& s) { return s.empty(); })); + + if (!lineShaderGroup) { + continue; + } + auto shader = lineShaderGroup->getOrCreateShader(context, propertiesAsUniforms_); + if (!shader) { + continue; + } + +#if MLN_RENDER_BACKEND_METAL + propertiesAsUniforms = std::move(propertiesAsUniforms_); + if (tweaker) { + tweaker->setPropertiesAsUniforms(propertiesAsUniforms); + } +#endif // MLN_RENDER_BACKEND_METAL + + auto builder = createLineBuilder("line", std::move(shader)); // vertices, attributes and segments addAttributes(*builder, bucket, std::move(vertexAttrs)); @@ -745,7 +778,7 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders, drawable->setType(mbgl::underlying_type(LineLayerTweaker::LineType::Simple)); drawable->setTileID(tileID); drawable->mutableUniformBuffers().createOrUpdate( - LineInterpolationUBOName, &lineInterpolationUBO, context); + "LineInterpolationUBO", &lineInterpolationUBO, context); tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable)); ++stats.drawablesAdded; diff --git a/src/mbgl/renderer/layers/render_line_layer.hpp b/src/mbgl/renderer/layers/render_line_layer.hpp index 91e86fe13..78424ff52 100644 --- a/src/mbgl/renderer/layers/render_line_layer.hpp +++ b/src/mbgl/renderer/layers/render_line_layer.hpp @@ -27,6 +27,9 @@ class UniformBuffer; using ShaderGroupPtr = std::shared_ptr; using UniformBufferPtr = std::shared_ptr; } // namespace gfx + +class LineLayerTweaker; +using LineLayerTweakerPtr = std::shared_ptr; #endif class RenderLineLayer final : public RenderLayer { @@ -39,6 +42,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif @@ -54,6 +58,9 @@ private: #if MLN_LEGACY_RENDERER void render(PaintParameters&) override; #endif +#if MLN_DRAWABLE_RENDERER + void updateLayerTweaker(); +#endif bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, @@ -90,6 +97,13 @@ private: gfx::ShaderGroupPtr linePatternShaderGroup; gfx::DrawableTweakerPtr iconTweaker; + LineLayerTweakerPtr tweaker; + +#if MLN_RENDER_BACKEND_METAL + std::vector propertiesAsUniforms; +#endif // MLN_RENDER_BACKEND_METAL + + bool overdrawInspector = false; #endif }; diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index daa5ffbbc..e33e920b9 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #endif @@ -52,9 +53,7 @@ void RenderRasterLayer::evaluate(const PropertyEvaluationParameters& parameters) evaluatedProperties = std::move(properties); #if MLN_DRAWABLE_RENDERER - if (layerGroup && layerGroup->getLayerTweaker()) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); - } + updateLayerTweaker(); #endif } @@ -233,9 +232,18 @@ constexpr auto TexturePosAttribName = "a_texture_pos"; constexpr auto Image0UniformName = "u_image0"; constexpr auto Image1UniformName = "u_image1"; +void RenderRasterLayer::updateLayerTweaker() { + if (layerGroup) { + tweaker = std::make_shared(getID(), evaluatedProperties); + tweaker->enableOverdrawInspector(overdrawInspector); + layerGroup->setLayerTweaker(tweaker); + } +} + void RenderRasterLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& /*state*/, + const std::shared_ptr& updateParameters, [[maybe_unused]] const RenderTree& renderTree, [[maybe_unused]] UniqueChangeRequestVec& changes) { std::unique_lock guard(mutex); @@ -254,6 +262,17 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders, if (!rasterShader) { rasterShader = context.getGenericShader(shaders, "RasterShader"); + if (!rasterShader) { + return; + } + } + + const bool overdraw = !!(updateParameters->debugOptions & MapDebugOptions::Overdraw); + if (overdrawInspector != overdraw) { + overdrawInspector = overdraw; + if (tweaker) { + tweaker->enableOverdrawInspector(overdrawInspector); + } } if (!staticDataVertices) { @@ -336,6 +355,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders, sizeof(RasterLayoutVertex), gfx::AttributeDataType::Short2); } + builder->setVertexAttributes(std::move(vertexAttrs)); } @@ -371,8 +391,8 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders, } else { // Set up a layer group imageLayerGroup = context.createLayerGroup(layerIndex, /*initialCapacity=*/64, getID()); - imageLayerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); activateLayerGroup(imageLayerGroup, isRenderable, changes); + updateLayerTweaker(); } auto builder = createBuilder(); @@ -398,8 +418,8 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders, } else { // Set up a tile layer group if (auto layerGroup_ = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID())) { - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); + updateLayerTweaker(); } } diff --git a/src/mbgl/renderer/layers/render_raster_layer.hpp b/src/mbgl/renderer/layers/render_raster_layer.hpp index c45b3210a..b4554e2c4 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.hpp +++ b/src/mbgl/renderer/layers/render_raster_layer.hpp @@ -8,6 +8,11 @@ namespace mbgl { +#if MLN_DRAWABLE_RENDERER +class RasterLayerTweaker; +using RasterLayerTweakerPtr = std::shared_ptr; +#endif // MLN_DRAWABLE_RENDERER + class ImageSourceRenderData; class RasterProgram; @@ -21,6 +26,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif @@ -41,6 +47,10 @@ private: void render(PaintParameters&) override; #endif +#if MLN_DRAWABLE_RENDERER + void updateLayerTweaker(); +#endif // MLN_DRAWABLE_RENDERER + // Paint properties style::RasterPaintProperties::Unevaluated unevaluated; const ImageSourceRenderData* imageData = nullptr; @@ -65,6 +75,9 @@ private: using RasterSegmentVector = SegmentVector; using RasterSegmentVectorPtr = std::shared_ptr; std::shared_ptr staticDataSegments; + + RasterLayerTweakerPtr tweaker; + bool overdrawInspector = false; #endif }; diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index b1156932f..2085e9b6f 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -379,7 +379,7 @@ void RenderSymbolLayer::evaluate(const PropertyEvaluationParameters& parameters) #if MLN_DRAWABLE_RENDERER if (layerGroup) { - layerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); } #endif // MLN_DRAWABLE_RENDERER } @@ -954,6 +954,7 @@ void RenderSymbolLayer::removeAllDrawables() { void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders, gfx::Context& context, const TransformState& state, + const std::shared_ptr&, const RenderTree& /*renderTree*/, UniqueChangeRequestVec& changes) { if (!renderTiles || renderTiles->empty() || passes == RenderPass::None) { @@ -964,7 +965,7 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders, // Set up a layer group if (!layerGroup) { if (auto layerGroup_ = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID())) { - layerGroup_->setLayerTweaker(std::make_shared(evaluatedProperties)); + layerGroup_->setLayerTweaker(std::make_shared(getID(), evaluatedProperties)); setLayerGroup(std::move(layerGroup_), changes); } } @@ -972,7 +973,8 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders, if (!collisionTileLayerGroup) { if ((collisionTileLayerGroup = context.createTileLayerGroup( layerIndex, /*initialCapacity=*/64, getID() + "-collision"))) { - collisionTileLayerGroup->setLayerTweaker(std::make_shared(evaluatedProperties)); + collisionTileLayerGroup->setLayerTweaker( + std::make_shared(getID(), evaluatedProperties)); activateLayerGroup(collisionTileLayerGroup, true, changes); } } @@ -1270,6 +1272,9 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders, builder->setVertexAttrName(posOffsetAttribName); } + if (!shaderGroup) { + return; + } const auto shader = std::static_pointer_cast( shaderGroup->getOrCreateShader(context, uniformProps, posOffsetAttribName)); if (!shader) { diff --git a/src/mbgl/renderer/layers/render_symbol_layer.hpp b/src/mbgl/renderer/layers/render_symbol_layer.hpp index 7150c931f..6d7547232 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.hpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.hpp @@ -90,6 +90,7 @@ public: void update(gfx::ShaderRegistry&, gfx::Context&, const TransformState&, + const std::shared_ptr&, const RenderTree&, UniqueChangeRequestVec&) override; #endif // MLN_DRAWABLE_RENDERER diff --git a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp index 224e2e459..3dc563af4 100644 --- a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp @@ -81,11 +81,6 @@ std::array toArray(const Size& s) { constexpr auto texUniformName = "u_texture"; constexpr auto texIconUniformName = "u_texture_icon"; -template -auto constOrDefault(const IndexedTuple, TypeList>& evaluated) { - return evaluated.template get().constantOr(T::defaultValue()); -} - SymbolDrawablePaintUBO buildPaintUBO(bool isText, const SymbolPaintProperties::PossiblyEvaluated& evaluated) { return { /*.fill_color=*/isText ? constOrDefault(evaluated) : constOrDefault(evaluated), @@ -169,21 +164,23 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, // Unpitched point labels need to have their rotation applied after projection const bool rotateInShader = rotateWithMap && !pitchWithMap && !alongLine; - const SymbolDrawableUBO drawableUBO = {/*.matrix=*/util::cast(matrix), - /*.label_plane_matrix=*/util::cast(labelPlaneMatrix), - /*.coord_matrix=*/util::cast(glCoordMatrix), + const SymbolDrawableUBO drawableUBO = { + /*.matrix=*/util::cast(matrix), + /*.label_plane_matrix=*/util::cast(labelPlaneMatrix), + /*.coord_matrix=*/util::cast(glCoordMatrix), - /*.texsize=*/toArray(getTexSize(drawable, texUniformName)), - /*.texsize_icon=*/toArray(getTexSize(drawable, texIconUniformName)), + /*.texsize=*/toArray(getTexSize(drawable, texUniformName)), + /*.texsize_icon=*/toArray(getTexSize(drawable, texIconUniformName)), - /*.gamma_scale=*/gammaScale, - /*.device_pixel_ratio=*/parameters.pixelRatio, + /*.gamma_scale=*/gammaScale, + /*.device_pixel_ratio=*/parameters.pixelRatio, - /*.camera_to_center_distance=*/camDist, - /*.pitch=*/static_cast(state.getPitch()), - /*.rotate_symbol=*/rotateInShader, - /*.aspect_ratio=*/state.getSize().aspectRatio(), - /*.pad=*/{0, 0}}; + /*.camera_to_center_distance=*/camDist, + /*.pitch=*/static_cast(state.getPitch()), + /*.rotate_symbol=*/rotateInShader, + /*.aspect_ratio=*/state.getSize().aspectRatio(), + /*.pad=*/{0}, + }; const SymbolDynamicUBO dynamicUBO = {/*.fade_change=*/parameters.symbolFadeChange, /*.pad1=*/0, diff --git a/src/mbgl/renderer/layers/symbol_layer_tweaker.hpp b/src/mbgl/renderer/layers/symbol_layer_tweaker.hpp index 826d9ddbb..98f2b14eb 100644 --- a/src/mbgl/renderer/layers/symbol_layer_tweaker.hpp +++ b/src/mbgl/renderer/layers/symbol_layer_tweaker.hpp @@ -11,8 +11,8 @@ namespace mbgl { */ class SymbolLayerTweaker : public LayerTweaker { public: - SymbolLayerTweaker(Immutable properties) - : LayerTweaker(properties){}; + SymbolLayerTweaker(std::string id_, Immutable properties) + : LayerTweaker(std::move(id_), properties) {} public: ~SymbolLayerTweaker() override = default; diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp index 6d0e786f6..445f93029 100644 --- a/src/mbgl/renderer/paint_parameters.cpp +++ b/src/mbgl/renderer/paint_parameters.cpp @@ -36,7 +36,8 @@ PaintParameters::PaintParameters(gfx::Context& context_, const TransformParameters& transformParams_, RenderStaticData& staticData_, LineAtlas& lineAtlas_, - PatternAtlas& patternAtlas_) + PatternAtlas& patternAtlas_, + uint64_t frameCount_) : context(context_), backend(backend_), encoder(context.createCommandEncoder()), @@ -55,7 +56,8 @@ PaintParameters::PaintParameters(gfx::Context& context_, #else programs(staticData_.programs), #endif - shaders(*staticData_.shaders) { + shaders(*staticData_.shaders), + frameCount(frameCount_) { pixelsToGLUnits = {{2.0f / state.getSize().width, -2.0f / state.getSize().height}}; if (state.getViewportMode() == ViewportMode::FlippedY) { diff --git a/src/mbgl/renderer/paint_parameters.hpp b/src/mbgl/renderer/paint_parameters.hpp index 6df4c91ea..7ccfe8867 100644 --- a/src/mbgl/renderer/paint_parameters.hpp +++ b/src/mbgl/renderer/paint_parameters.hpp @@ -57,7 +57,8 @@ public: const TransformParameters&, RenderStaticData&, LineAtlas&, - PatternAtlas&); + PatternAtlas&, + uint64_t frameCount); ~PaintParameters(); gfx::Context& context; @@ -103,7 +104,14 @@ public: /// Clear the stencil buffer, even if there are no tile masks (for 3D) void clearStencil(); + /// @brief Get a stencil mode for rendering constrined to the specified tile ID. + /// The tile ID must have been present in the set previously passed to `renderTileClippingMasks` gfx::StencilMode stencilModeForClipping(const UnwrappedTileID&) const; + + /// @brief Initialize a stencil mode for 3D rendering. + /// @details Clears the tile stencil masks, so `stencilModeForClipping` + /// cannot be used until `renderTileClippingMasks` is called again. + /// @return The stencil mode, each value is unique. gfx::StencilMode stencilModeFor3D(); private: @@ -117,13 +125,15 @@ private: int32_t nextStencilID = 1; public: - int numSublayers = 3; + const int numSublayers = 3; uint32_t currentLayer; float depthRangeSize; - static constexpr float depthEpsilon = 1.0f / (1 << 16); - static constexpr int maxStencilValue = 255; uint32_t opaquePassCutoff = 0; float symbolFadeChange; + const uint64_t frameCount; + + static constexpr float depthEpsilon = 1.0f / (1 << 16); + static constexpr int maxStencilValue = 255; }; } // namespace mbgl diff --git a/src/mbgl/renderer/pattern_atlas.cpp b/src/mbgl/renderer/pattern_atlas.cpp index 62dd147f4..4f80e155f 100644 --- a/src/mbgl/renderer/pattern_atlas.cpp +++ b/src/mbgl/renderer/pattern_atlas.cpp @@ -93,7 +93,9 @@ void PatternAtlas::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { #if MLN_DRAWABLE_RENDERER if (!atlasTexture2D) { atlasTexture2D = uploadPass.getContext().createTexture2D(); - atlasTexture2D->upload(atlasImage); + if (atlasTexture2D) { + atlasTexture2D->upload(atlasImage); + } } else if (dirty) { atlasTexture2D->upload(atlasImage); } diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp index ce23d04a9..fa2a1a90f 100644 --- a/src/mbgl/renderer/render_layer.hpp +++ b/src/mbgl/renderer/render_layer.hpp @@ -30,6 +30,7 @@ class RenderTree; class SymbolBucket; class TransformState; class TransitionParameters; +class UpdateParameters; class UploadParameters; #if MLN_DRAWABLE_RENDERER @@ -164,8 +165,12 @@ public: #if MLN_DRAWABLE_RENDERER /// Generate any changes needed by the layer - virtual void update( - gfx::ShaderRegistry&, gfx::Context&, const TransformState&, const RenderTree&, UniqueChangeRequestVec&) {} + virtual void update(gfx::ShaderRegistry&, + gfx::Context&, + const TransformState&, + const std::shared_ptr&, + const RenderTree&, + UniqueChangeRequestVec&) {} /// Called when the style layer is replaced (same ID and type), and the render layer is reused. virtual void layerChanged(const TransitionParameters&, diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index d6c813b83..a71810e2f 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -823,6 +823,7 @@ bool RenderOrchestrator::addLayerGroup(LayerGroupBasePtr layerGroup, const bool for (auto it = range.first; it != range.second; ++it) { if (it->second == layerGroup) { found = true; + // not added if (replace) { onRemoveLayerGroup(*it->second); it->second = std::move(layerGroup); @@ -849,6 +850,10 @@ bool RenderOrchestrator::removeLayerGroup(const int32_t layerIndex) { return removed; } +size_t RenderOrchestrator::numLayerGroups() const noexcept { + return layerGroupsByLayerIndex.size(); +} + int32_t RenderOrchestrator::maxLayerIndex() const { if (!layerGroupsByLayerIndex.empty()) { return layerGroupsByLayerIndex.crbegin()->second->getLayerIndex(); @@ -897,7 +902,7 @@ void RenderOrchestrator::updateLayers(gfx::ShaderRegistry& shaders, std::vector> changes; for (const auto& item : renderTree.getLayerRenderItems()) { auto& renderLayer = static_cast(item.get()).layer.get(); - renderLayer.update(shaders, context, state, renderTree, changes); + renderLayer.update(shaders, context, state, updateParameters, renderTree, changes); } addChanges(changes); } diff --git a/src/mbgl/renderer/render_orchestrator.hpp b/src/mbgl/renderer/render_orchestrator.hpp index ba751f2a9..5d100ad93 100644 --- a/src/mbgl/renderer/render_orchestrator.hpp +++ b/src/mbgl/renderer/render_orchestrator.hpp @@ -100,6 +100,7 @@ public: #if MLN_DRAWABLE_RENDERER bool addLayerGroup(LayerGroupBasePtr, bool replace); bool removeLayerGroup(const int32_t layerIndex); + size_t numLayerGroups() const noexcept; int32_t maxLayerIndex() const; const LayerGroupBasePtr& getLayerGroup(const int32_t layerIndex) const; void visitLayerGroups(std::function); diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index 70518ed53..d13648b2b 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -19,13 +19,18 @@ #if MLN_DRAWABLE_RENDERER #include -#include #include #include -#include #include -#endif +#endif // MLN_DRAWABLE_RENDERER + +#if !MLN_RENDER_BACKEND_METAL +#include +#if MLN_DRAWABLE_RENDERER +#include +#endif // MLN_DRAWABLE_RENDERER +#endif // !MLN_RENDER_BACKEND_METAL namespace mbgl { @@ -99,7 +104,8 @@ void Renderer::Impl::render(const RenderTree& renderTree, renderTreeParameters.transformParams, *staticData, renderTree.getLineAtlas(), - renderTree.getPatternAtlas()}; + renderTree.getPatternAtlas(), + frameCount}; parameters.symbolFadeChange = renderTreeParameters.symbolFadeChange; parameters.opaquePassCutoff = renderTreeParameters.opaquePassCutOff; @@ -109,7 +115,11 @@ void Renderer::Impl::render(const RenderTree& renderTree, // - UPLOAD PASS ------------------------------------------------------------------------------- // Uploads all required buffers and images before we do any actual rendering. { - const auto uploadPass = parameters.encoder->createUploadPass("upload"); + const auto uploadPass = parameters.encoder->createUploadPass("upload", + parameters.backend.getDefaultRenderable()); +#if !defined(NDEBUG) + const auto debugGroup = uploadPass->createDebugGroup("upload"); +#endif // Update all clipping IDs + upload buckets. for (const RenderItem& item : sourceRenderItems) { @@ -131,15 +141,23 @@ void Renderer::Impl::render(const RenderTree& renderTree, *staticData->shaders, context, renderTreeParameters.transformParams.state, updateParameters, renderTree); } - // Process changes orchestrator.processChanges(); - // Run layer tweakers to update any dynamic elements - orchestrator.visitLayerGroups([&](LayerGroupBase& layerGroup) { - if (layerGroup.getLayerTweaker()) { - layerGroup.getLayerTweaker()->execute(layerGroup, renderTree, parameters); - } - }); + // Upload layer groups + { + const auto uploadPass = parameters.encoder->createUploadPass("layerGroup-upload", + parameters.backend.getDefaultRenderable()); +#if !defined(NDEBUG) + const auto debugGroup = uploadPass->createDebugGroup("layerGroup-upload"); +#endif + + // Tweakers are run in the upload pass so they can set up uniforms. + orchestrator.visitLayerGroups([&](LayerGroupBase& layerGroup) { + if (layerGroup.getLayerTweaker()) { + layerGroup.getLayerTweaker()->execute(layerGroup, renderTree, parameters); + } + }); + } // Update the debug layer groups orchestrator.updateDebugLayerGroups(renderTree, parameters); @@ -150,7 +168,8 @@ void Renderer::Impl::render(const RenderTree& renderTree, // Upload layer groups { - const auto uploadPass = parameters.encoder->createUploadPass("layerGroup-upload"); + const auto uploadPass = parameters.encoder->createUploadPass("layerGroup-upload", + parameters.backend.getDefaultRenderable()); // Give the layers a chance to upload orchestrator.visitLayerGroups([&](LayerGroupBase& layerGroup) { layerGroup.upload(*uploadPass); }); @@ -367,7 +386,7 @@ void Renderer::Impl::render(const RenderTree& renderTree, renderDebugOverlays(); #else static_assert(0, "Must define one of (MLN_DRAWABLE_RENDERER, MLN_LEGACY_RENDERER)"); -#endif +#endif // MLN_LEGACY_RENDERER #if MLN_DRAWABLE_RENDERER // Give the layers a chance to do cleanup @@ -395,6 +414,8 @@ void Renderer::Impl::render(const RenderTree& renderTree, renderState = RenderState::Fully; observer->onDidFinishRenderingMap(); } + + frameCount += 1; } void Renderer::Impl::reduceMemoryUse() { diff --git a/src/mbgl/renderer/renderer_impl.hpp b/src/mbgl/renderer/renderer_impl.hpp index 91259f4d8..c869773df 100644 --- a/src/mbgl/renderer/renderer_impl.hpp +++ b/src/mbgl/renderer/renderer_impl.hpp @@ -47,6 +47,8 @@ private: }; RenderState renderState = RenderState::Never; + + uint64_t frameCount = 0; }; } // namespace mbgl diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp index b4f7b0521..f23dbfe98 100644 --- a/src/mbgl/renderer/sources/render_tile_source.cpp +++ b/src/mbgl/renderer/sources/render_tile_source.cpp @@ -10,10 +10,11 @@ #include #if MLN_DRAWABLE_RENDERER -#include -#include +#include #include #include +#include +#include #include #include @@ -61,6 +62,9 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr auto& shaders = *parameters.staticData.shaders; constexpr auto DebugShaderName = "DebugShader"; gfx::ShaderProgramBasePtr debugShader = context.getGenericShader(shaders, std::string(DebugShaderName)); + if (!debugShader) { + return; + } // create a builder constexpr auto VertexAttribName = "a_pos"; diff --git a/src/mbgl/shaders/gl/shader_program_gl.cpp b/src/mbgl/shaders/gl/shader_program_gl.cpp index d06a8b5f9..f945fa2e4 100644 --- a/src/mbgl/shaders/gl/shader_program_gl.cpp +++ b/src/mbgl/shaders/gl/shader_program_gl.cpp @@ -118,14 +118,14 @@ std::shared_ptr ShaderProgramGL::create(Context& context, ShaderType::Vertex, std::initializer_list{ "#version 300 es\n", - programParameters.getDefines().c_str(), + programParameters.getDefinesString().c_str(), additionalDefines.c_str(), shaders::ShaderSource::vertex, vertexSource.c_str()}); auto fragProg = context.createShader( ShaderType::Fragment, {"#version 300 es\n", - programParameters.getDefines().c_str(), + programParameters.getDefinesString().c_str(), additionalDefines.c_str(), shaders::ShaderSource::fragment, fragmentSource.c_str()}); diff --git a/src/mbgl/shaders/mtl/shader_program.cpp b/src/mbgl/shaders/mtl/shader_program.cpp new file mode 100644 index 000000000..164524a41 --- /dev/null +++ b/src/mbgl/shaders/mtl/shader_program.cpp @@ -0,0 +1,192 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +using namespace std::string_literals; + +namespace mbgl { +namespace mtl { + +namespace { +MTL::BlendOperation metalBlendOperation(const gfx::ColorBlendEquationType& colorBlend) { + switch (colorBlend) { + case gfx::ColorBlendEquationType::Add: + return MTL::BlendOperationAdd; + case gfx::ColorBlendEquationType::Subtract: + return MTL::BlendOperationSubtract; + case gfx::ColorBlendEquationType::ReverseSubtract: + return MTL::BlendOperationReverseSubtract; + } +} + +MTL::BlendFactor metalBlendFactor(const gfx::ColorBlendFactorType& colorFactor) { + switch (colorFactor) { + case gfx::ColorBlendFactorType::Zero: + return MTL::BlendFactorZero; + case gfx::ColorBlendFactorType::One: + return MTL::BlendFactorOne; + case gfx::ColorBlendFactorType::SrcColor: + return MTL::BlendFactorSourceColor; + case gfx::ColorBlendFactorType::OneMinusSrcColor: + return MTL::BlendFactorOneMinusSourceColor; + case gfx::ColorBlendFactorType::SrcAlpha: + return MTL::BlendFactorSourceAlpha; + case gfx::ColorBlendFactorType::OneMinusSrcAlpha: + return MTL::BlendFactorOneMinusSourceAlpha; + case gfx::ColorBlendFactorType::DstAlpha: + return MTL::BlendFactorDestinationAlpha; + case gfx::ColorBlendFactorType::OneMinusDstAlpha: + return MTL::BlendFactorOneMinusDestinationAlpha; + case gfx::ColorBlendFactorType::DstColor: + return MTL::BlendFactorDestinationColor; + case gfx::ColorBlendFactorType::OneMinusDstColor: + return MTL::BlendFactorOneMinusDestinationColor; + case gfx::ColorBlendFactorType::SrcAlphaSaturate: + return MTL::BlendFactorSourceAlphaSaturated; + case gfx::ColorBlendFactorType::ConstantColor: + return MTL::BlendFactorBlendColor; + case gfx::ColorBlendFactorType::OneMinusConstantColor: + return MTL::BlendFactorOneMinusBlendColor; + case gfx::ColorBlendFactorType::ConstantAlpha: + return MTL::BlendFactorBlendAlpha; + case gfx::ColorBlendFactorType::OneMinusConstantAlpha: + return MTL::BlendFactorOneMinusBlendAlpha; + } +} +} // namespace + +ShaderProgram::ShaderProgram(std::string name, RendererBackend& backend_, MTLFunctionPtr vert, MTLFunctionPtr frag) + : ShaderProgramBase(), + shaderName(std::move(name)), + backend(backend_), + vertexFunction(std::move(vert)), + fragmentFunction(std::move(frag)) {} + +MTLRenderPipelineStatePtr ShaderProgram::getRenderPipelineState(const gfx::RenderPassDescriptor& renderPassDescriptor, + const MTLVertexDescriptorPtr& vertexDescriptor, + const gfx::ColorMode& colorMode) const { + auto pool = NS::TransferPtr(NS::AutoreleasePool::alloc()->init()); + + const auto& renderable = renderPassDescriptor.renderable; + const auto& renderableResource = renderable.getResource(); + + auto colorFormat = MTL::PixelFormat::PixelFormatBGRA8Unorm; + std::optional depthFormat = std::nullopt; + std::optional stencilFormat = std::nullopt; + if (const auto& rpd = renderableResource.getRenderPassDescriptor()) { + if (auto* colorTarget = rpd->colorAttachments()->object(0)) { + if (auto* tex = colorTarget->texture()) { + colorFormat = tex->pixelFormat(); + } + } + if (auto* depthTarget = rpd->depthAttachment()) { + if (auto* tex = depthTarget->texture()) { + depthFormat = tex->pixelFormat(); + } + } + if (auto* stencilTarget = rpd->stencilAttachment()) { + if (auto* tex = stencilTarget->texture()) { + stencilFormat = tex->pixelFormat(); + } + } + } + + auto desc = NS::TransferPtr(MTL::RenderPipelineDescriptor::alloc()->init()); + desc->setLabel(NS::String::string(shaderName.data(), NS::UTF8StringEncoding)); + desc->setVertexFunction(vertexFunction.get()); + desc->setFragmentFunction(fragmentFunction.get()); + desc->setVertexDescriptor(vertexDescriptor.get()); + + if (auto* colorTarget = desc->colorAttachments()->object(0)) { + const auto blendEnabled = !colorMode.blendFunction.is(); + auto blendOperation = MTL::BlendOperationAdd; + auto srcFactor = MTL::BlendFactorOne; + auto destFactor = MTL::BlendFactorOne; + + if (blendEnabled) { + apply_visitor( + [&](const auto& blendFunction) { + blendOperation = metalBlendOperation(gfx::ColorBlendEquationType(blendFunction.equation)); + srcFactor = metalBlendFactor(blendFunction.srcFactor); + destFactor = metalBlendFactor(blendFunction.dstFactor); + }, + colorMode.blendFunction); + } + + colorTarget->setPixelFormat(colorFormat); + colorTarget->setBlendingEnabled(blendEnabled); + colorTarget->setRgbBlendOperation(blendOperation); + colorTarget->setAlphaBlendOperation(blendOperation); + colorTarget->setSourceRGBBlendFactor(srcFactor); + colorTarget->setSourceAlphaBlendFactor(srcFactor); + colorTarget->setDestinationRGBBlendFactor(destFactor); + colorTarget->setDestinationAlphaBlendFactor(destFactor); + } + + if (depthFormat) { + desc->setDepthAttachmentPixelFormat(*depthFormat); + } + + if (stencilFormat) { + desc->setStencilAttachmentPixelFormat(*stencilFormat); + } + + NS::Error* error = nullptr; + const auto& device = backend.getDevice(); + auto rps = NS::TransferPtr(device->newRenderPipelineState(desc.get(), &error)); + + if (!rps || error) { + const auto errPtr = error ? error->localizedDescription()->utf8String() : nullptr; + const auto errStr = (errPtr && errPtr[0]) ? ": "s + errPtr : std::string(); + Log::Error(Event::Shader, shaderName + " newRenderPipelineState failed" + errStr); + assert(false); + } + + return rps; +} + +std::optional ShaderProgram::getSamplerLocation(std::string_view name) const { + std::size_t index = 0; + for (const auto& bindingName : textureBindings) { + if (bindingName == name) { + return index; + } + index += 1; + } + return std::nullopt; +} + +void ShaderProgram::initAttribute(const shaders::AttributeInfo& info) { + vertexAttributes.add(std::string(info.name), static_cast(info.index), info.dataType, info.count); +} + +void ShaderProgram::initUniformBlock(const shaders::UniformBlockInfo& info) { + if (const auto& block_ = uniformBlocks.add(info.name.data(), static_cast(info.index), info.size)) { + auto& block = static_cast(*block_); + block.setBindVertex(info.vertex); + block.setBindFragment(info.fragment); + } +} + +void ShaderProgram::initTexture(const shaders::TextureInfo& info) { + textureBindings.resize(std::max(textureBindings.size(), info.index + 1)); + textureBindings[info.index] = info.name; +} + +} // namespace mtl +} // namespace mbgl diff --git a/src/mbgl/shaders/mtl/shader_program_mtl.cpp b/src/mbgl/shaders/mtl/shader_program_mtl.cpp deleted file mode 100644 index 164d793d4..000000000 --- a/src/mbgl/shaders/mtl/shader_program_mtl.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -namespace mbgl { -namespace mtl { - -// bool ShaderProgramMTL::compile(std::string_view vert, std::string_view frag) { -// return false; -// } - -} // namespace mtl -} // namespace mbgl diff --git a/src/mbgl/style/properties.hpp b/src/mbgl/style/properties.hpp index 4a2c63b6b..fb9d7579a 100644 --- a/src/mbgl/style/properties.hpp +++ b/src/mbgl/style/properties.hpp @@ -304,5 +304,10 @@ public: template using ConcatenateProperties = typename TypeListConcat::template ExpandInto; +template +auto constOrDefault(const IndexedTuple, TypeList>& evaluated) { + return evaluated.template get().constantOr(T::defaultValue()); +} + } // namespace style } // namespace mbgl diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 10e926ed8..25437cd90 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -135,7 +135,7 @@ if(MLN_WITH_OPENGL) ) target_compile_definitions( mbgl-test - PRIVATE MBGL_RENDER_BACKEND_OPENGL=1 + PRIVATE MLN_RENDER_BACKEND_OPENGL=1 ) endif() diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp index 39fd78076..c53b027de 100644 --- a/test/gl/bucket.test.cpp +++ b/test/gl/bucket.test.cpp @@ -67,7 +67,7 @@ TEST(Buckets, CircleBucket) { ASSERT_TRUE(bucket.needsUpload()); auto commandEncoder = context.createCommandEncoder(); - auto uploadPass = commandEncoder->createUploadPass("upload"); + auto uploadPass = commandEncoder->createUploadPass("upload", backend.getDefaultRenderable()); bucket.upload(*uploadPass); ASSERT_TRUE(bucket.hasData()); ASSERT_FALSE(bucket.needsUpload()); @@ -94,7 +94,7 @@ TEST(Buckets, FillBucket) { ASSERT_TRUE(bucket.needsUpload()); auto commandEncoder = context.createCommandEncoder(); - auto uploadPass = commandEncoder->createUploadPass("upload"); + auto uploadPass = commandEncoder->createUploadPass("upload", backend.getDefaultRenderable()); bucket.upload(*uploadPass); ASSERT_FALSE(bucket.needsUpload()); } @@ -130,7 +130,7 @@ TEST(Buckets, LineBucket) { ASSERT_TRUE(bucket.needsUpload()); auto commandEncoder = context.createCommandEncoder(); - auto uploadPass = commandEncoder->createUploadPass("upload"); + auto uploadPass = commandEncoder->createUploadPass("upload", backend.getDefaultRenderable()); bucket.upload(*uploadPass); ASSERT_FALSE(bucket.needsUpload()); } @@ -188,7 +188,7 @@ TEST(Buckets, SymbolBucket) { ASSERT_TRUE(bucket.needsUpload()); auto commandEncoder = context.createCommandEncoder(); - auto uploadPass = commandEncoder->createUploadPass("upload"); + auto uploadPass = commandEncoder->createUploadPass("upload", backend.getDefaultRenderable()); bucket.upload(*uploadPass); ASSERT_FALSE(bucket.needsUpload()); } @@ -206,7 +206,7 @@ TEST(Buckets, RasterBucket) { ASSERT_TRUE(bucket.needsUpload()); auto commandEncoder = context.createCommandEncoder(); - auto uploadPass = commandEncoder->createUploadPass("upload"); + auto uploadPass = commandEncoder->createUploadPass("upload", backend.getDefaultRenderable()); bucket.upload(*uploadPass); ASSERT_FALSE(bucket.needsUpload()); diff --git a/vendor/BUILD.bazel b/vendor/BUILD.bazel index 8dc598375..c950e3a3c 100644 --- a/vendor/BUILD.bazel +++ b/vendor/BUILD.bazel @@ -175,6 +175,15 @@ cc_library( visibility = ["//visibility:public"], ) +# vendor/metal-cpp.json +cc_library( + name = "metal-cpp", + hdrs = glob(["metal-cpp/**/*.hpp"], allow_empty = False), + copts = CPP_FLAGS, + includes = ["metal-cpp"], + visibility = ["//visibility:public"], +) + # vendor/polylabel-files.json cc_library( name = "polylabel", diff --git a/vendor/metal-cpp/Foundation/Foundation.hpp b/vendor/metal-cpp/Foundation/Foundation.hpp new file mode 100644 index 000000000..8b64277ff --- /dev/null +++ b/vendor/metal-cpp/Foundation/Foundation.hpp @@ -0,0 +1,47 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/Foundation.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSArray.hpp" +#include "NSAutoreleasePool.hpp" +#include "NSBundle.hpp" +#include "NSData.hpp" +#include "NSDate.hpp" +#include "NSDefines.hpp" +#include "NSDictionary.hpp" +#include "NSEnumerator.hpp" +#include "NSError.hpp" +#include "NSLock.hpp" +#include "NSNotification.hpp" +#include "NSNumber.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSProcessInfo.hpp" +#include "NSRange.hpp" +#include "NSSet.hpp" +#include "NSSharedPtr.hpp" +#include "NSString.hpp" +#include "NSTypes.hpp" +#include "NSURL.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSArray.hpp b/vendor/metal-cpp/Foundation/NSArray.hpp new file mode 100644 index 000000000..7ccdb8044 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSArray.hpp @@ -0,0 +1,115 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSArray.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSObject.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +class Array : public Copying +{ +public: + static Array* array(); + static Array* array(const Object* pObject); + static Array* array(const Object* const* pObjects, UInteger count); + + static Array* alloc(); + + Array* init(); + Array* init(const Object* const* pObjects, UInteger count); + Array* init(const class Coder* pCoder); + + template + _Object* object(UInteger index) const; + UInteger count() const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Array::array() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(array)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Array::array(const Object* pObject) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(arrayWithObject_), pObject); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Array::array(const Object* const* pObjects, UInteger count) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSArray), _NS_PRIVATE_SEL(arrayWithObjects_count_), pObjects, count); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Array::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSArray)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Array::init() +{ + return NS::Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Array::init(const Object* const* pObjects, UInteger count) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithObjects_count_), pObjects, count); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Array::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::Array::count() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(count)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Object* NS::Array::object(UInteger index) const +{ + return Object::sendMessage<_Object*>(this, _NS_PRIVATE_SEL(objectAtIndex_), index); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSAutoreleasePool.hpp b/vendor/metal-cpp/Foundation/NSAutoreleasePool.hpp new file mode 100644 index 000000000..3008590d4 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSAutoreleasePool.hpp @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSAutoreleasePool.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +class AutoreleasePool : public Object +{ +public: + static AutoreleasePool* alloc(); + AutoreleasePool* init(); + + void drain(); + + void addObject(Object* pObject); + + static void showPools(); +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::AutoreleasePool* NS::AutoreleasePool::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSAutoreleasePool)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::AutoreleasePool* NS::AutoreleasePool::init() +{ + return NS::Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::AutoreleasePool::drain() +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(drain)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::AutoreleasePool::addObject(Object* pObject) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(addObject_), pObject); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::AutoreleasePool::showPools() +{ + Object::sendMessage(_NS_PRIVATE_CLS(NSAutoreleasePool), _NS_PRIVATE_SEL(showPools)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSBundle.hpp b/vendor/metal-cpp/Foundation/NSBundle.hpp new file mode 100644 index 000000000..323d93f33 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSBundle.hpp @@ -0,0 +1,374 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSBundle.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSNotification.hpp" +#include "NSObject.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +_NS_CONST(NotificationName, BundleDidLoadNotification); +_NS_CONST(NotificationName, BundleResourceRequestLowDiskSpaceNotification); + +class String* LocalizedString(const String* pKey, const String*); +class String* LocalizedStringFromTable(const String* pKey, const String* pTbl, const String*); +class String* LocalizedStringFromTableInBundle(const String* pKey, const String* pTbl, const class Bundle* pBdle, const String*); +class String* LocalizedStringWithDefaultValue(const String* pKey, const String* pTbl, const class Bundle* pBdle, const String* pVal, const String*); + +class Bundle : public Referencing +{ +public: + static Bundle* mainBundle(); + + static Bundle* bundle(const class String* pPath); + static Bundle* bundle(const class URL* pURL); + + static Bundle* alloc(); + + Bundle* init(const class String* pPath); + Bundle* init(const class URL* pURL); + + class Array* allBundles() const; + class Array* allFrameworks() const; + + bool load(); + bool unload(); + + bool isLoaded() const; + + bool preflightAndReturnError(class Error** pError) const; + bool loadAndReturnError(class Error** pError); + + class URL* bundleURL() const; + class URL* resourceURL() const; + class URL* executableURL() const; + class URL* URLForAuxiliaryExecutable(const class String* pExecutableName) const; + + class URL* privateFrameworksURL() const; + class URL* sharedFrameworksURL() const; + class URL* sharedSupportURL() const; + class URL* builtInPlugInsURL() const; + class URL* appStoreReceiptURL() const; + + class String* bundlePath() const; + class String* resourcePath() const; + class String* executablePath() const; + class String* pathForAuxiliaryExecutable(const class String* pExecutableName) const; + + class String* privateFrameworksPath() const; + class String* sharedFrameworksPath() const; + class String* sharedSupportPath() const; + class String* builtInPlugInsPath() const; + + class String* bundleIdentifier() const; + class Dictionary* infoDictionary() const; + class Dictionary* localizedInfoDictionary() const; + class Object* objectForInfoDictionaryKey(const class String* pKey); + + class String* localizedString(const class String* pKey, const class String* pValue = nullptr, const class String* pTableName = nullptr) const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_PRIVATE_DEF_CONST(NS::NotificationName, BundleDidLoadNotification); +_NS_PRIVATE_DEF_CONST(NS::NotificationName, BundleResourceRequestLowDiskSpaceNotification); + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::LocalizedString(const String* pKey, const String*) +{ + return Bundle::mainBundle()->localizedString(pKey, nullptr, nullptr); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::LocalizedStringFromTable(const String* pKey, const String* pTbl, const String*) +{ + return Bundle::mainBundle()->localizedString(pKey, nullptr, pTbl); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::LocalizedStringFromTableInBundle(const String* pKey, const String* pTbl, const Bundle* pBdl, const String*) +{ + return pBdl->localizedString(pKey, nullptr, pTbl); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::LocalizedStringWithDefaultValue(const String* pKey, const String* pTbl, const Bundle* pBdl, const String* pVal, const String*) +{ + return pBdl->localizedString(pKey, pVal, pTbl); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Bundle* NS::Bundle::mainBundle() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(mainBundle)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Bundle* NS::Bundle::bundle(const class String* pPath) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(bundleWithPath_), pPath); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Bundle* NS::Bundle::bundle(const class URL* pURL) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(bundleWithURL_), pURL); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Bundle* NS::Bundle::alloc() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSBundle), _NS_PRIVATE_SEL(alloc)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Bundle* NS::Bundle::init(const String* pPath) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithPath_), pPath); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Bundle* NS::Bundle::init(const URL* pURL) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithURL_), pURL); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Bundle::allBundles() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(allBundles)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Bundle::allFrameworks() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(allFrameworks)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Bundle::load() +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(load)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Bundle::unload() +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unload)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Bundle::isLoaded() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isLoaded)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Bundle::preflightAndReturnError(Error** pError) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(preflightAndReturnError_), pError); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Bundle::loadAndReturnError(Error** pError) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(loadAndReturnError_), pError); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::bundleURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(bundleURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::resourceURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(resourceURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::executableURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(executableURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::URLForAuxiliaryExecutable(const String* pExecutableName) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(URLForAuxiliaryExecutable_), pExecutableName); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::privateFrameworksURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(privateFrameworksURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::sharedFrameworksURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedFrameworksURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::sharedSupportURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedSupportURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::builtInPlugInsURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(builtInPlugInsURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::Bundle::appStoreReceiptURL() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(appStoreReceiptURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::bundlePath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(bundlePath)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::resourcePath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(resourcePath)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::executablePath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(executablePath)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::pathForAuxiliaryExecutable(const String* pExecutableName) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(pathForAuxiliaryExecutable_), pExecutableName); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::privateFrameworksPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(privateFrameworksPath)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::sharedFrameworksPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedFrameworksPath)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::sharedSupportPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(sharedSupportPath)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::builtInPlugInsPath() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(builtInPlugInsPath)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::bundleIdentifier() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(bundleIdentifier)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Bundle::infoDictionary() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(infoDictionary)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Bundle::localizedInfoDictionary() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedInfoDictionary)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Object* NS::Bundle::objectForInfoDictionaryKey(const String* pKey) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(objectForInfoDictionaryKey_), pKey); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Bundle::localizedString(const String* pKey, const String* pValue /* = nullptr */, const String* pTableName /* = nullptr */) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedStringForKey_value_table_), pKey, pValue, pTableName); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSData.hpp b/vendor/metal-cpp/Foundation/NSData.hpp new file mode 100644 index 000000000..ddfa6dd08 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSData.hpp @@ -0,0 +1,54 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSData.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSObject.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +class Data : public Copying +{ +public: + void* mutableBytes() const; + UInteger length() const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void* NS::Data::mutableBytes() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(mutableBytes)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::Data::length() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(length)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSDate.hpp b/vendor/metal-cpp/Foundation/NSDate.hpp new file mode 100644 index 000000000..61f10a95b --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSDate.hpp @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSDate.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ + +using TimeInterval = double; + +class Date : public Copying +{ +public: + static Date* dateWithTimeIntervalSinceNow(TimeInterval secs); +}; + +} // NS + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Date* NS::Date::dateWithTimeIntervalSinceNow(NS::TimeInterval secs) +{ + return NS::Object::sendMessage(_NS_PRIVATE_CLS(NSDate), _NS_PRIVATE_SEL(dateWithTimeIntervalSinceNow_), secs); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/vendor/metal-cpp/Foundation/NSDefines.hpp b/vendor/metal-cpp/Foundation/NSDefines.hpp new file mode 100644 index 000000000..a042be631 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSDefines.hpp @@ -0,0 +1,45 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSDefines.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#define _NS_WEAK_IMPORT __attribute__((weak_import)) +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _NS_EXPORT __attribute__((visibility("hidden"))) +#else +#define _NS_EXPORT __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _NS_EXTERN extern "C" _NS_EXPORT +#define _NS_INLINE inline __attribute__((always_inline)) +#define _NS_PACKED __attribute__((packed)) + +#define _NS_CONST(type, name) _NS_EXTERN type const name +#define _NS_ENUM(type, name) enum name : type +#define _NS_OPTIONS(type, name) \ + using name = type; \ + enum : name + +#define _NS_CAST_TO_UINT(value) static_cast(value) +#define _NS_VALIDATE_SIZE(ns, name) static_assert(sizeof(ns::name) == sizeof(ns##name), "size mismatch " #ns "::" #name) +#define _NS_VALIDATE_ENUM(ns, name) static_assert(_NS_CAST_TO_UINT(ns::name) == _NS_CAST_TO_UINT(ns##name), "value mismatch " #ns "::" #name) + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSDictionary.hpp b/vendor/metal-cpp/Foundation/NSDictionary.hpp new file mode 100644 index 000000000..078cd5c8f --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSDictionary.hpp @@ -0,0 +1,128 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSDictionary.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSEnumerator.hpp" +#include "NSObject.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +class Dictionary : public NS::Copying +{ +public: + static Dictionary* dictionary(); + static Dictionary* dictionary(const Object* pObject, const Object* pKey); + static Dictionary* dictionary(const Object* const* pObjects, const Object* const* pKeys, UInteger count); + + static Dictionary* alloc(); + + Dictionary* init(); + Dictionary* init(const Object* const* pObjects, const Object* const* pKeys, UInteger count); + Dictionary* init(const class Coder* pCoder); + + template + Enumerator<_KeyType>* keyEnumerator() const; + + template + _Object* object(const Object* pKey) const; + UInteger count() const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionary)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary(const Object* pObject, const Object* pKey) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionaryWithObject_forKey_), pObject, pKey); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Dictionary::dictionary(const Object* const* pObjects, const Object* const* pKeys, UInteger count) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSDictionary), _NS_PRIVATE_SEL(dictionaryWithObjects_forKeys_count_), + pObjects, pKeys, count); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Dictionary::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSDictionary)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Dictionary::init() +{ + return NS::Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Dictionary::init(const Object* const* pObjects, const Object* const* pKeys, UInteger count) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithObjects_forKeys_count_), pObjects, pKeys, count); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Dictionary::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE NS::Enumerator<_KeyType>* NS::Dictionary::keyEnumerator() const +{ + return Object::sendMessage*>(this, _NS_PRIVATE_SEL(keyEnumerator)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Object* NS::Dictionary::object(const Object* pKey) const +{ + return Object::sendMessage<_Object*>(this, _NS_PRIVATE_SEL(objectForKey_), pKey); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::Dictionary::count() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(count)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSEnumerator.hpp b/vendor/metal-cpp/Foundation/NSEnumerator.hpp new file mode 100644 index 000000000..eed19dbac --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSEnumerator.hpp @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSEnumerator.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSObject.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +struct FastEnumerationState +{ + unsigned long state; + Object** itemsPtr; + unsigned long* mutationsPtr; + unsigned long extra[5]; +} _NS_PACKED; + +class FastEnumeration : public Referencing +{ +public: + NS::UInteger countByEnumerating(FastEnumerationState* pState, Object** pBuffer, NS::UInteger len); +}; + +template +class Enumerator : public Referencing, FastEnumeration> +{ +public: + _ObjectType* nextObject(); + class Array* allObjects(); +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::FastEnumeration::countByEnumerating(FastEnumerationState* pState, Object** pBuffer, NS::UInteger len) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(countByEnumeratingWithState_objects_count_), pState, pBuffer, len); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _ObjectType* NS::Enumerator<_ObjectType>::nextObject() +{ + return Object::sendMessage<_ObjectType*>(this, _NS_PRIVATE_SEL(nextObject)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE NS::Array* NS::Enumerator<_ObjectType>::allObjects() +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(allObjects)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSError.hpp b/vendor/metal-cpp/Foundation/NSError.hpp new file mode 100644 index 000000000..f19ff861f --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSError.hpp @@ -0,0 +1,173 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSError.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +using ErrorDomain = class String*; + +_NS_CONST(ErrorDomain, CocoaErrorDomain); +_NS_CONST(ErrorDomain, POSIXErrorDomain); +_NS_CONST(ErrorDomain, OSStatusErrorDomain); +_NS_CONST(ErrorDomain, MachErrorDomain); + +using ErrorUserInfoKey = class String*; + +_NS_CONST(ErrorUserInfoKey, UnderlyingErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedDescriptionKey); +_NS_CONST(ErrorUserInfoKey, LocalizedFailureReasonErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedRecoverySuggestionErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedRecoveryOptionsErrorKey); +_NS_CONST(ErrorUserInfoKey, RecoveryAttempterErrorKey); +_NS_CONST(ErrorUserInfoKey, HelpAnchorErrorKey); +_NS_CONST(ErrorUserInfoKey, DebugDescriptionErrorKey); +_NS_CONST(ErrorUserInfoKey, LocalizedFailureErrorKey); +_NS_CONST(ErrorUserInfoKey, StringEncodingErrorKey); +_NS_CONST(ErrorUserInfoKey, URLErrorKey); +_NS_CONST(ErrorUserInfoKey, FilePathErrorKey); + +class Error : public Copying +{ +public: + static Error* error(ErrorDomain domain, Integer code, class Dictionary* pDictionary); + + static Error* alloc(); + Error* init(); + Error* init(ErrorDomain domain, Integer code, class Dictionary* pDictionary); + + Integer code() const; + ErrorDomain domain() const; + class Dictionary* userInfo() const; + + class String* localizedDescription() const; + class Array* localizedRecoveryOptions() const; + class String* localizedRecoverySuggestion() const; + class String* localizedFailureReason() const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, CocoaErrorDomain); +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, POSIXErrorDomain); +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, OSStatusErrorDomain); +_NS_PRIVATE_DEF_CONST(NS::ErrorDomain, MachErrorDomain); + +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, UnderlyingErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedDescriptionKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedFailureReasonErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedRecoverySuggestionErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedRecoveryOptionsErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, RecoveryAttempterErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, HelpAnchorErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, DebugDescriptionErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, LocalizedFailureErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, StringEncodingErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, URLErrorKey); +_NS_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, FilePathErrorKey); + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Error* NS::Error::error(ErrorDomain domain, Integer code, class Dictionary* pDictionary) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSError), _NS_PRIVATE_SEL(errorWithDomain_code_userInfo_), domain, code, pDictionary); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Error* NS::Error::alloc() +{ + return Object::alloc(_NS_PRIVATE_CLS(NSError)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Error* NS::Error::init() +{ + return Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Error* NS::Error::init(ErrorDomain domain, Integer code, class Dictionary* pDictionary) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithDomain_code_userInfo_), domain, code, pDictionary); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Integer NS::Error::code() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(code)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::ErrorDomain NS::Error::domain() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(domain)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Error::userInfo() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(userInfo)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Error::localizedDescription() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedDescription)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::Error::localizedRecoveryOptions() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedRecoveryOptions)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Error::localizedRecoverySuggestion() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedRecoverySuggestion)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Error::localizedFailureReason() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(localizedFailureReason)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSLock.hpp b/vendor/metal-cpp/Foundation/NSLock.hpp new file mode 100644 index 000000000..ca371fbae --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSLock.hpp @@ -0,0 +1,118 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSLock.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSTypes.hpp" +#include "NSDate.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ + +template +class Locking : public _Base +{ +public: + void lock(); + void unlock(); +}; + +class Condition : public Locking +{ +public: + static Condition* alloc(); + + Condition* init(); + + void wait(); + bool waitUntilDate(Date* pLimit); + void signal(); + void broadcast(); +}; + +} // NS + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE void NS::Locking<_Class, _Base>::lock() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(lock)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE void NS::Locking<_Class, _Base>::unlock() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(unlock)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Condition* NS::Condition::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSCondition)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Condition* NS::Condition::init() +{ + return NS::Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::Condition::wait() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(wait)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Condition::waitUntilDate(NS::Date* pLimit) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(waitUntilDate_), pLimit); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::Condition::signal() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(signal)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::Condition::broadcast() +{ + NS::Object::sendMessage(this, _NS_PRIVATE_SEL(broadcast)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/vendor/metal-cpp/Foundation/NSNotification.hpp b/vendor/metal-cpp/Foundation/NSNotification.hpp new file mode 100644 index 000000000..49cf2d4a4 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSNotification.hpp @@ -0,0 +1,110 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSNotification.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSDictionary.hpp" +#include "NSObject.hpp" +#include "NSString.hpp" +#include "NSTypes.hpp" +#include + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +using NotificationName = class String*; + +class Notification : public NS::Referencing +{ +public: + NS::String* name() const; + NS::Object* object() const; + NS::Dictionary* userInfo() const; +}; + +using ObserverBlock = void(^)(Notification*); +using ObserverFunction = std::function; + +class NotificationCenter : public NS::Referencing +{ + public: + static class NotificationCenter* defaultCenter(); + Object* addObserver(NotificationName name, Object* pObj, void* pQueue, ObserverBlock block); + Object* addObserver(NotificationName name, Object* pObj, void* pQueue, ObserverFunction &handler); + void removeObserver(Object* pObserver); + +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Notification::name() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(name)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Object* NS::Notification::object() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(object)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::Notification::userInfo() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(userInfo)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::NotificationCenter* NS::NotificationCenter::defaultCenter() +{ + return NS::Object::sendMessage(_NS_PRIVATE_CLS(NSNotificationCenter), _NS_PRIVATE_SEL(defaultCenter)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Object* NS::NotificationCenter::addObserver(NS::NotificationName name, Object* pObj, void* pQueue, NS::ObserverBlock block) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(addObserverName_object_queue_block_), name, pObj, pQueue, block); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Object* NS::NotificationCenter::addObserver(NS::NotificationName name, Object* pObj, void* pQueue, NS::ObserverFunction &handler) +{ + __block ObserverFunction blockFunction = handler; + + return addObserver(name, pObj, pQueue, ^(NS::Notification* pNotif) {blockFunction(pNotif);}); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::NotificationCenter::removeObserver(Object* pObserver) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(removeObserver_), pObserver); +} + diff --git a/vendor/metal-cpp/Foundation/NSNumber.hpp b/vendor/metal-cpp/Foundation/NSNumber.hpp new file mode 100644 index 000000000..13c780248 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSNumber.hpp @@ -0,0 +1,501 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSNumber.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSObjCRuntime.hpp" +#include "NSObject.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +class Value : public Copying +{ +public: + static Value* value(const void* pValue, const char* pType); + static Value* value(const void* pPointer); + + static Value* alloc(); + + Value* init(const void* pValue, const char* pType); + Value* init(const class Coder* pCoder); + + void getValue(void* pValue, UInteger size) const; + const char* objCType() const; + + bool isEqualToValue(Value* pValue) const; + void* pointerValue() const; +}; + +class Number : public Copying +{ +public: + static Number* number(char value); + static Number* number(unsigned char value); + static Number* number(short value); + static Number* number(unsigned short value); + static Number* number(int value); + static Number* number(unsigned int value); + static Number* number(long value); + static Number* number(unsigned long value); + static Number* number(long long value); + static Number* number(unsigned long long value); + static Number* number(float value); + static Number* number(double value); + static Number* number(bool value); + + static Number* alloc(); + + Number* init(const class Coder* pCoder); + Number* init(char value); + Number* init(unsigned char value); + Number* init(short value); + Number* init(unsigned short value); + Number* init(int value); + Number* init(unsigned int value); + Number* init(long value); + Number* init(unsigned long value); + Number* init(long long value); + Number* init(unsigned long long value); + Number* init(float value); + Number* init(double value); + Number* init(bool value); + + char charValue() const; + unsigned char unsignedCharValue() const; + short shortValue() const; + unsigned short unsignedShortValue() const; + int intValue() const; + unsigned int unsignedIntValue() const; + long longValue() const; + unsigned long unsignedLongValue() const; + long long longLongValue() const; + unsigned long long unsignedLongLongValue() const; + float floatValue() const; + double doubleValue() const; + bool boolValue() const; + Integer integerValue() const; + UInteger unsignedIntegerValue() const; + class String* stringValue() const; + + ComparisonResult compare(const Number* pOtherNumber) const; + bool isEqualToNumber(const Number* pNumber) const; + + class String* descriptionWithLocale(const Object* pLocale) const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Value* NS::Value::value(const void* pValue, const char* pType) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSValue), _NS_PRIVATE_SEL(valueWithBytes_objCType_), pValue, pType); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Value* NS::Value::value(const void* pPointer) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSValue), _NS_PRIVATE_SEL(valueWithPointer_), pPointer); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Value* NS::Value::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Value* NS::Value::init(const void* pValue, const char* pType) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithBytes_objCType_), pValue, pType); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Value* NS::Value::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::Value::getValue(void* pValue, UInteger size) const +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(getValue_size_), pValue, size); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE const char* NS::Value::objCType() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(objCType)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Value::isEqualToValue(Value* pValue) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isEqualToValue_), pValue); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void* NS::Value::pointerValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(pointerValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(char value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithChar_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(unsigned char value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedChar_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(short value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithShort_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(unsigned short value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedShort_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(int value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithInt_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(unsigned int value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedInt_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(unsigned long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(long long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithLongLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(unsigned long long value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithUnsignedLongLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(float value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithFloat_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(double value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithDouble_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::number(bool value) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSNumber), _NS_PRIVATE_SEL(numberWithBool_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSNumber)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(const Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(char value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithChar_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(unsigned char value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedChar_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(short value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithShort_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(unsigned short value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedShort_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(int value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithInt_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(unsigned int value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedInt_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(unsigned long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(long long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithLongLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(unsigned long long value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithUnsignedLongLong_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(float value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithFloat_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(double value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithDouble_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Number* NS::Number::init(bool value) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithBool_), value); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE char NS::Number::charValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(charValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE unsigned char NS::Number::unsignedCharValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedCharValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE short NS::Number::shortValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(shortValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE unsigned short NS::Number::unsignedShortValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedShortValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE int NS::Number::intValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(intValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE unsigned int NS::Number::unsignedIntValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedIntValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE long NS::Number::longValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(longValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE unsigned long NS::Number::unsignedLongValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedLongValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE long long NS::Number::longLongValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(longLongValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE unsigned long long NS::Number::unsignedLongLongValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedLongLongValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE float NS::Number::floatValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(floatValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE double NS::Number::doubleValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(doubleValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Number::boolValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(boolValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Integer NS::Number::integerValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(integerValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::Number::unsignedIntegerValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(unsignedIntegerValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Number::stringValue() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(stringValue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::ComparisonResult NS::Number::compare(const Number* pOtherNumber) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(compare_), pOtherNumber); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Number::isEqualToNumber(const Number* pNumber) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isEqualToNumber_), pNumber); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Number::descriptionWithLocale(const Object* pLocale) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(descriptionWithLocale_), pLocale); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSObjCRuntime.hpp b/vendor/metal-cpp/Foundation/NSObjCRuntime.hpp new file mode 100644 index 000000000..a3860e94a --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSObjCRuntime.hpp @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSObjCRuntime.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ + +_NS_ENUM(Integer, ComparisonResult) { + OrderedAscending = -1L, + OrderedSame, + OrderedDescending +}; + +const Integer NotFound = IntegerMax; + +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSObject.hpp b/vendor/metal-cpp/Foundation/NSObject.hpp new file mode 100644 index 000000000..957071bca --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSObject.hpp @@ -0,0 +1,302 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSObject.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSPrivate.hpp" +#include "NSTypes.hpp" + +#include +#include + +#include + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +template +class _NS_EXPORT Referencing : public _Base +{ +public: + _Class* retain(); + void release(); + + _Class* autorelease(); + + UInteger retainCount() const; +}; + +template +class Copying : public Referencing<_Class, _Base> +{ +public: + _Class* copy() const; +}; + +template +class SecureCoding : public Referencing<_Class, _Base> +{ +}; + +class Object : public Referencing +{ +public: + UInteger hash() const; + bool isEqual(const Object* pObject) const; + + class String* description() const; + class String* debugDescription() const; + +protected: + friend class Referencing; + + template + static _Class* alloc(const char* pClassName); + template + static _Class* alloc(const void* pClass); + template + _Class* init(); + + template + static _Dst bridgingCast(const void* pObj); + static class MethodSignature* methodSignatureForSelector(const void* pObj, SEL selector); + static bool respondsToSelector(const void* pObj, SEL selector); + template + static constexpr bool doesRequireMsgSendStret(); + template + static _Ret sendMessage(const void* pObj, SEL selector, _Args... args); + template + static _Ret sendMessageSafe(const void* pObj, SEL selector, _Args... args); + +private: + Object() = delete; + Object(const Object&) = delete; + ~Object() = delete; + + Object& operator=(const Object&) = delete; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Class* NS::Referencing<_Class, _Base>::retain() +{ + return Object::sendMessage<_Class*>(this, _NS_PRIVATE_SEL(retain)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE void NS::Referencing<_Class, _Base>::release() +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(release)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Class* NS::Referencing<_Class, _Base>::autorelease() +{ + return Object::sendMessage<_Class*>(this, _NS_PRIVATE_SEL(autorelease)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE NS::UInteger NS::Referencing<_Class, _Base>::retainCount() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(retainCount)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Class* NS::Copying<_Class, _Base>::copy() const +{ + return Object::sendMessage<_Class*>(this, _NS_PRIVATE_SEL(copy)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Dst NS::Object::bridgingCast(const void* pObj) +{ +#ifdef __OBJC__ + return (__bridge _Dst)pObj; +#else + return (_Dst)pObj; +#endif // __OBJC__ +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE constexpr bool NS::Object::doesRequireMsgSendStret() +{ +#if (defined(__i386__) || defined(__x86_64__)) + constexpr size_t kStructLimit = (sizeof(std::uintptr_t) << 1); + + return sizeof(_Type) > kStructLimit; +#elif defined(__arm64__) + return false; +#elif defined(__arm__) + constexpr size_t kStructLimit = sizeof(std::uintptr_t); + + return std::is_class(_Type) && (sizeof(_Type) > kStructLimit); +#else +#error "Unsupported architecture!" +#endif +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template <> +_NS_INLINE constexpr bool NS::Object::doesRequireMsgSendStret() +{ + return false; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Ret NS::Object::sendMessage(const void* pObj, SEL selector, _Args... args) +{ +#if (defined(__i386__) || defined(__x86_64__)) + if constexpr (std::is_floating_point<_Ret>()) + { + using SendMessageProcFpret = _Ret (*)(const void*, SEL, _Args...); + + const SendMessageProcFpret pProc = reinterpret_cast(&objc_msgSend_fpret); + + return (*pProc)(pObj, selector, args...); + } + else +#endif // ( defined( __i386__ ) || defined( __x86_64__ ) ) +#if !defined(__arm64__) + if constexpr (doesRequireMsgSendStret<_Ret>()) + { + using SendMessageProcStret = void (*)(_Ret*, const void*, SEL, _Args...); + + const SendMessageProcStret pProc = reinterpret_cast(&objc_msgSend_stret); + _Ret ret; + + (*pProc)(&ret, pObj, selector, args...); + + return ret; + } + else +#endif // !defined( __arm64__ ) + { + using SendMessageProc = _Ret (*)(const void*, SEL, _Args...); + + const SendMessageProc pProc = reinterpret_cast(&objc_msgSend); + + return (*pProc)(pObj, selector, args...); + } +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::MethodSignature* NS::Object::methodSignatureForSelector(const void* pObj, SEL selector) +{ + return sendMessage(pObj, _NS_PRIVATE_SEL(methodSignatureForSelector_), selector); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Object::respondsToSelector(const void* pObj, SEL selector) +{ + return sendMessage(pObj, _NS_PRIVATE_SEL(respondsToSelector_), selector); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Ret NS::Object::sendMessageSafe(const void* pObj, SEL selector, _Args... args) +{ + if ((respondsToSelector(pObj, selector)) || (nullptr != methodSignatureForSelector(pObj, selector))) + { + return sendMessage<_Ret>(pObj, selector, args...); + } + + if constexpr (!std::is_void<_Ret>::value) + { + return 0; + } +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Class* NS::Object::alloc(const char* pClassName) +{ + return sendMessage<_Class*>(objc_lookUpClass(pClassName), _NS_PRIVATE_SEL(alloc)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Class* NS::Object::alloc(const void* pClass) +{ + return sendMessage<_Class*>(pClass, _NS_PRIVATE_SEL(alloc)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +template +_NS_INLINE _Class* NS::Object::init() +{ + return sendMessage<_Class*>(this, _NS_PRIVATE_SEL(init)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::Object::hash() const +{ + return sendMessage(this, _NS_PRIVATE_SEL(hash)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Object::isEqual(const Object* pObject) const +{ + return sendMessage(this, _NS_PRIVATE_SEL(isEqual_), pObject); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Object::description() const +{ + return sendMessage(this, _NS_PRIVATE_SEL(description)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::Object::debugDescription() const +{ + return sendMessageSafe(this, _NS_PRIVATE_SEL(debugDescription)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSPrivate.hpp b/vendor/metal-cpp/Foundation/NSPrivate.hpp new file mode 100644 index 000000000..af5ffb148 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSPrivate.hpp @@ -0,0 +1,507 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSPrivate.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#define _NS_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol) +#define _NS_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor) + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#if defined(NS_PRIVATE_IMPLEMENTATION) + +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _NS_PRIVATE_VISIBILITY __attribute__((visibility("hidden"))) +#else +#define _NS_PRIVATE_VISIBILITY __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN + +#define _NS_PRIVATE_IMPORT __attribute__((weak_import)) + +#ifdef __OBJC__ +#define _NS_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol)) +#define _NS_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol)) +#else +#define _NS_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol) +#define _NS_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol) +#endif // __OBJC__ + +#define _NS_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _NS_PRIVATE_VISIBILITY = _NS_PRIVATE_OBJC_LOOKUP_CLASS(symbol) +#define _NS_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _NS_PRIVATE_VISIBILITY = _NS_PRIVATE_OBJC_GET_PROTOCOL(symbol) +#define _NS_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _NS_PRIVATE_VISIBILITY = sel_registerName(symbol) +#define _NS_PRIVATE_DEF_CONST(type, symbol) \ + _NS_EXTERN type const NS##symbol _NS_PRIVATE_IMPORT; \ + type const NS::symbol = (nullptr != &NS##symbol) ? NS##symbol : nullptr + +#else + +#define _NS_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol +#define _NS_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol +#define _NS_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor +#define _NS_PRIVATE_DEF_CONST(type, symbol) extern type const NS::symbol + +#endif // NS_PRIVATE_IMPLEMENTATION + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +namespace Private +{ + namespace Class + { + + _NS_PRIVATE_DEF_CLS(NSArray); + _NS_PRIVATE_DEF_CLS(NSAutoreleasePool); + _NS_PRIVATE_DEF_CLS(NSBundle); + _NS_PRIVATE_DEF_CLS(NSCondition); + _NS_PRIVATE_DEF_CLS(NSDate); + _NS_PRIVATE_DEF_CLS(NSDictionary); + _NS_PRIVATE_DEF_CLS(NSError); + _NS_PRIVATE_DEF_CLS(NSNotificationCenter); + _NS_PRIVATE_DEF_CLS(NSNumber); + _NS_PRIVATE_DEF_CLS(NSObject); + _NS_PRIVATE_DEF_CLS(NSProcessInfo); + _NS_PRIVATE_DEF_CLS(NSSet); + _NS_PRIVATE_DEF_CLS(NSString); + _NS_PRIVATE_DEF_CLS(NSURL); + _NS_PRIVATE_DEF_CLS(NSValue); + + } // Class +} // Private +} // MTL + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +namespace Private +{ + namespace Protocol + { + + } // Protocol +} // Private +} // NS + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +namespace Private +{ + namespace Selector + { + + _NS_PRIVATE_DEF_SEL(addObject_, + "addObject:"); + _NS_PRIVATE_DEF_SEL(addObserverName_object_queue_block_, + "addObserverForName:object:queue:usingBlock:"); + _NS_PRIVATE_DEF_SEL(activeProcessorCount, + "activeProcessorCount"); + _NS_PRIVATE_DEF_SEL(allBundles, + "allBundles"); + _NS_PRIVATE_DEF_SEL(allFrameworks, + "allFrameworks"); + _NS_PRIVATE_DEF_SEL(allObjects, + "allObjects"); + _NS_PRIVATE_DEF_SEL(alloc, + "alloc"); + _NS_PRIVATE_DEF_SEL(appStoreReceiptURL, + "appStoreReceiptURL"); + _NS_PRIVATE_DEF_SEL(arguments, + "arguments"); + _NS_PRIVATE_DEF_SEL(array, + "array"); + _NS_PRIVATE_DEF_SEL(arrayWithObject_, + "arrayWithObject:"); + _NS_PRIVATE_DEF_SEL(arrayWithObjects_count_, + "arrayWithObjects:count:"); + _NS_PRIVATE_DEF_SEL(automaticTerminationSupportEnabled, + "automaticTerminationSupportEnabled"); + _NS_PRIVATE_DEF_SEL(autorelease, + "autorelease"); + _NS_PRIVATE_DEF_SEL(beginActivityWithOptions_reason_, + "beginActivityWithOptions:reason:"); + _NS_PRIVATE_DEF_SEL(boolValue, + "boolValue"); + _NS_PRIVATE_DEF_SEL(broadcast, + "broadcast"); + _NS_PRIVATE_DEF_SEL(builtInPlugInsPath, + "builtInPlugInsPath"); + _NS_PRIVATE_DEF_SEL(builtInPlugInsURL, + "builtInPlugInsURL"); + _NS_PRIVATE_DEF_SEL(bundleIdentifier, + "bundleIdentifier"); + _NS_PRIVATE_DEF_SEL(bundlePath, + "bundlePath"); + _NS_PRIVATE_DEF_SEL(bundleURL, + "bundleURL"); + _NS_PRIVATE_DEF_SEL(bundleWithPath_, + "bundleWithPath:"); + _NS_PRIVATE_DEF_SEL(bundleWithURL_, + "bundleWithURL:"); + _NS_PRIVATE_DEF_SEL(caseInsensitiveCompare_, + "caseInsensitiveCompare:"); + _NS_PRIVATE_DEF_SEL(characterAtIndex_, + "characterAtIndex:"); + _NS_PRIVATE_DEF_SEL(charValue, + "charValue"); + _NS_PRIVATE_DEF_SEL(countByEnumeratingWithState_objects_count_, + "countByEnumeratingWithState:objects:count:"); + _NS_PRIVATE_DEF_SEL(cStringUsingEncoding_, + "cStringUsingEncoding:"); + _NS_PRIVATE_DEF_SEL(code, + "code"); + _NS_PRIVATE_DEF_SEL(compare_, + "compare:"); + _NS_PRIVATE_DEF_SEL(copy, + "copy"); + _NS_PRIVATE_DEF_SEL(count, + "count"); + _NS_PRIVATE_DEF_SEL(dateWithTimeIntervalSinceNow_, + "dateWithTimeIntervalSinceNow:"); + _NS_PRIVATE_DEF_SEL(defaultCenter, + "defaultCenter"); + _NS_PRIVATE_DEF_SEL(descriptionWithLocale_, + "descriptionWithLocale:"); + _NS_PRIVATE_DEF_SEL(disableAutomaticTermination_, + "disableAutomaticTermination:"); + _NS_PRIVATE_DEF_SEL(disableSuddenTermination, + "disableSuddenTermination"); + _NS_PRIVATE_DEF_SEL(debugDescription, + "debugDescription"); + _NS_PRIVATE_DEF_SEL(description, + "description"); + _NS_PRIVATE_DEF_SEL(dictionary, + "dictionary"); + _NS_PRIVATE_DEF_SEL(dictionaryWithObject_forKey_, + "dictionaryWithObject:forKey:"); + _NS_PRIVATE_DEF_SEL(dictionaryWithObjects_forKeys_count_, + "dictionaryWithObjects:forKeys:count:"); + _NS_PRIVATE_DEF_SEL(domain, + "domain"); + _NS_PRIVATE_DEF_SEL(doubleValue, + "doubleValue"); + _NS_PRIVATE_DEF_SEL(drain, + "drain"); + _NS_PRIVATE_DEF_SEL(enableAutomaticTermination_, + "enableAutomaticTermination:"); + _NS_PRIVATE_DEF_SEL(enableSuddenTermination, + "enableSuddenTermination"); + _NS_PRIVATE_DEF_SEL(endActivity_, + "endActivity:"); + _NS_PRIVATE_DEF_SEL(environment, + "environment"); + _NS_PRIVATE_DEF_SEL(errorWithDomain_code_userInfo_, + "errorWithDomain:code:userInfo:"); + _NS_PRIVATE_DEF_SEL(executablePath, + "executablePath"); + _NS_PRIVATE_DEF_SEL(executableURL, + "executableURL"); + _NS_PRIVATE_DEF_SEL(fileSystemRepresentation, + "fileSystemRepresentation"); + _NS_PRIVATE_DEF_SEL(fileURLWithPath_, + "fileURLWithPath:"); + _NS_PRIVATE_DEF_SEL(floatValue, + "floatValue"); + _NS_PRIVATE_DEF_SEL(fullUserName, + "fullUserName"); + _NS_PRIVATE_DEF_SEL(getValue_size_, + "getValue:size:"); + _NS_PRIVATE_DEF_SEL(globallyUniqueString, + "globallyUniqueString"); + _NS_PRIVATE_DEF_SEL(hash, + "hash"); + _NS_PRIVATE_DEF_SEL(hostName, + "hostName"); + _NS_PRIVATE_DEF_SEL(infoDictionary, + "infoDictionary"); + _NS_PRIVATE_DEF_SEL(init, + "init"); + _NS_PRIVATE_DEF_SEL(initFileURLWithPath_, + "initFileURLWithPath:"); + _NS_PRIVATE_DEF_SEL(initWithBool_, + "initWithBool:"); + _NS_PRIVATE_DEF_SEL(initWithBytes_objCType_, + "initWithBytes:objCType:"); + _NS_PRIVATE_DEF_SEL(initWithBytesNoCopy_length_encoding_freeWhenDone_, + "initWithBytesNoCopy:length:encoding:freeWhenDone:"); + _NS_PRIVATE_DEF_SEL(initWithChar_, + "initWithChar:"); + _NS_PRIVATE_DEF_SEL(initWithCoder_, + "initWithCoder:"); + _NS_PRIVATE_DEF_SEL(initWithCString_encoding_, + "initWithCString:encoding:"); + _NS_PRIVATE_DEF_SEL(initWithDomain_code_userInfo_, + "initWithDomain:code:userInfo:"); + _NS_PRIVATE_DEF_SEL(initWithDouble_, + "initWithDouble:"); + _NS_PRIVATE_DEF_SEL(initWithFloat_, + "initWithFloat:"); + _NS_PRIVATE_DEF_SEL(initWithInt_, + "initWithInt:"); + _NS_PRIVATE_DEF_SEL(initWithLong_, + "initWithLong:"); + _NS_PRIVATE_DEF_SEL(initWithLongLong_, + "initWithLongLong:"); + _NS_PRIVATE_DEF_SEL(initWithObjects_count_, + "initWithObjects:count:"); + _NS_PRIVATE_DEF_SEL(initWithObjects_forKeys_count_, + "initWithObjects:forKeys:count:"); + _NS_PRIVATE_DEF_SEL(initWithPath_, + "initWithPath:"); + _NS_PRIVATE_DEF_SEL(initWithShort_, + "initWithShort:"); + _NS_PRIVATE_DEF_SEL(initWithString_, + "initWithString:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedChar_, + "initWithUnsignedChar:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedInt_, + "initWithUnsignedInt:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedLong_, + "initWithUnsignedLong:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedLongLong_, + "initWithUnsignedLongLong:"); + _NS_PRIVATE_DEF_SEL(initWithUnsignedShort_, + "initWithUnsignedShort:"); + _NS_PRIVATE_DEF_SEL(initWithURL_, + "initWithURL:"); + _NS_PRIVATE_DEF_SEL(integerValue, + "integerValue"); + _NS_PRIVATE_DEF_SEL(intValue, + "intValue"); + _NS_PRIVATE_DEF_SEL(isEqual_, + "isEqual:"); + _NS_PRIVATE_DEF_SEL(isEqualToNumber_, + "isEqualToNumber:"); + _NS_PRIVATE_DEF_SEL(isEqualToString_, + "isEqualToString:"); + _NS_PRIVATE_DEF_SEL(isEqualToValue_, + "isEqualToValue:"); + _NS_PRIVATE_DEF_SEL(isiOSAppOnMac, + "isiOSAppOnMac"); + _NS_PRIVATE_DEF_SEL(isLoaded, + "isLoaded"); + _NS_PRIVATE_DEF_SEL(isLowPowerModeEnabled, + "isLowPowerModeEnabled"); + _NS_PRIVATE_DEF_SEL(isMacCatalystApp, + "isMacCatalystApp"); + _NS_PRIVATE_DEF_SEL(isOperatingSystemAtLeastVersion_, + "isOperatingSystemAtLeastVersion:"); + _NS_PRIVATE_DEF_SEL(keyEnumerator, + "keyEnumerator"); + _NS_PRIVATE_DEF_SEL(length, + "length"); + _NS_PRIVATE_DEF_SEL(lengthOfBytesUsingEncoding_, + "lengthOfBytesUsingEncoding:"); + _NS_PRIVATE_DEF_SEL(load, + "load"); + _NS_PRIVATE_DEF_SEL(loadAndReturnError_, + "loadAndReturnError:"); + _NS_PRIVATE_DEF_SEL(localizedDescription, + "localizedDescription"); + _NS_PRIVATE_DEF_SEL(localizedFailureReason, + "localizedFailureReason"); + _NS_PRIVATE_DEF_SEL(localizedInfoDictionary, + "localizedInfoDictionary"); + _NS_PRIVATE_DEF_SEL(localizedRecoveryOptions, + "localizedRecoveryOptions"); + _NS_PRIVATE_DEF_SEL(localizedRecoverySuggestion, + "localizedRecoverySuggestion"); + _NS_PRIVATE_DEF_SEL(localizedStringForKey_value_table_, + "localizedStringForKey:value:table:"); + _NS_PRIVATE_DEF_SEL(lock, + "lock"); + _NS_PRIVATE_DEF_SEL(longValue, + "longValue"); + _NS_PRIVATE_DEF_SEL(longLongValue, + "longLongValue"); + _NS_PRIVATE_DEF_SEL(mainBundle, + "mainBundle"); + _NS_PRIVATE_DEF_SEL(maximumLengthOfBytesUsingEncoding_, + "maximumLengthOfBytesUsingEncoding:"); + _NS_PRIVATE_DEF_SEL(methodSignatureForSelector_, + "methodSignatureForSelector:"); + _NS_PRIVATE_DEF_SEL(mutableBytes, + "mutableBytes"); + _NS_PRIVATE_DEF_SEL(name, + "name"); + _NS_PRIVATE_DEF_SEL(nextObject, + "nextObject"); + _NS_PRIVATE_DEF_SEL(numberWithBool_, + "numberWithBool:"); + _NS_PRIVATE_DEF_SEL(numberWithChar_, + "numberWithChar:"); + _NS_PRIVATE_DEF_SEL(numberWithDouble_, + "numberWithDouble:"); + _NS_PRIVATE_DEF_SEL(numberWithFloat_, + "numberWithFloat:"); + _NS_PRIVATE_DEF_SEL(numberWithInt_, + "numberWithInt:"); + _NS_PRIVATE_DEF_SEL(numberWithLong_, + "numberWithLong:"); + _NS_PRIVATE_DEF_SEL(numberWithLongLong_, + "numberWithLongLong:"); + _NS_PRIVATE_DEF_SEL(numberWithShort_, + "numberWithShort:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedChar_, + "numberWithUnsignedChar:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedInt_, + "numberWithUnsignedInt:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedLong_, + "numberWithUnsignedLong:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedLongLong_, + "numberWithUnsignedLongLong:"); + _NS_PRIVATE_DEF_SEL(numberWithUnsignedShort_, + "numberWithUnsignedShort:"); + _NS_PRIVATE_DEF_SEL(objCType, + "objCType"); + _NS_PRIVATE_DEF_SEL(object, + "object"); + _NS_PRIVATE_DEF_SEL(objectAtIndex_, + "objectAtIndex:"); + _NS_PRIVATE_DEF_SEL(objectEnumerator, + "objectEnumerator"); + _NS_PRIVATE_DEF_SEL(objectForInfoDictionaryKey_, + "objectForInfoDictionaryKey:"); + _NS_PRIVATE_DEF_SEL(objectForKey_, + "objectForKey:"); + _NS_PRIVATE_DEF_SEL(operatingSystem, + "operatingSystem"); + _NS_PRIVATE_DEF_SEL(operatingSystemVersion, + "operatingSystemVersion"); + _NS_PRIVATE_DEF_SEL(operatingSystemVersionString, + "operatingSystemVersionString"); + _NS_PRIVATE_DEF_SEL(pathForAuxiliaryExecutable_, + "pathForAuxiliaryExecutable:"); + _NS_PRIVATE_DEF_SEL(performActivityWithOptions_reason_usingBlock_, + "performActivityWithOptions:reason:usingBlock:"); + _NS_PRIVATE_DEF_SEL(performExpiringActivityWithReason_usingBlock_, + "performExpiringActivityWithReason:usingBlock:"); + _NS_PRIVATE_DEF_SEL(physicalMemory, + "physicalMemory"); + _NS_PRIVATE_DEF_SEL(pointerValue, + "pointerValue"); + _NS_PRIVATE_DEF_SEL(preflightAndReturnError_, + "preflightAndReturnError:"); + _NS_PRIVATE_DEF_SEL(privateFrameworksPath, + "privateFrameworksPath"); + _NS_PRIVATE_DEF_SEL(privateFrameworksURL, + "privateFrameworksURL"); + _NS_PRIVATE_DEF_SEL(processIdentifier, + "processIdentifier"); + _NS_PRIVATE_DEF_SEL(processInfo, + "processInfo"); + _NS_PRIVATE_DEF_SEL(processName, + "processName"); + _NS_PRIVATE_DEF_SEL(processorCount, + "processorCount"); + _NS_PRIVATE_DEF_SEL(rangeOfString_options_, + "rangeOfString:options:"); + _NS_PRIVATE_DEF_SEL(release, + "release"); + _NS_PRIVATE_DEF_SEL(removeObserver_, + "removeObserver:"); + _NS_PRIVATE_DEF_SEL(resourcePath, + "resourcePath"); + _NS_PRIVATE_DEF_SEL(resourceURL, + "resourceURL"); + _NS_PRIVATE_DEF_SEL(respondsToSelector_, + "respondsToSelector:"); + _NS_PRIVATE_DEF_SEL(retain, + "retain"); + _NS_PRIVATE_DEF_SEL(retainCount, + "retainCount"); + _NS_PRIVATE_DEF_SEL(setAutomaticTerminationSupportEnabled_, + "setAutomaticTerminationSupportEnabled:"); + _NS_PRIVATE_DEF_SEL(setProcessName_, + "setProcessName:"); + _NS_PRIVATE_DEF_SEL(sharedFrameworksPath, + "sharedFrameworksPath"); + _NS_PRIVATE_DEF_SEL(sharedFrameworksURL, + "sharedFrameworksURL"); + _NS_PRIVATE_DEF_SEL(sharedSupportPath, + "sharedSupportPath"); + _NS_PRIVATE_DEF_SEL(sharedSupportURL, + "sharedSupportURL"); + _NS_PRIVATE_DEF_SEL(shortValue, + "shortValue"); + _NS_PRIVATE_DEF_SEL(showPools, + "showPools"); + _NS_PRIVATE_DEF_SEL(signal, + "signal"); + _NS_PRIVATE_DEF_SEL(string, + "string"); + _NS_PRIVATE_DEF_SEL(stringValue, + "stringValue"); + _NS_PRIVATE_DEF_SEL(stringWithString_, + "stringWithString:"); + _NS_PRIVATE_DEF_SEL(stringWithCString_encoding_, + "stringWithCString:encoding:"); + _NS_PRIVATE_DEF_SEL(stringByAppendingString_, + "stringByAppendingString:"); + _NS_PRIVATE_DEF_SEL(systemUptime, + "systemUptime"); + _NS_PRIVATE_DEF_SEL(thermalState, + "thermalState"); + _NS_PRIVATE_DEF_SEL(unload, + "unload"); + _NS_PRIVATE_DEF_SEL(unlock, + "unlock"); + _NS_PRIVATE_DEF_SEL(unsignedCharValue, + "unsignedCharValue"); + _NS_PRIVATE_DEF_SEL(unsignedIntegerValue, + "unsignedIntegerValue"); + _NS_PRIVATE_DEF_SEL(unsignedIntValue, + "unsignedIntValue"); + _NS_PRIVATE_DEF_SEL(unsignedLongValue, + "unsignedLongValue"); + _NS_PRIVATE_DEF_SEL(unsignedLongLongValue, + "unsignedLongLongValue"); + _NS_PRIVATE_DEF_SEL(unsignedShortValue, + "unsignedShortValue"); + _NS_PRIVATE_DEF_SEL(URLForAuxiliaryExecutable_, + "URLForAuxiliaryExecutable:"); + _NS_PRIVATE_DEF_SEL(userInfo, + "userInfo"); + _NS_PRIVATE_DEF_SEL(userName, + "userName"); + _NS_PRIVATE_DEF_SEL(UTF8String, + "UTF8String"); + _NS_PRIVATE_DEF_SEL(valueWithBytes_objCType_, + "valueWithBytes:objCType:"); + _NS_PRIVATE_DEF_SEL(valueWithPointer_, + "valueWithPointer:"); + _NS_PRIVATE_DEF_SEL(wait, + "wait"); + _NS_PRIVATE_DEF_SEL(waitUntilDate_, + "waitUntilDate:"); + } // Class +} // Private +} // MTL + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSProcessInfo.hpp b/vendor/metal-cpp/Foundation/NSProcessInfo.hpp new file mode 100644 index 000000000..565b59937 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSProcessInfo.hpp @@ -0,0 +1,354 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSProcessInfo.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSNotification.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSTypes.hpp" + +#include + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +_NS_CONST(NotificationName, ProcessInfoThermalStateDidChangeNotification); +_NS_CONST(NotificationName, ProcessInfoPowerStateDidChangeNotification); + +_NS_ENUM(NS::Integer, ProcessInfoThermalState) { + ProcessInfoThermalStateNominal = 0, + ProcessInfoThermalStateFair = 1, + ProcessInfoThermalStateSerious = 2, + ProcessInfoThermalStateCritical = 3 +}; + +_NS_OPTIONS(std::uint64_t, ActivityOptions) { + ActivityIdleDisplaySleepDisabled = (1ULL << 40), + ActivityIdleSystemSleepDisabled = (1ULL << 20), + ActivitySuddenTerminationDisabled = (1ULL << 14), + ActivityAutomaticTerminationDisabled = (1ULL << 15), + ActivityUserInitiated = (0x00FFFFFFULL | ActivityIdleSystemSleepDisabled), + ActivityUserInitiatedAllowingIdleSystemSleep = (ActivityUserInitiated & ~ActivityIdleSystemSleepDisabled), + ActivityBackground = 0x000000FFULL, + ActivityLatencyCritical = 0xFF00000000ULL, +}; + +class ProcessInfo : public Referencing +{ +public: + static ProcessInfo* processInfo(); + + class Array* arguments() const; + class Dictionary* environment() const; + class String* hostName() const; + class String* processName() const; + void setProcessName(const String* pString); + int processIdentifier() const; + class String* globallyUniqueString() const; + + class String* userName() const; + class String* fullUserName() const; + + UInteger operatingSystem() const; + OperatingSystemVersion operatingSystemVersion() const; + class String* operatingSystemVersionString() const; + bool isOperatingSystemAtLeastVersion(OperatingSystemVersion version) const; + + UInteger processorCount() const; + UInteger activeProcessorCount() const; + unsigned long long physicalMemory() const; + TimeInterval systemUptime() const; + + void disableSuddenTermination(); + void enableSuddenTermination(); + + void disableAutomaticTermination(const class String* pReason); + void enableAutomaticTermination(const class String* pReason); + bool automaticTerminationSupportEnabled() const; + void setAutomaticTerminationSupportEnabled(bool enabled); + + class Object* beginActivity(ActivityOptions options, const class String* pReason); + void endActivity(class Object* pActivity); + void performActivity(ActivityOptions options, const class String* pReason, void (^block)(void)); + void performActivity(ActivityOptions options, const class String* pReason, const std::function& func); + void performExpiringActivity(const class String* pReason, void (^block)(bool expired)); + void performExpiringActivity(const class String* pReason, const std::function& func); + + ProcessInfoThermalState thermalState() const; + bool isLowPowerModeEnabled() const; + + bool isiOSAppOnMac() const; + bool isMacCatalystApp() const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_PRIVATE_DEF_CONST(NS::NotificationName, ProcessInfoThermalStateDidChangeNotification); +_NS_PRIVATE_DEF_CONST(NS::NotificationName, ProcessInfoPowerStateDidChangeNotification); + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::ProcessInfo* NS::ProcessInfo::processInfo() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSProcessInfo), _NS_PRIVATE_SEL(processInfo)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Array* NS::ProcessInfo::arguments() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(arguments)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Dictionary* NS::ProcessInfo::environment() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(environment)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::ProcessInfo::hostName() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(hostName)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::ProcessInfo::processName() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(processName)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::setProcessName(const String* pString) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(setProcessName_), pString); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE int NS::ProcessInfo::processIdentifier() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(processIdentifier)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::ProcessInfo::globallyUniqueString() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(globallyUniqueString)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::ProcessInfo::userName() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(userName)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::ProcessInfo::fullUserName() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(fullUserName)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::ProcessInfo::operatingSystem() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(operatingSystem)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::OperatingSystemVersion NS::ProcessInfo::operatingSystemVersion() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(operatingSystemVersion)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::ProcessInfo::operatingSystemVersionString() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(operatingSystemVersionString)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::ProcessInfo::isOperatingSystemAtLeastVersion(OperatingSystemVersion version) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isOperatingSystemAtLeastVersion_), version); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::ProcessInfo::processorCount() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(processorCount)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::ProcessInfo::activeProcessorCount() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(activeProcessorCount)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE unsigned long long NS::ProcessInfo::physicalMemory() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(physicalMemory)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::TimeInterval NS::ProcessInfo::systemUptime() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(systemUptime)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::disableSuddenTermination() +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(disableSuddenTermination)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::enableSuddenTermination() +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(enableSuddenTermination)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::disableAutomaticTermination(const String* pReason) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(disableAutomaticTermination_), pReason); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::enableAutomaticTermination(const String* pReason) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(enableAutomaticTermination_), pReason); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::ProcessInfo::automaticTerminationSupportEnabled() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(automaticTerminationSupportEnabled)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::setAutomaticTerminationSupportEnabled(bool enabled) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(setAutomaticTerminationSupportEnabled_), enabled); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Object* NS::ProcessInfo::beginActivity(ActivityOptions options, const String* pReason) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(beginActivityWithOptions_reason_), options, pReason); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::endActivity(Object* pActivity) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(endActivity_), pActivity); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::performActivity(ActivityOptions options, const String* pReason, void (^block)(void)) +{ + Object::sendMessage(this, _NS_PRIVATE_SEL(performActivityWithOptions_reason_usingBlock_), options, pReason, block); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::performActivity(ActivityOptions options, const String* pReason, const std::function& function) +{ + __block std::function blockFunction = function; + + performActivity(options, pReason, ^() { blockFunction(); }); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::performExpiringActivity(const String* pReason, void (^block)(bool expired)) +{ + Object::sendMessageSafe(this, _NS_PRIVATE_SEL(performExpiringActivityWithReason_usingBlock_), pReason, block); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE void NS::ProcessInfo::performExpiringActivity(const String* pReason, const std::function& function) +{ + __block std::function blockFunction = function; + + performExpiringActivity(pReason, ^(bool expired) { blockFunction(expired); }); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::ProcessInfoThermalState NS::ProcessInfo::thermalState() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(thermalState)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::ProcessInfo::isLowPowerModeEnabled() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(isLowPowerModeEnabled)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::ProcessInfo::isiOSAppOnMac() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(isiOSAppOnMac)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::ProcessInfo::isMacCatalystApp() const +{ + return Object::sendMessageSafe(this, _NS_PRIVATE_SEL(isMacCatalystApp)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSRange.hpp b/vendor/metal-cpp/Foundation/NSRange.hpp new file mode 100644 index 000000000..2c5beb5b9 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSRange.hpp @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSRange.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +struct Range +{ + static Range Make(UInteger loc, UInteger len); + + Range(UInteger loc, UInteger len); + + bool Equal(const Range& range) const; + bool LocationInRange(UInteger loc) const; + UInteger Max() const; + + UInteger location; + UInteger length; +} _NS_PACKED; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Range::Range(UInteger loc, UInteger len) + : location(loc) + , length(len) +{ +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Range NS::Range::Make(UInteger loc, UInteger len) +{ + return Range(loc, len); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Range::Equal(const Range& range) const +{ + return (location == range.location) && (length == range.length); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::Range::LocationInRange(UInteger loc) const +{ + return (!(loc < location)) && ((loc - location) < length); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::Range::Max() const +{ + return location + length; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSSet.hpp b/vendor/metal-cpp/Foundation/NSSet.hpp new file mode 100644 index 000000000..a4eb0d64e --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSSet.hpp @@ -0,0 +1,87 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSSet.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSObject.hpp" +#include "NSEnumerator.hpp" + +/*****Immutable Set*******/ + +namespace NS +{ + class Set : public NS::Copying + { + public: + UInteger count() const; + Enumerator* objectEnumerator() const; + + static Set* alloc(); + + Set* init(); + Set* init(const Object* const* pObjects, UInteger count); + Set* init(const class Coder* pCoder); + + }; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::Set::count() const +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(count)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Enumerator* NS::Set::objectEnumerator() const +{ + return NS::Object::sendMessage*>(this, _NS_PRIVATE_SEL(objectEnumerator)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Set* NS::Set::alloc() +{ + return NS::Object::alloc(_NS_PRIVATE_CLS(NSSet)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Set* NS::Set::init() +{ + return NS::Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Set* NS::Set::init(const Object* const* pObjects, NS::UInteger count) +{ + return NS::Object::sendMessage(this, _NS_PRIVATE_SEL(initWithObjects_count_), pObjects, count); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Set* NS::Set::init(const class Coder* pCoder) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCoder_), pCoder); +} diff --git a/vendor/metal-cpp/Foundation/NSSharedPtr.hpp b/vendor/metal-cpp/Foundation/NSSharedPtr.hpp new file mode 100644 index 000000000..09e8855ef --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSSharedPtr.hpp @@ -0,0 +1,311 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSSharedPtr.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "NSDefines.hpp" + +namespace NS +{ +template +class SharedPtr +{ +public: + /** + * Create a new null pointer. + */ + SharedPtr(); + + /** + * Destroy this SharedPtr, decreasing the reference count. + */ + ~SharedPtr(); + + /** + * SharedPtr copy constructor. + */ + SharedPtr(const SharedPtr<_Class>& other) noexcept; + + /** + * Construction from another pointee type. + */ + template + SharedPtr(const SharedPtr<_OtherClass>& other, typename std::enable_if_t> * = nullptr) noexcept; + + /** + * SharedPtr move constructor. + */ + SharedPtr(SharedPtr<_Class>&& other) noexcept; + + /** + * Move from another pointee type. + */ + template + SharedPtr(SharedPtr<_OtherClass>&& other, typename std::enable_if_t> * = nullptr) noexcept; + + /** + * Copy assignment operator. + * Copying increases reference count. Only releases previous pointee if objects are different. + */ + SharedPtr& operator=(const SharedPtr<_Class>& other); + + /** + * Copy-assignment from different pointee. + * Copying increases reference count. Only releases previous pointee if objects are different. + */ + template + typename std::enable_if_t, SharedPtr &> + operator=(const SharedPtr<_OtherClass>& other); + + /** + * Move assignment operator. + * Move without affecting reference counts, unless pointees are equal. Moved-from object is reset to nullptr. + */ + SharedPtr& operator=(SharedPtr<_Class>&& other); + + /** + * Move-asignment from different pointee. + * Move without affecting reference counts, unless pointees are equal. Moved-from object is reset to nullptr. + */ + template + typename std::enable_if_t, SharedPtr &> + operator=(SharedPtr<_OtherClass>&& other); + + /** + * Access raw pointee. + * @warning Avoid wrapping the returned value again, as it may lead double frees unless this object becomes detached. + */ + _Class* get() const; + + /** + * Call operations directly on the pointee. + */ + _Class* operator->() const; + + /** + * Implicit cast to bool. + */ + explicit operator bool() const; + + /** + * Reset this SharedPtr to null, decreasing the reference count. + */ + void reset(); + + /** + * Detach the SharedPtr from the pointee, without decreasing the reference count. + */ + void detach(); + + template + friend SharedPtr<_OtherClass> RetainPtr(_OtherClass* ptr); + + template + friend SharedPtr<_OtherClass> TransferPtr(_OtherClass* ptr); + +private: + _Class* m_pObject; +}; + +/** + * Create a SharedPtr by retaining an existing raw pointer. + * Increases the reference count of the passed-in object. + * If the passed-in object was in an AutoreleasePool, it will be removed from it. + */ +template +_NS_INLINE NS::SharedPtr<_Class> RetainPtr(_Class* pObject) +{ + NS::SharedPtr<_Class> ret; + ret.m_pObject = pObject->retain(); + return ret; +} + +/* + * Create a SharedPtr by transfering the ownership of an existing raw pointer to SharedPtr. + * Does not increase the reference count of the passed-in pointer, it is assumed to be >= 1. + * This method does not remove objects from an AutoreleasePool. +*/ +template +_NS_INLINE NS::SharedPtr<_Class> TransferPtr(_Class* pObject) +{ + NS::SharedPtr<_Class> ret; + ret.m_pObject = pObject; + return ret; +} + +} + +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr() + : m_pObject(nullptr) +{ +} + +template +_NS_INLINE NS::SharedPtr<_Class>::~SharedPtr() +{ + if (m_pObject) + { + m_pObject->release(); + } +} + +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(const NS::SharedPtr<_Class>& other) noexcept + : m_pObject(other.m_pObject->retain()) +{ +} + +template +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(const NS::SharedPtr<_OtherClass>& other, typename std::enable_if_t> *) noexcept + : m_pObject(reinterpret_cast<_Class*>(other.get()->retain())) +{ +} + +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(NS::SharedPtr<_Class>&& other) noexcept + : m_pObject(other.m_pObject) +{ + other.m_pObject = nullptr; +} + +template +template +_NS_INLINE NS::SharedPtr<_Class>::SharedPtr(NS::SharedPtr<_OtherClass>&& other, typename std::enable_if_t> *) noexcept + : m_pObject(reinterpret_cast<_Class*>(other.get())) +{ + other.detach(); +} + +template +_NS_INLINE _Class* NS::SharedPtr<_Class>::get() const +{ + return m_pObject; +} + +template +_NS_INLINE _Class* NS::SharedPtr<_Class>::operator->() const +{ + return m_pObject; +} + +template +_NS_INLINE NS::SharedPtr<_Class>::operator bool() const +{ + return nullptr != m_pObject; +} + +template +_NS_INLINE void NS::SharedPtr<_Class>::reset() +{ + m_pObject->release(); + m_pObject = nullptr; +} + +template +_NS_INLINE void NS::SharedPtr<_Class>::detach() +{ + m_pObject = nullptr; +} + +template +_NS_INLINE NS::SharedPtr<_Class>& NS::SharedPtr<_Class>::operator=(const SharedPtr<_Class>& other) +{ + if (m_pObject != other.m_pObject) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = other.m_pObject->retain(); + } + return *this; +} + +template +template +typename std::enable_if_t, NS::SharedPtr<_Class> &> +_NS_INLINE NS::SharedPtr<_Class>::operator=(const SharedPtr<_OtherClass>& other) +{ + if (m_pObject != other.get()) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = reinterpret_cast<_Class*>(other.get()->retain()); + } + return *this; +} + +template +_NS_INLINE NS::SharedPtr<_Class>& NS::SharedPtr<_Class>::operator=(SharedPtr<_Class>&& other) +{ + if (m_pObject != other.m_pObject) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = other.m_pObject; + } + else + { + m_pObject = other.m_pObject; + other.m_pObject->release(); + } + other.m_pObject = nullptr; + return *this; +} + +template +template +typename std::enable_if_t, NS::SharedPtr<_Class> &> +_NS_INLINE NS::SharedPtr<_Class>::operator=(SharedPtr<_OtherClass>&& other) +{ + if (m_pObject != other.get()) + { + if (m_pObject) + { + m_pObject->release(); + } + m_pObject = reinterpret_cast<_Class*>(other.get()); + other.detach(); + } + else + { + m_pObject = other.get(); + other.reset(); + } + return *this; +} + +template +_NS_INLINE bool operator==(const NS::SharedPtr<_ClassLhs>& lhs, const NS::SharedPtr<_ClassRhs>& rhs) +{ + return lhs.get() == rhs.get(); +} + +template +_NS_INLINE bool operator!=(const NS::SharedPtr<_ClassLhs>& lhs, const NS::SharedPtr<_ClassRhs>& rhs) +{ + return lhs.get() != rhs.get(); +} diff --git a/vendor/metal-cpp/Foundation/NSString.hpp b/vendor/metal-cpp/Foundation/NSString.hpp new file mode 100644 index 000000000..c601fc012 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSString.hpp @@ -0,0 +1,255 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSString.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSObjCRuntime.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSRange.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +_NS_ENUM(NS::UInteger, StringEncoding) { + ASCIIStringEncoding = 1, + NEXTSTEPStringEncoding = 2, + JapaneseEUCStringEncoding = 3, + UTF8StringEncoding = 4, + ISOLatin1StringEncoding = 5, + SymbolStringEncoding = 6, + NonLossyASCIIStringEncoding = 7, + ShiftJISStringEncoding = 8, + ISOLatin2StringEncoding = 9, + UnicodeStringEncoding = 10, + WindowsCP1251StringEncoding = 11, + WindowsCP1252StringEncoding = 12, + WindowsCP1253StringEncoding = 13, + WindowsCP1254StringEncoding = 14, + WindowsCP1250StringEncoding = 15, + ISO2022JPStringEncoding = 21, + MacOSRomanStringEncoding = 30, + + UTF16StringEncoding = UnicodeStringEncoding, + + UTF16BigEndianStringEncoding = 0x90000100, + UTF16LittleEndianStringEncoding = 0x94000100, + + UTF32StringEncoding = 0x8c000100, + UTF32BigEndianStringEncoding = 0x98000100, + UTF32LittleEndianStringEncoding = 0x9c000100 +}; + +_NS_OPTIONS(NS::UInteger, StringCompareOptions) { + CaseInsensitiveSearch = 1, + LiteralSearch = 2, + BackwardsSearch = 4, + AnchoredSearch = 8, + NumericSearch = 64, + DiacriticInsensitiveSearch = 128, + WidthInsensitiveSearch = 256, + ForcedOrderingSearch = 512, + RegularExpressionSearch = 1024 +}; + +using unichar = unsigned short; + +class String : public Copying +{ +public: + static String* string(); + static String* string(const String* pString); + static String* string(const char* pString, StringEncoding encoding); + + static String* alloc(); + String* init(); + String* init(const String* pString); + String* init(const char* pString, StringEncoding encoding); + String* init(void* pBytes, UInteger len, StringEncoding encoding, bool freeBuffer); + + unichar character(UInteger index) const; + UInteger length() const; + + const char* cString(StringEncoding encoding) const; + const char* utf8String() const; + UInteger maximumLengthOfBytes(StringEncoding encoding) const; + UInteger lengthOfBytes(StringEncoding encoding) const; + + bool isEqualToString(const String* pString) const; + Range rangeOfString(const String* pString, StringCompareOptions options) const; + + const char* fileSystemRepresentation() const; + + String* stringByAppendingString(const String* pString) const; + ComparisonResult caseInsensitiveCompare(const String* pString) const; +}; + +/// Create an NS::String* from a string literal. +#define MTLSTR(literal) (NS::String*)__builtin___CFStringMakeConstantString("" literal "") + +template +[[deprecated("please use MTLSTR(str)")]] constexpr const String* MakeConstantString(const char (&str)[_StringLen]) +{ + return reinterpret_cast(__CFStringMakeConstantString(str)); +} + +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::string() +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSString), _NS_PRIVATE_SEL(string)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::string(const String* pString) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSString), _NS_PRIVATE_SEL(stringWithString_), pString); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::string(const char* pString, StringEncoding encoding) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSString), _NS_PRIVATE_SEL(stringWithCString_encoding_), pString, encoding); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::alloc() +{ + return Object::alloc(_NS_PRIVATE_CLS(NSString)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::init() +{ + return Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::init(const String* pString) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithString_), pString); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::init(const char* pString, StringEncoding encoding) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithCString_encoding_), pString, encoding); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::init(void* pBytes, UInteger len, StringEncoding encoding, bool freeBuffer) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithBytesNoCopy_length_encoding_freeWhenDone_), pBytes, len, encoding, freeBuffer); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::unichar NS::String::character(UInteger index) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(characterAtIndex_), index); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::String::length() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(length)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE const char* NS::String::cString(StringEncoding encoding) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(cStringUsingEncoding_), encoding); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE const char* NS::String::utf8String() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(UTF8String)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::String::maximumLengthOfBytes(StringEncoding encoding) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(maximumLengthOfBytesUsingEncoding_), encoding); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::UInteger NS::String::lengthOfBytes(StringEncoding encoding) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(lengthOfBytesUsingEncoding_), encoding); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE bool NS::String::isEqualToString(const NS::String* pString) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(isEqualToString_), pString); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::Range NS::String::rangeOfString(const NS::String* pString, NS::StringCompareOptions options) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(rangeOfString_options_), pString, options); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE const char* NS::String::fileSystemRepresentation() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(fileSystemRepresentation)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::String* NS::String::stringByAppendingString(const String* pString) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(stringByAppendingString_), pString); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::ComparisonResult NS::String::caseInsensitiveCompare(const String* pString) const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(caseInsensitiveCompare_), pString); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSTypes.hpp b/vendor/metal-cpp/Foundation/NSTypes.hpp new file mode 100644 index 000000000..5f098f670 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSTypes.hpp @@ -0,0 +1,51 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSTypes.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" + +#include +#include + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +using TimeInterval = double; + +using Integer = std::intptr_t; +using UInteger = std::uintptr_t; + +const Integer IntegerMax = INTPTR_MAX; +const Integer IntegerMin = INTPTR_MIN; +const UInteger UIntegerMax = UINTPTR_MAX; + +struct OperatingSystemVersion +{ + Integer majorVersion; + Integer minorVersion; + Integer patchVersion; +} _NS_PACKED; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Foundation/NSURL.hpp b/vendor/metal-cpp/Foundation/NSURL.hpp new file mode 100644 index 000000000..a7bc3e6e3 --- /dev/null +++ b/vendor/metal-cpp/Foundation/NSURL.hpp @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Foundation/NSURL.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "NSDefines.hpp" +#include "NSObject.hpp" +#include "NSPrivate.hpp" +#include "NSTypes.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace NS +{ +class URL : public Copying +{ +public: + static URL* fileURLWithPath(const class String* pPath); + + static URL* alloc(); + URL* init(); + URL* init(const class String* pString); + URL* initFileURLWithPath(const class String* pPath); + + const char* fileSystemRepresentation() const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::URL::fileURLWithPath(const String* pPath) +{ + return Object::sendMessage(_NS_PRIVATE_CLS(NSURL), _NS_PRIVATE_SEL(fileURLWithPath_), pPath); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::URL::alloc() +{ + return Object::alloc(_NS_PRIVATE_CLS(NSURL)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::URL::init() +{ + return Object::init(); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::URL::init(const String* pString) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initWithString_), pString); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE NS::URL* NS::URL::initFileURLWithPath(const String* pPath) +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(initFileURLWithPath_), pPath); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_NS_INLINE const char* NS::URL::fileSystemRepresentation() const +{ + return Object::sendMessage(this, _NS_PRIVATE_SEL(fileSystemRepresentation)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/LICENSE.txt b/vendor/metal-cpp/LICENSE.txt new file mode 100644 index 000000000..6c877ff98 --- /dev/null +++ b/vendor/metal-cpp/LICENSE.txt @@ -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 © 2023 Apple 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. diff --git a/vendor/metal-cpp/Metal/MTLAccelerationStructure.hpp b/vendor/metal-cpp/Metal/MTLAccelerationStructure.hpp new file mode 100644 index 000000000..9d71fa3d3 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLAccelerationStructure.hpp @@ -0,0 +1,1081 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLAccelerationStructure.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLAccelerationStructure.hpp" +#include "MTLAccelerationStructureTypes.hpp" +#include "MTLResource.hpp" +#include "MTLStageInputOutputDescriptor.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, AccelerationStructureUsage) { + AccelerationStructureUsageNone = 0, + AccelerationStructureUsageRefit = 1, + AccelerationStructureUsagePreferFastBuild = 2, + AccelerationStructureUsageExtendedLimits = 4, +}; + +_MTL_OPTIONS(uint32_t, AccelerationStructureInstanceOptions) { + AccelerationStructureInstanceOptionNone = 0, + AccelerationStructureInstanceOptionDisableTriangleCulling = 1, + AccelerationStructureInstanceOptionTriangleFrontFacingWindingCounterClockwise = 2, + AccelerationStructureInstanceOptionOpaque = 4, + AccelerationStructureInstanceOptionNonOpaque = 8, +}; + +class AccelerationStructureDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureDescriptor* alloc(); + + class AccelerationStructureDescriptor* init(); + + MTL::AccelerationStructureUsage usage() const; + void setUsage(MTL::AccelerationStructureUsage usage); +}; + +class AccelerationStructureGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureGeometryDescriptor* alloc(); + + class AccelerationStructureGeometryDescriptor* init(); + + NS::UInteger intersectionFunctionTableOffset() const; + void setIntersectionFunctionTableOffset(NS::UInteger intersectionFunctionTableOffset); + + bool opaque() const; + void setOpaque(bool opaque); + + bool allowDuplicateIntersectionFunctionInvocation() const; + void setAllowDuplicateIntersectionFunctionInvocation(bool allowDuplicateIntersectionFunctionInvocation); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Buffer* primitiveDataBuffer() const; + void setPrimitiveDataBuffer(const class Buffer* primitiveDataBuffer); + + NS::UInteger primitiveDataBufferOffset() const; + void setPrimitiveDataBufferOffset(NS::UInteger primitiveDataBufferOffset); + + NS::UInteger primitiveDataStride() const; + void setPrimitiveDataStride(NS::UInteger primitiveDataStride); + + NS::UInteger primitiveDataElementSize() const; + void setPrimitiveDataElementSize(NS::UInteger primitiveDataElementSize); +}; + +_MTL_ENUM(uint32_t, MotionBorderMode) { + MotionBorderModeClamp = 0, + MotionBorderModeVanish = 1, +}; + +class PrimitiveAccelerationStructureDescriptor : public NS::Copying +{ +public: + static class PrimitiveAccelerationStructureDescriptor* alloc(); + + class PrimitiveAccelerationStructureDescriptor* init(); + + NS::Array* geometryDescriptors() const; + void setGeometryDescriptors(const NS::Array* geometryDescriptors); + + MTL::MotionBorderMode motionStartBorderMode() const; + void setMotionStartBorderMode(MTL::MotionBorderMode motionStartBorderMode); + + MTL::MotionBorderMode motionEndBorderMode() const; + void setMotionEndBorderMode(MTL::MotionBorderMode motionEndBorderMode); + + float motionStartTime() const; + void setMotionStartTime(float motionStartTime); + + float motionEndTime() const; + void setMotionEndTime(float motionEndTime); + + NS::UInteger motionKeyframeCount() const; + void setMotionKeyframeCount(NS::UInteger motionKeyframeCount); + + static MTL::PrimitiveAccelerationStructureDescriptor* descriptor(); +}; + +class AccelerationStructureTriangleGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureTriangleGeometryDescriptor* alloc(); + + class AccelerationStructureTriangleGeometryDescriptor* init(); + + class Buffer* vertexBuffer() const; + void setVertexBuffer(const class Buffer* vertexBuffer); + + NS::UInteger vertexBufferOffset() const; + void setVertexBufferOffset(NS::UInteger vertexBufferOffset); + + MTL::AttributeFormat vertexFormat() const; + void setVertexFormat(MTL::AttributeFormat vertexFormat); + + NS::UInteger vertexStride() const; + void setVertexStride(NS::UInteger vertexStride); + + class Buffer* indexBuffer() const; + void setIndexBuffer(const class Buffer* indexBuffer); + + NS::UInteger indexBufferOffset() const; + void setIndexBufferOffset(NS::UInteger indexBufferOffset); + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger triangleCount() const; + void setTriangleCount(NS::UInteger triangleCount); + + class Buffer* transformationMatrixBuffer() const; + void setTransformationMatrixBuffer(const class Buffer* transformationMatrixBuffer); + + NS::UInteger transformationMatrixBufferOffset() const; + void setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset); + + static MTL::AccelerationStructureTriangleGeometryDescriptor* descriptor(); +}; + +class AccelerationStructureBoundingBoxGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureBoundingBoxGeometryDescriptor* alloc(); + + class AccelerationStructureBoundingBoxGeometryDescriptor* init(); + + class Buffer* boundingBoxBuffer() const; + void setBoundingBoxBuffer(const class Buffer* boundingBoxBuffer); + + NS::UInteger boundingBoxBufferOffset() const; + void setBoundingBoxBufferOffset(NS::UInteger boundingBoxBufferOffset); + + NS::UInteger boundingBoxStride() const; + void setBoundingBoxStride(NS::UInteger boundingBoxStride); + + NS::UInteger boundingBoxCount() const; + void setBoundingBoxCount(NS::UInteger boundingBoxCount); + + static MTL::AccelerationStructureBoundingBoxGeometryDescriptor* descriptor(); +}; + +class MotionKeyframeData : public NS::Referencing +{ +public: + static class MotionKeyframeData* alloc(); + + class MotionKeyframeData* init(); + + class Buffer* buffer() const; + void setBuffer(const class Buffer* buffer); + + NS::UInteger offset() const; + void setOffset(NS::UInteger offset); + + static MTL::MotionKeyframeData* data(); +}; + +class AccelerationStructureMotionTriangleGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureMotionTriangleGeometryDescriptor* alloc(); + + class AccelerationStructureMotionTriangleGeometryDescriptor* init(); + + NS::Array* vertexBuffers() const; + void setVertexBuffers(const NS::Array* vertexBuffers); + + MTL::AttributeFormat vertexFormat() const; + void setVertexFormat(MTL::AttributeFormat vertexFormat); + + NS::UInteger vertexStride() const; + void setVertexStride(NS::UInteger vertexStride); + + class Buffer* indexBuffer() const; + void setIndexBuffer(const class Buffer* indexBuffer); + + NS::UInteger indexBufferOffset() const; + void setIndexBufferOffset(NS::UInteger indexBufferOffset); + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger triangleCount() const; + void setTriangleCount(NS::UInteger triangleCount); + + class Buffer* transformationMatrixBuffer() const; + void setTransformationMatrixBuffer(const class Buffer* transformationMatrixBuffer); + + NS::UInteger transformationMatrixBufferOffset() const; + void setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset); + + static MTL::AccelerationStructureMotionTriangleGeometryDescriptor* descriptor(); +}; + +class AccelerationStructureMotionBoundingBoxGeometryDescriptor : public NS::Copying +{ +public: + static class AccelerationStructureMotionBoundingBoxGeometryDescriptor* alloc(); + + class AccelerationStructureMotionBoundingBoxGeometryDescriptor* init(); + + NS::Array* boundingBoxBuffers() const; + void setBoundingBoxBuffers(const NS::Array* boundingBoxBuffers); + + NS::UInteger boundingBoxStride() const; + void setBoundingBoxStride(NS::UInteger boundingBoxStride); + + NS::UInteger boundingBoxCount() const; + void setBoundingBoxCount(NS::UInteger boundingBoxCount); + + static MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* descriptor(); +}; + +struct AccelerationStructureInstanceDescriptor +{ + MTL::PackedFloat4x3 transformationMatrix; + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t accelerationStructureIndex; +} _MTL_PACKED; + +struct AccelerationStructureUserIDInstanceDescriptor +{ + MTL::PackedFloat4x3 transformationMatrix; + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t accelerationStructureIndex; + uint32_t userID; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, AccelerationStructureInstanceDescriptorType) { + AccelerationStructureInstanceDescriptorTypeDefault = 0, + AccelerationStructureInstanceDescriptorTypeUserID = 1, + AccelerationStructureInstanceDescriptorTypeMotion = 2, +}; + +struct AccelerationStructureMotionInstanceDescriptor +{ + MTL::AccelerationStructureInstanceOptions options; + uint32_t mask; + uint32_t intersectionFunctionTableOffset; + uint32_t accelerationStructureIndex; + uint32_t userID; + uint32_t motionTransformsStartIndex; + uint32_t motionTransformsCount; + MTL::MotionBorderMode motionStartBorderMode; + MTL::MotionBorderMode motionEndBorderMode; + float motionStartTime; + float motionEndTime; +} _MTL_PACKED; + +class InstanceAccelerationStructureDescriptor : public NS::Copying +{ +public: + static class InstanceAccelerationStructureDescriptor* alloc(); + + class InstanceAccelerationStructureDescriptor* init(); + + class Buffer* instanceDescriptorBuffer() const; + void setInstanceDescriptorBuffer(const class Buffer* instanceDescriptorBuffer); + + NS::UInteger instanceDescriptorBufferOffset() const; + void setInstanceDescriptorBufferOffset(NS::UInteger instanceDescriptorBufferOffset); + + NS::UInteger instanceDescriptorStride() const; + void setInstanceDescriptorStride(NS::UInteger instanceDescriptorStride); + + NS::UInteger instanceCount() const; + void setInstanceCount(NS::UInteger instanceCount); + + NS::Array* instancedAccelerationStructures() const; + void setInstancedAccelerationStructures(const NS::Array* instancedAccelerationStructures); + + MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType() const; + void setInstanceDescriptorType(MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType); + + class Buffer* motionTransformBuffer() const; + void setMotionTransformBuffer(const class Buffer* motionTransformBuffer); + + NS::UInteger motionTransformBufferOffset() const; + void setMotionTransformBufferOffset(NS::UInteger motionTransformBufferOffset); + + NS::UInteger motionTransformCount() const; + void setMotionTransformCount(NS::UInteger motionTransformCount); + + static MTL::InstanceAccelerationStructureDescriptor* descriptor(); +}; + +class AccelerationStructure : public NS::Referencing +{ +public: + NS::UInteger size() const; + + MTL::ResourceID gpuResourceID() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructureDescriptor* MTL::AccelerationStructureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructureDescriptor* MTL::AccelerationStructureDescriptor::init() +{ + return NS::Object::init(); +} + +// property: usage +_MTL_INLINE MTL::AccelerationStructureUsage MTL::AccelerationStructureDescriptor::usage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usage)); +} + +_MTL_INLINE void MTL::AccelerationStructureDescriptor::setUsage(MTL::AccelerationStructureUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setUsage_), usage); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructureGeometryDescriptor* MTL::AccelerationStructureGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureGeometryDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructureGeometryDescriptor* MTL::AccelerationStructureGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +// property: intersectionFunctionTableOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::intersectionFunctionTableOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(intersectionFunctionTableOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setIntersectionFunctionTableOffset(NS::UInteger intersectionFunctionTableOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTableOffset_), intersectionFunctionTableOffset); +} + +// property: opaque +_MTL_INLINE bool MTL::AccelerationStructureGeometryDescriptor::opaque() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(opaque)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setOpaque(bool opaque) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaque_), opaque); +} + +// property: allowDuplicateIntersectionFunctionInvocation +_MTL_INLINE bool MTL::AccelerationStructureGeometryDescriptor::allowDuplicateIntersectionFunctionInvocation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowDuplicateIntersectionFunctionInvocation)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setAllowDuplicateIntersectionFunctionInvocation(bool allowDuplicateIntersectionFunctionInvocation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAllowDuplicateIntersectionFunctionInvocation_), allowDuplicateIntersectionFunctionInvocation); +} + +// property: label +_MTL_INLINE NS::String* MTL::AccelerationStructureGeometryDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: primitiveDataBuffer +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureGeometryDescriptor::primitiveDataBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataBuffer(const MTL::Buffer* primitiveDataBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataBuffer_), primitiveDataBuffer); +} + +// property: primitiveDataBufferOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::primitiveDataBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataBufferOffset(NS::UInteger primitiveDataBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataBufferOffset_), primitiveDataBufferOffset); +} + +// property: primitiveDataStride +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::primitiveDataStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataStride(NS::UInteger primitiveDataStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataStride_), primitiveDataStride); +} + +// property: primitiveDataElementSize +_MTL_INLINE NS::UInteger MTL::AccelerationStructureGeometryDescriptor::primitiveDataElementSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(primitiveDataElementSize)); +} + +_MTL_INLINE void MTL::AccelerationStructureGeometryDescriptor::setPrimitiveDataElementSize(NS::UInteger primitiveDataElementSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrimitiveDataElementSize_), primitiveDataElementSize); +} + +// static method: alloc +_MTL_INLINE MTL::PrimitiveAccelerationStructureDescriptor* MTL::PrimitiveAccelerationStructureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPrimitiveAccelerationStructureDescriptor)); +} + +// method: init +_MTL_INLINE MTL::PrimitiveAccelerationStructureDescriptor* MTL::PrimitiveAccelerationStructureDescriptor::init() +{ + return NS::Object::init(); +} + +// property: geometryDescriptors +_MTL_INLINE NS::Array* MTL::PrimitiveAccelerationStructureDescriptor::geometryDescriptors() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(geometryDescriptors)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setGeometryDescriptors(const NS::Array* geometryDescriptors) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setGeometryDescriptors_), geometryDescriptors); +} + +// property: motionStartBorderMode +_MTL_INLINE MTL::MotionBorderMode MTL::PrimitiveAccelerationStructureDescriptor::motionStartBorderMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionStartBorderMode)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionStartBorderMode(MTL::MotionBorderMode motionStartBorderMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionStartBorderMode_), motionStartBorderMode); +} + +// property: motionEndBorderMode +_MTL_INLINE MTL::MotionBorderMode MTL::PrimitiveAccelerationStructureDescriptor::motionEndBorderMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionEndBorderMode)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionEndBorderMode(MTL::MotionBorderMode motionEndBorderMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionEndBorderMode_), motionEndBorderMode); +} + +// property: motionStartTime +_MTL_INLINE float MTL::PrimitiveAccelerationStructureDescriptor::motionStartTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionStartTime)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionStartTime(float motionStartTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionStartTime_), motionStartTime); +} + +// property: motionEndTime +_MTL_INLINE float MTL::PrimitiveAccelerationStructureDescriptor::motionEndTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionEndTime)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionEndTime(float motionEndTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionEndTime_), motionEndTime); +} + +// property: motionKeyframeCount +_MTL_INLINE NS::UInteger MTL::PrimitiveAccelerationStructureDescriptor::motionKeyframeCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionKeyframeCount)); +} + +_MTL_INLINE void MTL::PrimitiveAccelerationStructureDescriptor::setMotionKeyframeCount(NS::UInteger motionKeyframeCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionKeyframeCount_), motionKeyframeCount); +} + +// static method: descriptor +_MTL_INLINE MTL::PrimitiveAccelerationStructureDescriptor* MTL::PrimitiveAccelerationStructureDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLPrimitiveAccelerationStructureDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructureTriangleGeometryDescriptor* MTL::AccelerationStructureTriangleGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureTriangleGeometryDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructureTriangleGeometryDescriptor* MTL::AccelerationStructureTriangleGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +// property: vertexBuffer +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureTriangleGeometryDescriptor::vertexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexBuffer(const MTL::Buffer* vertexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_), vertexBuffer); +} + +// property: vertexBufferOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::vertexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexBufferOffset(NS::UInteger vertexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_), vertexBufferOffset); +} + +// property: vertexFormat +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureTriangleGeometryDescriptor::vertexFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexFormat(MTL::AttributeFormat vertexFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexFormat_), vertexFormat); +} + +// property: vertexStride +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::vertexStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setVertexStride(NS::UInteger vertexStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexStride_), vertexStride); +} + +// property: indexBuffer +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureTriangleGeometryDescriptor::indexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); +} + +// property: indexBufferOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::indexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); +} + +// property: indexType +_MTL_INLINE MTL::IndexType MTL::AccelerationStructureTriangleGeometryDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +// property: triangleCount +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::triangleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(triangleCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setTriangleCount(NS::UInteger triangleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTriangleCount_), triangleCount); +} + +// property: transformationMatrixBuffer +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureTriangleGeometryDescriptor::transformationMatrixBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setTransformationMatrixBuffer(const MTL::Buffer* transformationMatrixBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBuffer_), transformationMatrixBuffer); +} + +// property: transformationMatrixBufferOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureTriangleGeometryDescriptor::transformationMatrixBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureTriangleGeometryDescriptor::setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBufferOffset_), transformationMatrixBufferOffset); +} + +// static method: descriptor +_MTL_INLINE MTL::AccelerationStructureTriangleGeometryDescriptor* MTL::AccelerationStructureTriangleGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureTriangleGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructureBoundingBoxGeometryDescriptor* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureBoundingBoxGeometryDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructureBoundingBoxGeometryDescriptor* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +// property: boundingBoxBuffer +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxBuffer(const MTL::Buffer* boundingBoxBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxBuffer_), boundingBoxBuffer); +} + +// property: boundingBoxBufferOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxBufferOffset(NS::UInteger boundingBoxBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxBufferOffset_), boundingBoxBufferOffset); +} + +// property: boundingBoxStride +_MTL_INLINE NS::UInteger MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxStride(NS::UInteger boundingBoxStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxStride_), boundingBoxStride); +} + +// property: boundingBoxCount +_MTL_INLINE NS::UInteger MTL::AccelerationStructureBoundingBoxGeometryDescriptor::boundingBoxCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureBoundingBoxGeometryDescriptor::setBoundingBoxCount(NS::UInteger boundingBoxCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxCount_), boundingBoxCount); +} + +// static method: descriptor +_MTL_INLINE MTL::AccelerationStructureBoundingBoxGeometryDescriptor* MTL::AccelerationStructureBoundingBoxGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureBoundingBoxGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +// static method: alloc +_MTL_INLINE MTL::MotionKeyframeData* MTL::MotionKeyframeData::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLMotionKeyframeData)); +} + +// method: init +_MTL_INLINE MTL::MotionKeyframeData* MTL::MotionKeyframeData::init() +{ + return NS::Object::init(); +} + +// property: buffer +_MTL_INLINE MTL::Buffer* MTL::MotionKeyframeData::buffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffer)); +} + +_MTL_INLINE void MTL::MotionKeyframeData::setBuffer(const MTL::Buffer* buffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_), buffer); +} + +// property: offset +_MTL_INLINE NS::UInteger MTL::MotionKeyframeData::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +_MTL_INLINE void MTL::MotionKeyframeData::setOffset(NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOffset_), offset); +} + +// static method: data +_MTL_INLINE MTL::MotionKeyframeData* MTL::MotionKeyframeData::data() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLMotionKeyframeData), _MTL_PRIVATE_SEL(data)); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructureMotionTriangleGeometryDescriptor* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionTriangleGeometryDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructureMotionTriangleGeometryDescriptor* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +// property: vertexBuffers +_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::vertexBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBuffers)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setVertexBuffers(const NS::Array* vertexBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffers_), vertexBuffers); +} + +// property: vertexFormat +_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureMotionTriangleGeometryDescriptor::vertexFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexFormat)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setVertexFormat(MTL::AttributeFormat vertexFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexFormat_), vertexFormat); +} + +// property: vertexStride +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::vertexStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setVertexStride(NS::UInteger vertexStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexStride_), vertexStride); +} + +// property: indexBuffer +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::indexBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); +} + +// property: indexBufferOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::indexBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); +} + +// property: indexType +_MTL_INLINE MTL::IndexType MTL::AccelerationStructureMotionTriangleGeometryDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +// property: triangleCount +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::triangleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(triangleCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setTriangleCount(NS::UInteger triangleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTriangleCount_), triangleCount); +} + +// property: transformationMatrixBuffer +_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::transformationMatrixBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setTransformationMatrixBuffer(const MTL::Buffer* transformationMatrixBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBuffer_), transformationMatrixBuffer); +} + +// property: transformationMatrixBufferOffset +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionTriangleGeometryDescriptor::transformationMatrixBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(transformationMatrixBufferOffset)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionTriangleGeometryDescriptor::setTransformationMatrixBufferOffset(NS::UInteger transformationMatrixBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTransformationMatrixBufferOffset_), transformationMatrixBufferOffset); +} + +// static method: descriptor +_MTL_INLINE MTL::AccelerationStructureMotionTriangleGeometryDescriptor* MTL::AccelerationStructureMotionTriangleGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionTriangleGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::init() +{ + return NS::Object::init(); +} + +// property: boundingBoxBuffers +_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::boundingBoxBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxBuffers)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::setBoundingBoxBuffers(const NS::Array* boundingBoxBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxBuffers_), boundingBoxBuffers); +} + +// property: boundingBoxStride +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::boundingBoxStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxStride)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::setBoundingBoxStride(NS::UInteger boundingBoxStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxStride_), boundingBoxStride); +} + +// property: boundingBoxCount +_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::boundingBoxCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(boundingBoxCount)); +} + +_MTL_INLINE void MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::setBoundingBoxCount(NS::UInteger boundingBoxCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBoundingBoxCount_), boundingBoxCount); +} + +// static method: descriptor +_MTL_INLINE MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor* MTL::AccelerationStructureMotionBoundingBoxGeometryDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +// static method: alloc +_MTL_INLINE MTL::InstanceAccelerationStructureDescriptor* MTL::InstanceAccelerationStructureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLInstanceAccelerationStructureDescriptor)); +} + +// method: init +_MTL_INLINE MTL::InstanceAccelerationStructureDescriptor* MTL::InstanceAccelerationStructureDescriptor::init() +{ + return NS::Object::init(); +} + +// property: instanceDescriptorBuffer +_MTL_INLINE MTL::Buffer* MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBuffer)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorBuffer(const MTL::Buffer* instanceDescriptorBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBuffer_), instanceDescriptorBuffer); +} + +// property: instanceDescriptorBufferOffset +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBufferOffset)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorBufferOffset(NS::UInteger instanceDescriptorBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBufferOffset_), instanceDescriptorBufferOffset); +} + +// property: instanceDescriptorStride +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorStride)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorStride(NS::UInteger instanceDescriptorStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorStride_), instanceDescriptorStride); +} + +// property: instanceCount +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::instanceCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceCount)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceCount(NS::UInteger instanceCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceCount_), instanceCount); +} + +// property: instancedAccelerationStructures +_MTL_INLINE NS::Array* MTL::InstanceAccelerationStructureDescriptor::instancedAccelerationStructures() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instancedAccelerationStructures)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstancedAccelerationStructures(const NS::Array* instancedAccelerationStructures) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstancedAccelerationStructures_), instancedAccelerationStructures); +} + +// property: instanceDescriptorType +_MTL_INLINE MTL::AccelerationStructureInstanceDescriptorType MTL::InstanceAccelerationStructureDescriptor::instanceDescriptorType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorType)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setInstanceDescriptorType(MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorType_), instanceDescriptorType); +} + +// property: motionTransformBuffer +_MTL_INLINE MTL::Buffer* MTL::InstanceAccelerationStructureDescriptor::motionTransformBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBuffer)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformBuffer(const MTL::Buffer* motionTransformBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBuffer_), motionTransformBuffer); +} + +// property: motionTransformBufferOffset +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::motionTransformBufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBufferOffset)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformBufferOffset(NS::UInteger motionTransformBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBufferOffset_), motionTransformBufferOffset); +} + +// property: motionTransformCount +_MTL_INLINE NS::UInteger MTL::InstanceAccelerationStructureDescriptor::motionTransformCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformCount)); +} + +_MTL_INLINE void MTL::InstanceAccelerationStructureDescriptor::setMotionTransformCount(NS::UInteger motionTransformCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformCount_), motionTransformCount); +} + +// static method: descriptor +_MTL_INLINE MTL::InstanceAccelerationStructureDescriptor* MTL::InstanceAccelerationStructureDescriptor::descriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLInstanceAccelerationStructureDescriptor), _MTL_PRIVATE_SEL(descriptor)); +} + +// property: size +_MTL_INLINE NS::UInteger MTL::AccelerationStructure::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::AccelerationStructure::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} diff --git a/vendor/metal-cpp/Metal/MTLAccelerationStructureCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLAccelerationStructureCommandEncoder.hpp new file mode 100644 index 000000000..e0b4ccd97 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLAccelerationStructureCommandEncoder.hpp @@ -0,0 +1,290 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLAccelerationStructureCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLAccelerationStructureCommandEncoder.hpp" +#include "MTLArgument.hpp" +#include "MTLCommandEncoder.hpp" + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, AccelerationStructureRefitOptions) { + AccelerationStructureRefitOptionVertexData = 1, + AccelerationStructureRefitOptionPerPrimitiveData = 2, +}; + +class AccelerationStructureCommandEncoder : public NS::Referencing +{ +public: + void buildAccelerationStructure(const class AccelerationStructure* accelerationStructure, const class AccelerationStructureDescriptor* descriptor, const class Buffer* scratchBuffer, NS::UInteger scratchBufferOffset); + + void refitAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructureDescriptor* descriptor, const class AccelerationStructure* destinationAccelerationStructure, const class Buffer* scratchBuffer, NS::UInteger scratchBufferOffset); + + void refitAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructureDescriptor* descriptor, const class AccelerationStructure* destinationAccelerationStructure, const class Buffer* scratchBuffer, NS::UInteger scratchBufferOffset, MTL::AccelerationStructureRefitOptions options); + + void copyAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructure* destinationAccelerationStructure); + + void writeCompactedAccelerationStructureSize(const class AccelerationStructure* accelerationStructure, const class Buffer* buffer, NS::UInteger offset); + + void writeCompactedAccelerationStructureSize(const class AccelerationStructure* accelerationStructure, const class Buffer* buffer, NS::UInteger offset, MTL::DataType sizeDataType); + + void copyAndCompactAccelerationStructure(const class AccelerationStructure* sourceAccelerationStructure, const class AccelerationStructure* destinationAccelerationStructure); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage); + + void useHeap(const class Heap* heap); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); +}; + +class AccelerationStructurePassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class AccelerationStructurePassSampleBufferAttachmentDescriptor* alloc(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class AccelerationStructurePassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class AccelerationStructurePassSampleBufferAttachmentDescriptorArray* alloc(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptorArray* init(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class AccelerationStructurePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class AccelerationStructurePassDescriptor : public NS::Copying +{ +public: + static class AccelerationStructurePassDescriptor* alloc(); + + class AccelerationStructurePassDescriptor* init(); + + static class AccelerationStructurePassDescriptor* accelerationStructurePassDescriptor(); + + class AccelerationStructurePassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +// method: buildAccelerationStructure:descriptor:scratchBuffer:scratchBufferOffset: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::buildAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, const MTL::AccelerationStructureDescriptor* descriptor, const MTL::Buffer* scratchBuffer, NS::UInteger scratchBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(buildAccelerationStructure_descriptor_scratchBuffer_scratchBufferOffset_), accelerationStructure, descriptor, scratchBuffer, scratchBufferOffset); +} + +// method: refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::refitAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructureDescriptor* descriptor, const MTL::AccelerationStructure* destinationAccelerationStructure, const MTL::Buffer* scratchBuffer, NS::UInteger scratchBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_), sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset); +} + +// method: refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:options: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::refitAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructureDescriptor* descriptor, const MTL::AccelerationStructure* destinationAccelerationStructure, const MTL::Buffer* scratchBuffer, NS::UInteger scratchBufferOffset, MTL::AccelerationStructureRefitOptions options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_options_), sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset, options); +} + +// method: copyAccelerationStructure:toAccelerationStructure: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::copyAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructure* destinationAccelerationStructure) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyAccelerationStructure_toAccelerationStructure_), sourceAccelerationStructure, destinationAccelerationStructure); +} + +// method: writeCompactedAccelerationStructureSize:toBuffer:offset: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::writeCompactedAccelerationStructureSize(const MTL::AccelerationStructure* accelerationStructure, const MTL::Buffer* buffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_), accelerationStructure, buffer, offset); +} + +// method: writeCompactedAccelerationStructureSize:toBuffer:offset:sizeDataType: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::writeCompactedAccelerationStructureSize(const MTL::AccelerationStructure* accelerationStructure, const MTL::Buffer* buffer, NS::UInteger offset, MTL::DataType sizeDataType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_sizeDataType_), accelerationStructure, buffer, offset, sizeDataType); +} + +// method: copyAndCompactAccelerationStructure:toAccelerationStructure: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::copyAndCompactAccelerationStructure(const MTL::AccelerationStructure* sourceAccelerationStructure, const MTL::AccelerationStructure* destinationAccelerationStructure) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyAndCompactAccelerationStructure_toAccelerationStructure_), sourceAccelerationStructure, destinationAccelerationStructure); +} + +// method: updateFence: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +// method: waitForFence: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +// method: useResource:usage: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_), resource, usage); +} + +// method: useResources:count:usage: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_), resources, count, usage); +} + +// method: useHeap: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useHeap(const MTL::Heap* heap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_), heap); +} + +// method: useHeaps:count: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_), heaps, count); +} + +// method: sampleCountersInBuffer:atSampleIndex:withBarrier: +_MTL_INLINE void MTL::AccelerationStructureCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: sampleBuffer +_MTL_INLINE MTL::CounterSampleBuffer* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +// property: startOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +// property: endOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray::setObject(const MTL::AccelerationStructurePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::AccelerationStructurePassDescriptor* MTL::AccelerationStructurePassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AccelerationStructurePassDescriptor* MTL::AccelerationStructurePassDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: accelerationStructurePassDescriptor +_MTL_INLINE MTL::AccelerationStructurePassDescriptor* MTL::AccelerationStructurePassDescriptor::accelerationStructurePassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructurePassDescriptor), _MTL_PRIVATE_SEL(accelerationStructurePassDescriptor)); +} + +// property: sampleBufferAttachments +_MTL_INLINE MTL::AccelerationStructurePassSampleBufferAttachmentDescriptorArray* MTL::AccelerationStructurePassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} diff --git a/vendor/metal-cpp/Metal/MTLAccelerationStructureTypes.hpp b/vendor/metal-cpp/Metal/MTLAccelerationStructureTypes.hpp new file mode 100644 index 000000000..146ffc207 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLAccelerationStructureTypes.hpp @@ -0,0 +1,169 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLAccelerationStructureTypes.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "MTLDefines.hpp" +#include "MTLPrivate.hpp" +#include "MTLResource.hpp" +#include "MTLStageInputOutputDescriptor.hpp" + +#include "../Foundation/NSRange.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace MTL +{ +struct PackedFloat3 +{ + PackedFloat3(); + PackedFloat3(float x, float y, float z); + + float& operator[](int idx); + float operator[](int idx) const; + + union + { + struct + { + float x; + float y; + float z; + }; + + float elements[3]; + }; +} _MTL_PACKED; + +struct PackedFloat4x3 +{ + PackedFloat4x3(); + PackedFloat4x3(const PackedFloat3& col0, const PackedFloat3& col1, const PackedFloat3& col2, const PackedFloat3& col3); + + PackedFloat3& operator[](int idx); + const PackedFloat3& operator[](int idx) const; + + PackedFloat3 columns[4]; +} _MTL_PACKED; + +struct AxisAlignedBoundingBox +{ + AxisAlignedBoundingBox(); + AxisAlignedBoundingBox(PackedFloat3 p); + AxisAlignedBoundingBox(PackedFloat3 min, PackedFloat3 max); + + PackedFloat3 min; + PackedFloat3 max; +} _MTL_PACKED; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::PackedFloat3::PackedFloat3() + : x(0.0f) + , y(0.0f) + , z(0.0f) +{ +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::PackedFloat3::PackedFloat3(float _x, float _y, float _z) + : x(_x) + , y(_y) + , z(_z) +{ +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE float& MTL::PackedFloat3::operator[](int idx) +{ + return elements[idx]; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE float MTL::PackedFloat3::operator[](int idx) const +{ + return elements[idx]; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::PackedFloat4x3::PackedFloat4x3() +{ + columns[0] = PackedFloat3(0.0f, 0.0f, 0.0f); + columns[1] = PackedFloat3(0.0f, 0.0f, 0.0f); + columns[2] = PackedFloat3(0.0f, 0.0f, 0.0f); + columns[3] = PackedFloat3(0.0f, 0.0f, 0.0f); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::PackedFloat4x3::PackedFloat4x3(const PackedFloat3& col0, const PackedFloat3& col1, const PackedFloat3& col2, const PackedFloat3& col3) +{ + columns[0] = col0; + columns[1] = col1; + columns[2] = col2; + columns[3] = col3; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::PackedFloat3& MTL::PackedFloat4x3::operator[](int idx) +{ + return columns[idx]; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE const MTL::PackedFloat3& MTL::PackedFloat4x3::operator[](int idx) const +{ + return columns[idx]; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::AxisAlignedBoundingBox::AxisAlignedBoundingBox() + : min(INFINITY, INFINITY, INFINITY) + , max(-INFINITY, -INFINITY, -INFINITY) +{ +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::AxisAlignedBoundingBox::AxisAlignedBoundingBox(PackedFloat3 p) + : min(p) + , max(p) +{ +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::AxisAlignedBoundingBox::AxisAlignedBoundingBox(PackedFloat3 _min, PackedFloat3 _max) + : min(_min) + , max(_max) +{ +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Metal/MTLArgument.hpp b/vendor/metal-cpp/Metal/MTLArgument.hpp new file mode 100644 index 000000000..730b21351 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLArgument.hpp @@ -0,0 +1,841 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLArgument.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLArgument.hpp" +#include "MTLTexture.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, DataType) { + DataTypeNone = 0, + DataTypeStruct = 1, + DataTypeArray = 2, + DataTypeFloat = 3, + DataTypeFloat2 = 4, + DataTypeFloat3 = 5, + DataTypeFloat4 = 6, + DataTypeFloat2x2 = 7, + DataTypeFloat2x3 = 8, + DataTypeFloat2x4 = 9, + DataTypeFloat3x2 = 10, + DataTypeFloat3x3 = 11, + DataTypeFloat3x4 = 12, + DataTypeFloat4x2 = 13, + DataTypeFloat4x3 = 14, + DataTypeFloat4x4 = 15, + DataTypeHalf = 16, + DataTypeHalf2 = 17, + DataTypeHalf3 = 18, + DataTypeHalf4 = 19, + DataTypeHalf2x2 = 20, + DataTypeHalf2x3 = 21, + DataTypeHalf2x4 = 22, + DataTypeHalf3x2 = 23, + DataTypeHalf3x3 = 24, + DataTypeHalf3x4 = 25, + DataTypeHalf4x2 = 26, + DataTypeHalf4x3 = 27, + DataTypeHalf4x4 = 28, + DataTypeInt = 29, + DataTypeInt2 = 30, + DataTypeInt3 = 31, + DataTypeInt4 = 32, + DataTypeUInt = 33, + DataTypeUInt2 = 34, + DataTypeUInt3 = 35, + DataTypeUInt4 = 36, + DataTypeShort = 37, + DataTypeShort2 = 38, + DataTypeShort3 = 39, + DataTypeShort4 = 40, + DataTypeUShort = 41, + DataTypeUShort2 = 42, + DataTypeUShort3 = 43, + DataTypeUShort4 = 44, + DataTypeChar = 45, + DataTypeChar2 = 46, + DataTypeChar3 = 47, + DataTypeChar4 = 48, + DataTypeUChar = 49, + DataTypeUChar2 = 50, + DataTypeUChar3 = 51, + DataTypeUChar4 = 52, + DataTypeBool = 53, + DataTypeBool2 = 54, + DataTypeBool3 = 55, + DataTypeBool4 = 56, + DataTypeTexture = 58, + DataTypeSampler = 59, + DataTypePointer = 60, + DataTypeR8Unorm = 62, + DataTypeR8Snorm = 63, + DataTypeR16Unorm = 64, + DataTypeR16Snorm = 65, + DataTypeRG8Unorm = 66, + DataTypeRG8Snorm = 67, + DataTypeRG16Unorm = 68, + DataTypeRG16Snorm = 69, + DataTypeRGBA8Unorm = 70, + DataTypeRGBA8Unorm_sRGB = 71, + DataTypeRGBA8Snorm = 72, + DataTypeRGBA16Unorm = 73, + DataTypeRGBA16Snorm = 74, + DataTypeRGB10A2Unorm = 75, + DataTypeRG11B10Float = 76, + DataTypeRGB9E5Float = 77, + DataTypeRenderPipeline = 78, + DataTypeComputePipeline = 79, + DataTypeIndirectCommandBuffer = 80, + DataTypeLong = 81, + DataTypeLong2 = 82, + DataTypeLong3 = 83, + DataTypeLong4 = 84, + DataTypeULong = 85, + DataTypeULong2 = 86, + DataTypeULong3 = 87, + DataTypeULong4 = 88, + DataTypeVisibleFunctionTable = 115, + DataTypeIntersectionFunctionTable = 116, + DataTypePrimitiveAccelerationStructure = 117, + DataTypeInstanceAccelerationStructure = 118, +}; + +_MTL_ENUM(NS::Integer, BindingType) { + BindingTypeBuffer = 0, + BindingTypeThreadgroupMemory = 1, + BindingTypeTexture = 2, + BindingTypeSampler = 3, + BindingTypeImageblockData = 16, + BindingTypeImageblock = 17, + BindingTypeVisibleFunctionTable = 24, + BindingTypePrimitiveAccelerationStructure = 25, + BindingTypeInstanceAccelerationStructure = 26, + BindingTypeIntersectionFunctionTable = 27, + BindingTypeObjectPayload = 34, +}; + +_MTL_ENUM(NS::UInteger, ArgumentType) { + ArgumentTypeBuffer = 0, + ArgumentTypeThreadgroupMemory = 1, + ArgumentTypeTexture = 2, + ArgumentTypeSampler = 3, + ArgumentTypeImageblockData = 16, + ArgumentTypeImageblock = 17, + ArgumentTypeVisibleFunctionTable = 24, + ArgumentTypePrimitiveAccelerationStructure = 25, + ArgumentTypeInstanceAccelerationStructure = 26, + ArgumentTypeIntersectionFunctionTable = 27, +}; + +_MTL_ENUM(NS::UInteger, ArgumentAccess) { + ArgumentAccessReadOnly = 0, + ArgumentAccessReadWrite = 1, + ArgumentAccessWriteOnly = 2, +}; + +class Type : public NS::Referencing +{ +public: + static class Type* alloc(); + + class Type* init(); + + MTL::DataType dataType() const; +}; + +class StructMember : public NS::Referencing +{ +public: + static class StructMember* alloc(); + + class StructMember* init(); + + NS::String* name() const; + + NS::UInteger offset() const; + + MTL::DataType dataType() const; + + class StructType* structType(); + + class ArrayType* arrayType(); + + class TextureReferenceType* textureReferenceType(); + + class PointerType* pointerType(); + + NS::UInteger argumentIndex() const; +}; + +class StructType : public NS::Referencing +{ +public: + static class StructType* alloc(); + + class StructType* init(); + + NS::Array* members() const; + + class StructMember* memberByName(const NS::String* name); +}; + +class ArrayType : public NS::Referencing +{ +public: + static class ArrayType* alloc(); + + class ArrayType* init(); + + MTL::DataType elementType() const; + + NS::UInteger arrayLength() const; + + NS::UInteger stride() const; + + NS::UInteger argumentIndexStride() const; + + class StructType* elementStructType(); + + class ArrayType* elementArrayType(); + + class TextureReferenceType* elementTextureReferenceType(); + + class PointerType* elementPointerType(); +}; + +class PointerType : public NS::Referencing +{ +public: + static class PointerType* alloc(); + + class PointerType* init(); + + MTL::DataType elementType() const; + + MTL::ArgumentAccess access() const; + + NS::UInteger alignment() const; + + NS::UInteger dataSize() const; + + bool elementIsArgumentBuffer() const; + + class StructType* elementStructType(); + + class ArrayType* elementArrayType(); +}; + +class TextureReferenceType : public NS::Referencing +{ +public: + static class TextureReferenceType* alloc(); + + class TextureReferenceType* init(); + + MTL::DataType textureDataType() const; + + MTL::TextureType textureType() const; + + MTL::ArgumentAccess access() const; + + bool isDepthTexture() const; +}; + +class Argument : public NS::Referencing +{ +public: + static class Argument* alloc(); + + class Argument* init(); + + NS::String* name() const; + + MTL::ArgumentType type() const; + + MTL::ArgumentAccess access() const; + + NS::UInteger index() const; + + bool active() const; + + NS::UInteger bufferAlignment() const; + + NS::UInteger bufferDataSize() const; + + MTL::DataType bufferDataType() const; + + class StructType* bufferStructType() const; + + class PointerType* bufferPointerType() const; + + NS::UInteger threadgroupMemoryAlignment() const; + + NS::UInteger threadgroupMemoryDataSize() const; + + MTL::TextureType textureType() const; + + MTL::DataType textureDataType() const; + + bool isDepthTexture() const; + + NS::UInteger arrayLength() const; +}; + +class Binding : public NS::Referencing +{ +public: + NS::String* name() const; + + MTL::BindingType type() const; + + MTL::ArgumentAccess access() const; + + NS::UInteger index() const; + + bool used() const; + + bool argument() const; +}; + +class BufferBinding : public NS::Referencing +{ +public: + NS::UInteger bufferAlignment() const; + + NS::UInteger bufferDataSize() const; + + MTL::DataType bufferDataType() const; + + class StructType* bufferStructType() const; + + class PointerType* bufferPointerType() const; +}; + +class ThreadgroupBinding : public NS::Referencing +{ +public: + NS::UInteger threadgroupMemoryAlignment() const; + + NS::UInteger threadgroupMemoryDataSize() const; +}; + +class TextureBinding : public NS::Referencing +{ +public: + MTL::TextureType textureType() const; + + MTL::DataType textureDataType() const; + + bool depthTexture() const; + + NS::UInteger arrayLength() const; +}; + +class ObjectPayloadBinding : public NS::Referencing +{ +public: + NS::UInteger objectPayloadAlignment() const; + + NS::UInteger objectPayloadDataSize() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::Type* MTL::Type::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLType)); +} + +// method: init +_MTL_INLINE MTL::Type* MTL::Type::init() +{ + return NS::Object::init(); +} + +// property: dataType +_MTL_INLINE MTL::DataType MTL::Type::dataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataType)); +} + +// static method: alloc +_MTL_INLINE MTL::StructMember* MTL::StructMember::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStructMember)); +} + +// method: init +_MTL_INLINE MTL::StructMember* MTL::StructMember::init() +{ + return NS::Object::init(); +} + +// property: name +_MTL_INLINE NS::String* MTL::StructMember::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: offset +_MTL_INLINE NS::UInteger MTL::StructMember::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +// property: dataType +_MTL_INLINE MTL::DataType MTL::StructMember::dataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataType)); +} + +// method: structType +_MTL_INLINE MTL::StructType* MTL::StructMember::structType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(structType)); +} + +// method: arrayType +_MTL_INLINE MTL::ArrayType* MTL::StructMember::arrayType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayType)); +} + +// method: textureReferenceType +_MTL_INLINE MTL::TextureReferenceType* MTL::StructMember::textureReferenceType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureReferenceType)); +} + +// method: pointerType +_MTL_INLINE MTL::PointerType* MTL::StructMember::pointerType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pointerType)); +} + +// property: argumentIndex +_MTL_INLINE NS::UInteger MTL::StructMember::argumentIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentIndex)); +} + +// static method: alloc +_MTL_INLINE MTL::StructType* MTL::StructType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStructType)); +} + +// method: init +_MTL_INLINE MTL::StructType* MTL::StructType::init() +{ + return NS::Object::init(); +} + +// property: members +_MTL_INLINE NS::Array* MTL::StructType::members() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(members)); +} + +// method: memberByName: +_MTL_INLINE MTL::StructMember* MTL::StructType::memberByName(const NS::String* name) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(memberByName_), name); +} + +// static method: alloc +_MTL_INLINE MTL::ArrayType* MTL::ArrayType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArrayType)); +} + +// method: init +_MTL_INLINE MTL::ArrayType* MTL::ArrayType::init() +{ + return NS::Object::init(); +} + +// property: elementType +_MTL_INLINE MTL::DataType MTL::ArrayType::elementType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementType)); +} + +// property: arrayLength +_MTL_INLINE NS::UInteger MTL::ArrayType::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +// property: stride +_MTL_INLINE NS::UInteger MTL::ArrayType::stride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stride)); +} + +// property: argumentIndexStride +_MTL_INLINE NS::UInteger MTL::ArrayType::argumentIndexStride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentIndexStride)); +} + +// method: elementStructType +_MTL_INLINE MTL::StructType* MTL::ArrayType::elementStructType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementStructType)); +} + +// method: elementArrayType +_MTL_INLINE MTL::ArrayType* MTL::ArrayType::elementArrayType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementArrayType)); +} + +// method: elementTextureReferenceType +_MTL_INLINE MTL::TextureReferenceType* MTL::ArrayType::elementTextureReferenceType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementTextureReferenceType)); +} + +// method: elementPointerType +_MTL_INLINE MTL::PointerType* MTL::ArrayType::elementPointerType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementPointerType)); +} + +// static method: alloc +_MTL_INLINE MTL::PointerType* MTL::PointerType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPointerType)); +} + +// method: init +_MTL_INLINE MTL::PointerType* MTL::PointerType::init() +{ + return NS::Object::init(); +} + +// property: elementType +_MTL_INLINE MTL::DataType MTL::PointerType::elementType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementType)); +} + +// property: access +_MTL_INLINE MTL::ArgumentAccess MTL::PointerType::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +// property: alignment +_MTL_INLINE NS::UInteger MTL::PointerType::alignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(alignment)); +} + +// property: dataSize +_MTL_INLINE NS::UInteger MTL::PointerType::dataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataSize)); +} + +// property: elementIsArgumentBuffer +_MTL_INLINE bool MTL::PointerType::elementIsArgumentBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementIsArgumentBuffer)); +} + +// method: elementStructType +_MTL_INLINE MTL::StructType* MTL::PointerType::elementStructType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementStructType)); +} + +// method: elementArrayType +_MTL_INLINE MTL::ArrayType* MTL::PointerType::elementArrayType() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(elementArrayType)); +} + +// static method: alloc +_MTL_INLINE MTL::TextureReferenceType* MTL::TextureReferenceType::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTextureReferenceType)); +} + +// method: init +_MTL_INLINE MTL::TextureReferenceType* MTL::TextureReferenceType::init() +{ + return NS::Object::init(); +} + +// property: textureDataType +_MTL_INLINE MTL::DataType MTL::TextureReferenceType::textureDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureDataType)); +} + +// property: textureType +_MTL_INLINE MTL::TextureType MTL::TextureReferenceType::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +// property: access +_MTL_INLINE MTL::ArgumentAccess MTL::TextureReferenceType::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +// property: isDepthTexture +_MTL_INLINE bool MTL::TextureReferenceType::isDepthTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthTexture)); +} + +// static method: alloc +_MTL_INLINE MTL::Argument* MTL::Argument::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArgument)); +} + +// method: init +_MTL_INLINE MTL::Argument* MTL::Argument::init() +{ + return NS::Object::init(); +} + +// property: name +_MTL_INLINE NS::String* MTL::Argument::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: type +_MTL_INLINE MTL::ArgumentType MTL::Argument::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +// property: access +_MTL_INLINE MTL::ArgumentAccess MTL::Argument::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +// property: index +_MTL_INLINE NS::UInteger MTL::Argument::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +// property: active +_MTL_INLINE bool MTL::Argument::active() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isActive)); +} + +// property: bufferAlignment +_MTL_INLINE NS::UInteger MTL::Argument::bufferAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferAlignment)); +} + +// property: bufferDataSize +_MTL_INLINE NS::UInteger MTL::Argument::bufferDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataSize)); +} + +// property: bufferDataType +_MTL_INLINE MTL::DataType MTL::Argument::bufferDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataType)); +} + +// property: bufferStructType +_MTL_INLINE MTL::StructType* MTL::Argument::bufferStructType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferStructType)); +} + +// property: bufferPointerType +_MTL_INLINE MTL::PointerType* MTL::Argument::bufferPointerType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferPointerType)); +} + +// property: threadgroupMemoryAlignment +_MTL_INLINE NS::UInteger MTL::Argument::threadgroupMemoryAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryAlignment)); +} + +// property: threadgroupMemoryDataSize +_MTL_INLINE NS::UInteger MTL::Argument::threadgroupMemoryDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryDataSize)); +} + +// property: textureType +_MTL_INLINE MTL::TextureType MTL::Argument::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +// property: textureDataType +_MTL_INLINE MTL::DataType MTL::Argument::textureDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureDataType)); +} + +// property: isDepthTexture +_MTL_INLINE bool MTL::Argument::isDepthTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthTexture)); +} + +// property: arrayLength +_MTL_INLINE NS::UInteger MTL::Argument::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +// property: name +_MTL_INLINE NS::String* MTL::Binding::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: type +_MTL_INLINE MTL::BindingType MTL::Binding::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +// property: access +_MTL_INLINE MTL::ArgumentAccess MTL::Binding::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +// property: index +_MTL_INLINE NS::UInteger MTL::Binding::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +// property: used +_MTL_INLINE bool MTL::Binding::used() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isUsed)); +} + +// property: argument +_MTL_INLINE bool MTL::Binding::argument() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isArgument)); +} + +// property: bufferAlignment +_MTL_INLINE NS::UInteger MTL::BufferBinding::bufferAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferAlignment)); +} + +// property: bufferDataSize +_MTL_INLINE NS::UInteger MTL::BufferBinding::bufferDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataSize)); +} + +// property: bufferDataType +_MTL_INLINE MTL::DataType MTL::BufferBinding::bufferDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferDataType)); +} + +// property: bufferStructType +_MTL_INLINE MTL::StructType* MTL::BufferBinding::bufferStructType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferStructType)); +} + +// property: bufferPointerType +_MTL_INLINE MTL::PointerType* MTL::BufferBinding::bufferPointerType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferPointerType)); +} + +// property: threadgroupMemoryAlignment +_MTL_INLINE NS::UInteger MTL::ThreadgroupBinding::threadgroupMemoryAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryAlignment)); +} + +// property: threadgroupMemoryDataSize +_MTL_INLINE NS::UInteger MTL::ThreadgroupBinding::threadgroupMemoryDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryDataSize)); +} + +// property: textureType +_MTL_INLINE MTL::TextureType MTL::TextureBinding::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +// property: textureDataType +_MTL_INLINE MTL::DataType MTL::TextureBinding::textureDataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureDataType)); +} + +// property: depthTexture +_MTL_INLINE bool MTL::TextureBinding::depthTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthTexture)); +} + +// property: arrayLength +_MTL_INLINE NS::UInteger MTL::TextureBinding::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +// property: objectPayloadAlignment +_MTL_INLINE NS::UInteger MTL::ObjectPayloadBinding::objectPayloadAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectPayloadAlignment)); +} + +// property: objectPayloadDataSize +_MTL_INLINE NS::UInteger MTL::ObjectPayloadBinding::objectPayloadDataSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectPayloadDataSize)); +} diff --git a/vendor/metal-cpp/Metal/MTLArgumentEncoder.hpp b/vendor/metal-cpp/Metal/MTLArgumentEncoder.hpp new file mode 100644 index 000000000..12ea5b6fb --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLArgumentEncoder.hpp @@ -0,0 +1,241 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLArgumentEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +class ArgumentEncoder : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); + + NS::UInteger encodedLength() const; + + NS::UInteger alignment() const; + + void setArgumentBuffer(const class Buffer* argumentBuffer, NS::UInteger offset); + + void setArgumentBuffer(const class Buffer* argumentBuffer, NS::UInteger startOffset, NS::UInteger arrayElement); + + void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setTexture(const class Texture* texture, NS::UInteger index); + + void setTextures(const class Texture* const textures[], NS::Range range); + + void setSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void* constantData(NS::UInteger index); + + void setRenderPipelineState(const class RenderPipelineState* pipeline, NS::UInteger index); + + void setRenderPipelineStates(const class RenderPipelineState* const pipelines[], NS::Range range); + + void setComputePipelineState(const class ComputePipelineState* pipeline, NS::UInteger index); + + void setComputePipelineStates(const class ComputePipelineState* const pipelines[], NS::Range range); + + void setIndirectCommandBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::UInteger index); + + void setIndirectCommandBuffers(const class IndirectCommandBuffer* const buffers[], NS::Range range); + + void setAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger index); + + class ArgumentEncoder* newArgumentEncoder(NS::UInteger index); + + void setVisibleFunctionTable(const class VisibleFunctionTable* visibleFunctionTable, NS::UInteger index); + + void setVisibleFunctionTables(const class VisibleFunctionTable* const visibleFunctionTables[], NS::Range range); + + void setIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger index); + + void setIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); +}; + +} + +// property: device +_MTL_INLINE MTL::Device* MTL::ArgumentEncoder::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: label +_MTL_INLINE NS::String* MTL::ArgumentEncoder::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::ArgumentEncoder::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: encodedLength +_MTL_INLINE NS::UInteger MTL::ArgumentEncoder::encodedLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(encodedLength)); +} + +// property: alignment +_MTL_INLINE NS::UInteger MTL::ArgumentEncoder::alignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(alignment)); +} + +// method: setArgumentBuffer:offset: +_MTL_INLINE void MTL::ArgumentEncoder::setArgumentBuffer(const MTL::Buffer* argumentBuffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArgumentBuffer_offset_), argumentBuffer, offset); +} + +// method: setArgumentBuffer:startOffset:arrayElement: +_MTL_INLINE void MTL::ArgumentEncoder::setArgumentBuffer(const MTL::Buffer* argumentBuffer, NS::UInteger startOffset, NS::UInteger arrayElement) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArgumentBuffer_startOffset_arrayElement_), argumentBuffer, startOffset, arrayElement); +} + +// method: setBuffer:offset:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setBuffers:offsets:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_withRange_), buffers, offsets, range); +} + +// method: setTexture:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTexture_atIndex_), texture, index); +} + +// method: setTextures:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextures_withRange_), textures, range); +} + +// method: setSamplerState:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerState_atIndex_), sampler, index); +} + +// method: setSamplerStates:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerStates_withRange_), samplers, range); +} + +// method: constantDataAtIndex: +_MTL_INLINE void* MTL::ArgumentEncoder::constantData(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(constantDataAtIndex_), index); +} + +// method: setRenderPipelineState:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setRenderPipelineState(const MTL::RenderPipelineState* pipeline, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineState_atIndex_), pipeline, index); +} + +// method: setRenderPipelineStates:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setRenderPipelineStates(const MTL::RenderPipelineState* const pipelines[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineStates_withRange_), pipelines, range); +} + +// method: setComputePipelineState:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setComputePipelineState(const MTL::ComputePipelineState* pipeline, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineState_atIndex_), pipeline, index); +} + +// method: setComputePipelineStates:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setComputePipelineStates(const MTL::ComputePipelineState* const pipelines[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineStates_withRange_), pipelines, range); +} + +// method: setIndirectCommandBuffer:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setIndirectCommandBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndirectCommandBuffer_atIndex_), indirectCommandBuffer, index); +} + +// method: setIndirectCommandBuffers:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setIndirectCommandBuffers(const MTL::IndirectCommandBuffer* const buffers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndirectCommandBuffers_withRange_), buffers, range); +} + +// method: setAccelerationStructure:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAccelerationStructure_atIndex_), accelerationStructure, index); +} + +// method: newArgumentEncoderForBufferAtIndex: +_MTL_INLINE MTL::ArgumentEncoder* MTL::ArgumentEncoder::newArgumentEncoder(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderForBufferAtIndex_), index); +} + +// method: setVisibleFunctionTable:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setVisibleFunctionTable(const MTL::VisibleFunctionTable* visibleFunctionTable, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTable_atIndex_), visibleFunctionTable, index); +} + +// method: setVisibleFunctionTables:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setVisibleFunctionTables(const MTL::VisibleFunctionTable* const visibleFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTables_withRange_), visibleFunctionTables, range); +} + +// method: setIntersectionFunctionTable:atIndex: +_MTL_INLINE void MTL::ArgumentEncoder::setIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTable_atIndex_), intersectionFunctionTable, index); +} + +// method: setIntersectionFunctionTables:withRange: +_MTL_INLINE void MTL::ArgumentEncoder::setIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTables_withRange_), intersectionFunctionTables, range); +} diff --git a/vendor/metal-cpp/Metal/MTLBinaryArchive.hpp b/vendor/metal-cpp/Metal/MTLBinaryArchive.hpp new file mode 100644 index 000000000..1c77c0781 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLBinaryArchive.hpp @@ -0,0 +1,139 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLBinaryArchive.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, BinaryArchiveError) { + BinaryArchiveErrorNone = 0, + BinaryArchiveErrorInvalidFile = 1, + BinaryArchiveErrorUnexpectedElement = 2, + BinaryArchiveErrorCompilationFailure = 3, + BinaryArchiveErrorInternalError = 4, +}; + +class BinaryArchiveDescriptor : public NS::Copying +{ +public: + static class BinaryArchiveDescriptor* alloc(); + + class BinaryArchiveDescriptor* init(); + + NS::URL* url() const; + void setUrl(const NS::URL* url); +}; + +class BinaryArchive : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + bool addComputePipelineFunctions(const class ComputePipelineDescriptor* descriptor, NS::Error** error); + + bool addRenderPipelineFunctions(const class RenderPipelineDescriptor* descriptor, NS::Error** error); + + bool addTileRenderPipelineFunctions(const class TileRenderPipelineDescriptor* descriptor, NS::Error** error); + + bool serializeToURL(const NS::URL* url, NS::Error** error); + + bool addFunction(const class FunctionDescriptor* descriptor, const class Library* library, NS::Error** error); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBinaryArchiveDescriptor)); +} + +// method: init +_MTL_INLINE MTL::BinaryArchiveDescriptor* MTL::BinaryArchiveDescriptor::init() +{ + return NS::Object::init(); +} + +// property: url +_MTL_INLINE NS::URL* MTL::BinaryArchiveDescriptor::url() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(url)); +} + +_MTL_INLINE void MTL::BinaryArchiveDescriptor::setUrl(const NS::URL* url) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setUrl_), url); +} + +// property: label +_MTL_INLINE NS::String* MTL::BinaryArchive::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::BinaryArchive::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::BinaryArchive::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// method: addComputePipelineFunctionsWithDescriptor:error: +_MTL_INLINE bool MTL::BinaryArchive::addComputePipelineFunctions(const MTL::ComputePipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addComputePipelineFunctionsWithDescriptor_error_), descriptor, error); +} + +// method: addRenderPipelineFunctionsWithDescriptor:error: +_MTL_INLINE bool MTL::BinaryArchive::addRenderPipelineFunctions(const MTL::RenderPipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addRenderPipelineFunctionsWithDescriptor_error_), descriptor, error); +} + +// method: addTileRenderPipelineFunctionsWithDescriptor:error: +_MTL_INLINE bool MTL::BinaryArchive::addTileRenderPipelineFunctions(const MTL::TileRenderPipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addTileRenderPipelineFunctionsWithDescriptor_error_), descriptor, error); +} + +// method: serializeToURL:error: +_MTL_INLINE bool MTL::BinaryArchive::serializeToURL(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(serializeToURL_error_), url, error); +} + +// method: addFunctionWithDescriptor:library:error: +_MTL_INLINE bool MTL::BinaryArchive::addFunction(const MTL::FunctionDescriptor* descriptor, const MTL::Library* library, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(addFunctionWithDescriptor_library_error_), descriptor, library, error); +} diff --git a/vendor/metal-cpp/Metal/MTLBlitCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLBlitCommandEncoder.hpp new file mode 100644 index 000000000..8d4845a82 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLBlitCommandEncoder.hpp @@ -0,0 +1,246 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLBlitCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLBlitCommandEncoder.hpp" +#include "MTLCommandEncoder.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, BlitOption) { + BlitOptionNone = 0, + BlitOptionDepthFromDepthStencil = 1, + BlitOptionStencilFromDepthStencil = 2, + BlitOptionRowLinearPVRTC = 4, +}; + +class BlitCommandEncoder : public NS::Referencing +{ +public: + void synchronizeResource(const class Resource* resource); + + void synchronizeTexture(const class Texture* texture, NS::UInteger slice, NS::UInteger level); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin); + + void copyFromBuffer(const class Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin); + + void copyFromBuffer(const class Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin, MTL::BlitOption options); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage, MTL::BlitOption options); + + void generateMipmaps(const class Texture* texture); + + void fillBuffer(const class Buffer* buffer, NS::Range range, uint8_t value); + + void copyFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, NS::UInteger sliceCount, NS::UInteger levelCount); + + void copyFromTexture(const class Texture* sourceTexture, const class Texture* destinationTexture); + + void copyFromBuffer(const class Buffer* sourceBuffer, NS::UInteger sourceOffset, const class Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger size); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void getTextureAccessCounters(const class Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice, bool resetCounters, const class Buffer* countersBuffer, NS::UInteger countersBufferOffset); + + void resetTextureAccessCounters(const class Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice); + + void optimizeContentsForGPUAccess(const class Texture* texture); + + void optimizeContentsForGPUAccess(const class Texture* texture, NS::UInteger slice, NS::UInteger level); + + void optimizeContentsForCPUAccess(const class Texture* texture); + + void optimizeContentsForCPUAccess(const class Texture* texture, NS::UInteger slice, NS::UInteger level); + + void resetCommandsInBuffer(const class IndirectCommandBuffer* buffer, NS::Range range); + + void copyIndirectCommandBuffer(const class IndirectCommandBuffer* source, NS::Range sourceRange, const class IndirectCommandBuffer* destination, NS::UInteger destinationIndex); + + void optimizeIndirectCommandBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::Range range); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); + + void resolveCounters(const class CounterSampleBuffer* sampleBuffer, NS::Range range, const class Buffer* destinationBuffer, NS::UInteger destinationOffset); +}; + +} + +// method: synchronizeResource: +_MTL_INLINE void MTL::BlitCommandEncoder::synchronizeResource(const MTL::Resource* resource) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(synchronizeResource_), resource); +} + +// method: synchronizeTexture:slice:level: +_MTL_INLINE void MTL::BlitCommandEncoder::synchronizeTexture(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(synchronizeTexture_slice_level_), texture, slice, level); +} + +// method: copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin); +} + +// method: copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromBuffer(const MTL::Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceBuffer, sourceOffset, sourceBytesPerRow, sourceBytesPerImage, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin); +} + +// method: copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromBuffer(const MTL::Buffer* sourceBuffer, NS::UInteger sourceOffset, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin, MTL::BlitOption options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options_), sourceBuffer, sourceOffset, sourceBytesPerRow, sourceBytesPerImage, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin, options); +} + +// method: copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationBuffer, destinationOffset, destinationBytesPerRow, destinationBytesPerImage); +} + +// method: copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger destinationBytesPerRow, NS::UInteger destinationBytesPerImage, MTL::BlitOption options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationBuffer, destinationOffset, destinationBytesPerRow, destinationBytesPerImage, options); +} + +// method: generateMipmapsForTexture: +_MTL_INLINE void MTL::BlitCommandEncoder::generateMipmaps(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(generateMipmapsForTexture_), texture); +} + +// method: fillBuffer:range:value: +_MTL_INLINE void MTL::BlitCommandEncoder::fillBuffer(const MTL::Buffer* buffer, NS::Range range, uint8_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(fillBuffer_range_value_), buffer, range, value); +} + +// method: copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, NS::UInteger sliceCount, NS::UInteger levelCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount_), sourceTexture, sourceSlice, sourceLevel, destinationTexture, destinationSlice, destinationLevel, sliceCount, levelCount); +} + +// method: copyFromTexture:toTexture: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromTexture(const MTL::Texture* sourceTexture, const MTL::Texture* destinationTexture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromTexture_toTexture_), sourceTexture, destinationTexture); +} + +// method: copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size: +_MTL_INLINE void MTL::BlitCommandEncoder::copyFromBuffer(const MTL::Buffer* sourceBuffer, NS::UInteger sourceOffset, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset, NS::UInteger size) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size_), sourceBuffer, sourceOffset, destinationBuffer, destinationOffset, size); +} + +// method: updateFence: +_MTL_INLINE void MTL::BlitCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +// method: waitForFence: +_MTL_INLINE void MTL::BlitCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +// method: getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset: +_MTL_INLINE void MTL::BlitCommandEncoder::getTextureAccessCounters(const MTL::Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice, bool resetCounters, const MTL::Buffer* countersBuffer, NS::UInteger countersBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getTextureAccessCounters_region_mipLevel_slice_resetCounters_countersBuffer_countersBufferOffset_), texture, region, mipLevel, slice, resetCounters, countersBuffer, countersBufferOffset); +} + +// method: resetTextureAccessCounters:region:mipLevel:slice: +_MTL_INLINE void MTL::BlitCommandEncoder::resetTextureAccessCounters(const MTL::Texture* texture, MTL::Region region, NS::UInteger mipLevel, NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resetTextureAccessCounters_region_mipLevel_slice_), texture, region, mipLevel, slice); +} + +// method: optimizeContentsForGPUAccess: +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForGPUAccess(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForGPUAccess_), texture); +} + +// method: optimizeContentsForGPUAccess:slice:level: +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForGPUAccess(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForGPUAccess_slice_level_), texture, slice, level); +} + +// method: optimizeContentsForCPUAccess: +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForCPUAccess(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForCPUAccess_), texture); +} + +// method: optimizeContentsForCPUAccess:slice:level: +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeContentsForCPUAccess(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeContentsForCPUAccess_slice_level_), texture, slice, level); +} + +// method: resetCommandsInBuffer:withRange: +_MTL_INLINE void MTL::BlitCommandEncoder::resetCommandsInBuffer(const MTL::IndirectCommandBuffer* buffer, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resetCommandsInBuffer_withRange_), buffer, range); +} + +// method: copyIndirectCommandBuffer:sourceRange:destination:destinationIndex: +_MTL_INLINE void MTL::BlitCommandEncoder::copyIndirectCommandBuffer(const MTL::IndirectCommandBuffer* source, NS::Range sourceRange, const MTL::IndirectCommandBuffer* destination, NS::UInteger destinationIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyIndirectCommandBuffer_sourceRange_destination_destinationIndex_), source, sourceRange, destination, destinationIndex); +} + +// method: optimizeIndirectCommandBuffer:withRange: +_MTL_INLINE void MTL::BlitCommandEncoder::optimizeIndirectCommandBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizeIndirectCommandBuffer_withRange_), indirectCommandBuffer, range); +} + +// method: sampleCountersInBuffer:atSampleIndex:withBarrier: +_MTL_INLINE void MTL::BlitCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} + +// method: resolveCounters:inRange:destinationBuffer:destinationOffset: +_MTL_INLINE void MTL::BlitCommandEncoder::resolveCounters(const MTL::CounterSampleBuffer* sampleBuffer, NS::Range range, const MTL::Buffer* destinationBuffer, NS::UInteger destinationOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveCounters_inRange_destinationBuffer_destinationOffset_), sampleBuffer, range, destinationBuffer, destinationOffset); +} diff --git a/vendor/metal-cpp/Metal/MTLBlitPass.hpp b/vendor/metal-cpp/Metal/MTLBlitPass.hpp new file mode 100644 index 000000000..849875259 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLBlitPass.hpp @@ -0,0 +1,165 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLBlitPass.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +class BlitPassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class BlitPassSampleBufferAttachmentDescriptor* alloc(); + + class BlitPassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class BlitPassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class BlitPassSampleBufferAttachmentDescriptorArray* alloc(); + + class BlitPassSampleBufferAttachmentDescriptorArray* init(); + + class BlitPassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class BlitPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class BlitPassDescriptor : public NS::Copying +{ +public: + static class BlitPassDescriptor* alloc(); + + class BlitPassDescriptor* init(); + + static class BlitPassDescriptor* blitPassDescriptor(); + + class BlitPassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptor* MTL::BlitPassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBlitPassSampleBufferAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptor* MTL::BlitPassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: sampleBuffer +_MTL_INLINE MTL::CounterSampleBuffer* MTL::BlitPassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +// property: startOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::BlitPassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +// property: endOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::BlitPassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +// static method: alloc +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptorArray* MTL::BlitPassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBlitPassSampleBufferAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptorArray* MTL::BlitPassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptor* MTL::BlitPassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::BlitPassSampleBufferAttachmentDescriptorArray::setObject(const MTL::BlitPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::BlitPassDescriptor* MTL::BlitPassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBlitPassDescriptor)); +} + +// method: init +_MTL_INLINE MTL::BlitPassDescriptor* MTL::BlitPassDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: blitPassDescriptor +_MTL_INLINE MTL::BlitPassDescriptor* MTL::BlitPassDescriptor::blitPassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLBlitPassDescriptor), _MTL_PRIVATE_SEL(blitPassDescriptor)); +} + +// property: sampleBufferAttachments +_MTL_INLINE MTL::BlitPassSampleBufferAttachmentDescriptorArray* MTL::BlitPassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} diff --git a/vendor/metal-cpp/Metal/MTLBuffer.hpp b/vendor/metal-cpp/Metal/MTLBuffer.hpp new file mode 100644 index 000000000..684ee8e24 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLBuffer.hpp @@ -0,0 +1,109 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLBuffer.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLResource.hpp" + +namespace MTL +{ +class Buffer : public NS::Referencing +{ +public: + NS::UInteger length() const; + + void* contents(); + + void didModifyRange(NS::Range range); + + class Texture* newTexture(const class TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow); + + void addDebugMarker(const NS::String* marker, NS::Range range); + + void removeAllDebugMarkers(); + + class Buffer* remoteStorageBuffer() const; + + class Buffer* newRemoteBufferViewForDevice(const class Device* device); + + uint64_t gpuAddress() const; +}; + +} + +// property: length +_MTL_INLINE NS::UInteger MTL::Buffer::length() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(length)); +} + +// method: contents +_MTL_INLINE void* MTL::Buffer::contents() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(contents)); +} + +// method: didModifyRange: +_MTL_INLINE void MTL::Buffer::didModifyRange(NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(didModifyRange_), range); +} + +// method: newTextureWithDescriptor:offset:bytesPerRow: +_MTL_INLINE MTL::Texture* MTL::Buffer::newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset, NS::UInteger bytesPerRow) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_offset_bytesPerRow_), descriptor, offset, bytesPerRow); +} + +// method: addDebugMarker:range: +_MTL_INLINE void MTL::Buffer::addDebugMarker(const NS::String* marker, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addDebugMarker_range_), marker, range); +} + +// method: removeAllDebugMarkers +_MTL_INLINE void MTL::Buffer::removeAllDebugMarkers() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(removeAllDebugMarkers)); +} + +// property: remoteStorageBuffer +_MTL_INLINE MTL::Buffer* MTL::Buffer::remoteStorageBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(remoteStorageBuffer)); +} + +// method: newRemoteBufferViewForDevice: +_MTL_INLINE MTL::Buffer* MTL::Buffer::newRemoteBufferViewForDevice(const MTL::Device* device) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRemoteBufferViewForDevice_), device); +} + +// property: gpuAddress +_MTL_INLINE uint64_t MTL::Buffer::gpuAddress() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuAddress)); +} diff --git a/vendor/metal-cpp/Metal/MTLCaptureManager.hpp b/vendor/metal-cpp/Metal/MTLCaptureManager.hpp new file mode 100644 index 000000000..ebe7ddd2a --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLCaptureManager.hpp @@ -0,0 +1,220 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLCaptureManager.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLCaptureManager.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::Integer, CaptureError) { + CaptureErrorNotSupported = 1, + CaptureErrorAlreadyCapturing = 2, + CaptureErrorInvalidDescriptor = 3, +}; + +_MTL_ENUM(NS::Integer, CaptureDestination) { + CaptureDestinationDeveloperTools = 1, + CaptureDestinationGPUTraceDocument = 2, +}; + +class CaptureDescriptor : public NS::Copying +{ +public: + static class CaptureDescriptor* alloc(); + + class CaptureDescriptor* init(); + + id captureObject() const; + void setCaptureObject(id captureObject); + + MTL::CaptureDestination destination() const; + void setDestination(MTL::CaptureDestination destination); + + NS::URL* outputURL() const; + void setOutputURL(const NS::URL* outputURL); +}; + +class CaptureManager : public NS::Referencing +{ +public: + static class CaptureManager* alloc(); + + static class CaptureManager* sharedCaptureManager(); + + MTL::CaptureManager* init(); + + class CaptureScope* newCaptureScope(const class Device* device); + + class CaptureScope* newCaptureScope(const class CommandQueue* commandQueue); + + bool supportsDestination(MTL::CaptureDestination destination); + + bool startCapture(const class CaptureDescriptor* descriptor, NS::Error** error); + + void startCapture(const class Device* device); + + void startCapture(const class CommandQueue* commandQueue); + + void startCapture(const class CaptureScope* captureScope); + + void stopCapture(); + + class CaptureScope* defaultCaptureScope() const; + void setDefaultCaptureScope(const class CaptureScope* defaultCaptureScope); + + bool isCapturing() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCaptureDescriptor)); +} + +// method: init +_MTL_INLINE MTL::CaptureDescriptor* MTL::CaptureDescriptor::init() +{ + return NS::Object::init(); +} + +// property: captureObject +_MTL_INLINE id MTL::CaptureDescriptor::captureObject() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(captureObject)); +} + +_MTL_INLINE void MTL::CaptureDescriptor::setCaptureObject(id captureObject) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCaptureObject_), captureObject); +} + +// property: destination +_MTL_INLINE MTL::CaptureDestination MTL::CaptureDescriptor::destination() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(destination)); +} + +_MTL_INLINE void MTL::CaptureDescriptor::setDestination(MTL::CaptureDestination destination) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDestination_), destination); +} + +// property: outputURL +_MTL_INLINE NS::URL* MTL::CaptureDescriptor::outputURL() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(outputURL)); +} + +_MTL_INLINE void MTL::CaptureDescriptor::setOutputURL(const NS::URL* outputURL) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOutputURL_), outputURL); +} + +// static method: alloc +_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCaptureManager)); +} + +// static method: sharedCaptureManager +_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::sharedCaptureManager() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLCaptureManager), _MTL_PRIVATE_SEL(sharedCaptureManager)); +} + +// method: init +_MTL_INLINE MTL::CaptureManager* MTL::CaptureManager::init() +{ + return NS::Object::init(); +} + +// method: newCaptureScopeWithDevice: +_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::Device* device) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCaptureScopeWithDevice_), device); +} + +// method: newCaptureScopeWithCommandQueue: +_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::newCaptureScope(const MTL::CommandQueue* commandQueue) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCaptureScopeWithCommandQueue_), commandQueue); +} + +// method: supportsDestination: +_MTL_INLINE bool MTL::CaptureManager::supportsDestination(MTL::CaptureDestination destination) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsDestination_), destination); +} + +// method: startCaptureWithDescriptor:error: +_MTL_INLINE bool MTL::CaptureManager::startCapture(const MTL::CaptureDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithDescriptor_error_), descriptor, error); +} + +// method: startCaptureWithDevice: +_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::Device* device) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithDevice_), device); +} + +// method: startCaptureWithCommandQueue: +_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CommandQueue* commandQueue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithCommandQueue_), commandQueue); +} + +// method: startCaptureWithScope: +_MTL_INLINE void MTL::CaptureManager::startCapture(const MTL::CaptureScope* captureScope) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(startCaptureWithScope_), captureScope); +} + +// method: stopCapture +_MTL_INLINE void MTL::CaptureManager::stopCapture() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(stopCapture)); +} + +// property: defaultCaptureScope +_MTL_INLINE MTL::CaptureScope* MTL::CaptureManager::defaultCaptureScope() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(defaultCaptureScope)); +} + +_MTL_INLINE void MTL::CaptureManager::setDefaultCaptureScope(const MTL::CaptureScope* defaultCaptureScope) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDefaultCaptureScope_), defaultCaptureScope); +} + +// property: isCapturing +_MTL_INLINE bool MTL::CaptureManager::isCapturing() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isCapturing)); +} diff --git a/vendor/metal-cpp/Metal/MTLCaptureScope.hpp b/vendor/metal-cpp/Metal/MTLCaptureScope.hpp new file mode 100644 index 000000000..6d5d1d6fd --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLCaptureScope.hpp @@ -0,0 +1,92 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLCaptureScope.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "MTLDefines.hpp" +#include "MTLPrivate.hpp" + +#include "../Foundation/NSObject.hpp" +#include "../Foundation/NSString.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace MTL +{ +class CaptureScope : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* pLabel); + + class CommandQueue* commandQueue() const; + + void beginScope(); + void endScope(); +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::Device* MTL::CaptureScope::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE NS::String* MTL::CaptureScope::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE void MTL::CaptureScope::setLabel(const NS::String* pLabel) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), pLabel); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE MTL::CommandQueue* MTL::CaptureScope::commandQueue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandQueue)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE void MTL::CaptureScope::beginScope() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(beginScope)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_MTL_INLINE void MTL::CaptureScope::endScope() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endScope)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Metal/MTLCommandBuffer.hpp b/vendor/metal-cpp/Metal/MTLCommandBuffer.hpp new file mode 100644 index 000000000..f8e2bfb68 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLCommandBuffer.hpp @@ -0,0 +1,474 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLCommandBuffer.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLCommandBuffer.hpp" +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, CommandBufferStatus) { + CommandBufferStatusNotEnqueued = 0, + CommandBufferStatusEnqueued = 1, + CommandBufferStatusCommitted = 2, + CommandBufferStatusScheduled = 3, + CommandBufferStatusCompleted = 4, + CommandBufferStatusError = 5, +}; + +_MTL_ENUM(NS::UInteger, CommandBufferError) { + CommandBufferErrorNone = 0, + CommandBufferErrorInternal = 1, + CommandBufferErrorTimeout = 2, + CommandBufferErrorPageFault = 3, + CommandBufferErrorAccessRevoked = 4, + CommandBufferErrorBlacklisted = 4, + CommandBufferErrorNotPermitted = 7, + CommandBufferErrorOutOfMemory = 8, + CommandBufferErrorInvalidResource = 9, + CommandBufferErrorMemoryless = 10, + CommandBufferErrorDeviceRemoved = 11, + CommandBufferErrorStackOverflow = 12, +}; + +_MTL_OPTIONS(NS::UInteger, CommandBufferErrorOption) { + CommandBufferErrorOptionNone = 0, + CommandBufferErrorOptionEncoderExecutionStatus = 1, +}; + +_MTL_ENUM(NS::Integer, CommandEncoderErrorState) { + CommandEncoderErrorStateUnknown = 0, + CommandEncoderErrorStateCompleted = 1, + CommandEncoderErrorStateAffected = 2, + CommandEncoderErrorStatePending = 3, + CommandEncoderErrorStateFaulted = 4, +}; + +class CommandBufferDescriptor : public NS::Copying +{ +public: + static class CommandBufferDescriptor* alloc(); + + class CommandBufferDescriptor* init(); + + bool retainedReferences() const; + void setRetainedReferences(bool retainedReferences); + + MTL::CommandBufferErrorOption errorOptions() const; + void setErrorOptions(MTL::CommandBufferErrorOption errorOptions); +}; + +class CommandBufferEncoderInfo : public NS::Referencing +{ +public: + NS::String* label() const; + + NS::Array* debugSignposts() const; + + MTL::CommandEncoderErrorState errorState() const; +}; + +_MTL_ENUM(NS::UInteger, DispatchType) { + DispatchTypeSerial = 0, + DispatchTypeConcurrent = 1, +}; + +class CommandBuffer; + +using CommandBufferHandler = void (^)(CommandBuffer*); + +using HandlerFunction = std::function; + +class CommandBuffer : public NS::Referencing +{ +public: + void addScheduledHandler(const HandlerFunction& function); + + void addCompletedHandler(const HandlerFunction& function); + + class Device* device() const; + + class CommandQueue* commandQueue() const; + + bool retainedReferences() const; + + MTL::CommandBufferErrorOption errorOptions() const; + + NS::String* label() const; + void setLabel(const NS::String* label); + + CFTimeInterval kernelStartTime() const; + + CFTimeInterval kernelEndTime() const; + + class LogContainer* logs() const; + + CFTimeInterval GPUStartTime() const; + + CFTimeInterval GPUEndTime() const; + + void enqueue(); + + void commit(); + + void addScheduledHandler(const MTL::CommandBufferHandler block); + + void presentDrawable(const class Drawable* drawable); + + void presentDrawableAtTime(const class Drawable* drawable, CFTimeInterval presentationTime); + + void presentDrawableAfterMinimumDuration(const class Drawable* drawable, CFTimeInterval duration); + + void waitUntilScheduled(); + + void addCompletedHandler(const MTL::CommandBufferHandler block); + + void waitUntilCompleted(); + + MTL::CommandBufferStatus status() const; + + NS::Error* error() const; + + class BlitCommandEncoder* blitCommandEncoder(); + + class RenderCommandEncoder* renderCommandEncoder(const class RenderPassDescriptor* renderPassDescriptor); + + class ComputeCommandEncoder* computeCommandEncoder(const class ComputePassDescriptor* computePassDescriptor); + + class BlitCommandEncoder* blitCommandEncoder(const class BlitPassDescriptor* blitPassDescriptor); + + class ComputeCommandEncoder* computeCommandEncoder(); + + class ComputeCommandEncoder* computeCommandEncoder(MTL::DispatchType dispatchType); + + void encodeWait(const class Event* event, uint64_t value); + + void encodeSignalEvent(const class Event* event, uint64_t value); + + class ParallelRenderCommandEncoder* parallelRenderCommandEncoder(const class RenderPassDescriptor* renderPassDescriptor); + + class ResourceStateCommandEncoder* resourceStateCommandEncoder(); + + class ResourceStateCommandEncoder* resourceStateCommandEncoder(const class ResourceStatePassDescriptor* resourceStatePassDescriptor); + + class AccelerationStructureCommandEncoder* accelerationStructureCommandEncoder(); + + class AccelerationStructureCommandEncoder* accelerationStructureCommandEncoder(const class AccelerationStructurePassDescriptor* descriptor); + + void pushDebugGroup(const NS::String* string); + + void popDebugGroup(); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::CommandBufferDescriptor* MTL::CommandBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCommandBufferDescriptor)); +} + +// method: init +_MTL_INLINE MTL::CommandBufferDescriptor* MTL::CommandBufferDescriptor::init() +{ + return NS::Object::init(); +} + +// property: retainedReferences +_MTL_INLINE bool MTL::CommandBufferDescriptor::retainedReferences() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(retainedReferences)); +} + +_MTL_INLINE void MTL::CommandBufferDescriptor::setRetainedReferences(bool retainedReferences) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRetainedReferences_), retainedReferences); +} + +// property: errorOptions +_MTL_INLINE MTL::CommandBufferErrorOption MTL::CommandBufferDescriptor::errorOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(errorOptions)); +} + +_MTL_INLINE void MTL::CommandBufferDescriptor::setErrorOptions(MTL::CommandBufferErrorOption errorOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setErrorOptions_), errorOptions); +} + +// property: label +_MTL_INLINE NS::String* MTL::CommandBufferEncoderInfo::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// property: debugSignposts +_MTL_INLINE NS::Array* MTL::CommandBufferEncoderInfo::debugSignposts() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(debugSignposts)); +} + +// property: errorState +_MTL_INLINE MTL::CommandEncoderErrorState MTL::CommandBufferEncoderInfo::errorState() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(errorState)); +} + +_MTL_INLINE void MTL::CommandBuffer::addScheduledHandler(const HandlerFunction& function) +{ + __block HandlerFunction blockFunction = function; + + addScheduledHandler(^(MTL::CommandBuffer* pCommandBuffer) { blockFunction(pCommandBuffer); }); +} + +_MTL_INLINE void MTL::CommandBuffer::addCompletedHandler(const HandlerFunction& function) +{ + __block HandlerFunction blockFunction = function; + + addCompletedHandler(^(MTL::CommandBuffer* pCommandBuffer) { blockFunction(pCommandBuffer); }); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::CommandBuffer::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: commandQueue +_MTL_INLINE MTL::CommandQueue* MTL::CommandBuffer::commandQueue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandQueue)); +} + +// property: retainedReferences +_MTL_INLINE bool MTL::CommandBuffer::retainedReferences() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(retainedReferences)); +} + +// property: errorOptions +_MTL_INLINE MTL::CommandBufferErrorOption MTL::CommandBuffer::errorOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(errorOptions)); +} + +// property: label +_MTL_INLINE NS::String* MTL::CommandBuffer::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CommandBuffer::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: kernelStartTime +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::kernelStartTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(kernelStartTime)); +} + +// property: kernelEndTime +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::kernelEndTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(kernelEndTime)); +} + +// property: logs +_MTL_INLINE MTL::LogContainer* MTL::CommandBuffer::logs() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(logs)); +} + +// property: GPUStartTime +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::GPUStartTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(GPUStartTime)); +} + +// property: GPUEndTime +_MTL_INLINE CFTimeInterval MTL::CommandBuffer::GPUEndTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(GPUEndTime)); +} + +// method: enqueue +_MTL_INLINE void MTL::CommandBuffer::enqueue() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(enqueue)); +} + +// method: commit +_MTL_INLINE void MTL::CommandBuffer::commit() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(commit)); +} + +// method: addScheduledHandler: +_MTL_INLINE void MTL::CommandBuffer::addScheduledHandler(const MTL::CommandBufferHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addScheduledHandler_), block); +} + +// method: presentDrawable: +_MTL_INLINE void MTL::CommandBuffer::presentDrawable(const MTL::Drawable* drawable) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentDrawable_), drawable); +} + +// method: presentDrawable:atTime: +_MTL_INLINE void MTL::CommandBuffer::presentDrawableAtTime(const MTL::Drawable* drawable, CFTimeInterval presentationTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentDrawable_atTime_), drawable, presentationTime); +} + +// method: presentDrawable:afterMinimumDuration: +_MTL_INLINE void MTL::CommandBuffer::presentDrawableAfterMinimumDuration(const MTL::Drawable* drawable, CFTimeInterval duration) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentDrawable_afterMinimumDuration_), drawable, duration); +} + +// method: waitUntilScheduled +_MTL_INLINE void MTL::CommandBuffer::waitUntilScheduled() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitUntilScheduled)); +} + +// method: addCompletedHandler: +_MTL_INLINE void MTL::CommandBuffer::addCompletedHandler(const MTL::CommandBufferHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addCompletedHandler_), block); +} + +// method: waitUntilCompleted +_MTL_INLINE void MTL::CommandBuffer::waitUntilCompleted() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitUntilCompleted)); +} + +// property: status +_MTL_INLINE MTL::CommandBufferStatus MTL::CommandBuffer::status() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(status)); +} + +// property: error +_MTL_INLINE NS::Error* MTL::CommandBuffer::error() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(error)); +} + +// method: blitCommandEncoder +_MTL_INLINE MTL::BlitCommandEncoder* MTL::CommandBuffer::blitCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(blitCommandEncoder)); +} + +// method: renderCommandEncoderWithDescriptor: +_MTL_INLINE MTL::RenderCommandEncoder* MTL::CommandBuffer::renderCommandEncoder(const MTL::RenderPassDescriptor* renderPassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderCommandEncoderWithDescriptor_), renderPassDescriptor); +} + +// method: computeCommandEncoderWithDescriptor: +_MTL_INLINE MTL::ComputeCommandEncoder* MTL::CommandBuffer::computeCommandEncoder(const MTL::ComputePassDescriptor* computePassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeCommandEncoderWithDescriptor_), computePassDescriptor); +} + +// method: blitCommandEncoderWithDescriptor: +_MTL_INLINE MTL::BlitCommandEncoder* MTL::CommandBuffer::blitCommandEncoder(const MTL::BlitPassDescriptor* blitPassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(blitCommandEncoderWithDescriptor_), blitPassDescriptor); +} + +// method: computeCommandEncoder +_MTL_INLINE MTL::ComputeCommandEncoder* MTL::CommandBuffer::computeCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeCommandEncoder)); +} + +// method: computeCommandEncoderWithDispatchType: +_MTL_INLINE MTL::ComputeCommandEncoder* MTL::CommandBuffer::computeCommandEncoder(MTL::DispatchType dispatchType) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeCommandEncoderWithDispatchType_), dispatchType); +} + +// method: encodeWaitForEvent:value: +_MTL_INLINE void MTL::CommandBuffer::encodeWait(const MTL::Event* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(encodeWaitForEvent_value_), event, value); +} + +// method: encodeSignalEvent:value: +_MTL_INLINE void MTL::CommandBuffer::encodeSignalEvent(const MTL::Event* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(encodeSignalEvent_value_), event, value); +} + +// method: parallelRenderCommandEncoderWithDescriptor: +_MTL_INLINE MTL::ParallelRenderCommandEncoder* MTL::CommandBuffer::parallelRenderCommandEncoder(const MTL::RenderPassDescriptor* renderPassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parallelRenderCommandEncoderWithDescriptor_), renderPassDescriptor); +} + +// method: resourceStateCommandEncoder +_MTL_INLINE MTL::ResourceStateCommandEncoder* MTL::CommandBuffer::resourceStateCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceStateCommandEncoder)); +} + +// method: resourceStateCommandEncoderWithDescriptor: +_MTL_INLINE MTL::ResourceStateCommandEncoder* MTL::CommandBuffer::resourceStateCommandEncoder(const MTL::ResourceStatePassDescriptor* resourceStatePassDescriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceStateCommandEncoderWithDescriptor_), resourceStatePassDescriptor); +} + +// method: accelerationStructureCommandEncoder +_MTL_INLINE MTL::AccelerationStructureCommandEncoder* MTL::CommandBuffer::accelerationStructureCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(accelerationStructureCommandEncoder)); +} + +// method: accelerationStructureCommandEncoderWithDescriptor: +_MTL_INLINE MTL::AccelerationStructureCommandEncoder* MTL::CommandBuffer::accelerationStructureCommandEncoder(const MTL::AccelerationStructurePassDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(accelerationStructureCommandEncoderWithDescriptor_), descriptor); +} + +// method: pushDebugGroup: +_MTL_INLINE void MTL::CommandBuffer::pushDebugGroup(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string); +} + +// method: popDebugGroup +_MTL_INLINE void MTL::CommandBuffer::popDebugGroup() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(popDebugGroup)); +} diff --git a/vendor/metal-cpp/Metal/MTLCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLCommandEncoder.hpp new file mode 100644 index 000000000..9a4d97c78 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLCommandEncoder.hpp @@ -0,0 +1,101 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, ResourceUsage) { + ResourceUsageRead = 1, + ResourceUsageWrite = 2, + ResourceUsageSample = 4, +}; + +_MTL_OPTIONS(NS::UInteger, BarrierScope) { + BarrierScopeBuffers = 1, + BarrierScopeTextures = 2, + BarrierScopeRenderTargets = 4, +}; + +class CommandEncoder : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); + + void endEncoding(); + + void insertDebugSignpost(const NS::String* string); + + void pushDebugGroup(const NS::String* string); + + void popDebugGroup(); +}; + +} + +// property: device +_MTL_INLINE MTL::Device* MTL::CommandEncoder::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: label +_MTL_INLINE NS::String* MTL::CommandEncoder::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CommandEncoder::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// method: endEncoding +_MTL_INLINE void MTL::CommandEncoder::endEncoding() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(endEncoding)); +} + +// method: insertDebugSignpost: +_MTL_INLINE void MTL::CommandEncoder::insertDebugSignpost(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(insertDebugSignpost_), string); +} + +// method: pushDebugGroup: +_MTL_INLINE void MTL::CommandEncoder::pushDebugGroup(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string); +} + +// method: popDebugGroup +_MTL_INLINE void MTL::CommandEncoder::popDebugGroup() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(popDebugGroup)); +} diff --git a/vendor/metal-cpp/Metal/MTLCommandQueue.hpp b/vendor/metal-cpp/Metal/MTLCommandQueue.hpp new file mode 100644 index 000000000..07b298448 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLCommandQueue.hpp @@ -0,0 +1,89 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLCommandQueue.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +class CommandQueue : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + class CommandBuffer* commandBuffer(); + + class CommandBuffer* commandBuffer(const class CommandBufferDescriptor* descriptor); + + class CommandBuffer* commandBufferWithUnretainedReferences(); + + void insertDebugCaptureBoundary(); +}; + +} + +// property: label +_MTL_INLINE NS::String* MTL::CommandQueue::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CommandQueue::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::CommandQueue::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// method: commandBuffer +_MTL_INLINE MTL::CommandBuffer* MTL::CommandQueue::commandBuffer() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBuffer)); +} + +// method: commandBufferWithDescriptor: +_MTL_INLINE MTL::CommandBuffer* MTL::CommandQueue::commandBuffer(const MTL::CommandBufferDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBufferWithDescriptor_), descriptor); +} + +// method: commandBufferWithUnretainedReferences +_MTL_INLINE MTL::CommandBuffer* MTL::CommandQueue::commandBufferWithUnretainedReferences() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBufferWithUnretainedReferences)); +} + +// method: insertDebugCaptureBoundary +_MTL_INLINE void MTL::CommandQueue::insertDebugCaptureBoundary() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(insertDebugCaptureBoundary)); +} diff --git a/vendor/metal-cpp/Metal/MTLComputeCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLComputeCommandEncoder.hpp new file mode 100644 index 000000000..2b30a1dd7 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLComputeCommandEncoder.hpp @@ -0,0 +1,330 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLComputeCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLCommandBuffer.hpp" +#include "MTLCommandEncoder.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +struct DispatchThreadgroupsIndirectArguments +{ + uint32_t threadgroupsPerGrid[3]; +} _MTL_PACKED; + +struct StageInRegionIndirectArguments +{ + uint32_t stageInOrigin[3]; + uint32_t stageInSize[3]; +} _MTL_PACKED; + +class ComputeCommandEncoder : public NS::Referencing +{ +public: + MTL::DispatchType dispatchType() const; + + void setComputePipelineState(const class ComputePipelineState* state); + + void setBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setVisibleFunctionTable(const class VisibleFunctionTable* visibleFunctionTable, NS::UInteger bufferIndex); + + void setVisibleFunctionTables(const class VisibleFunctionTable* const visibleFunctionTables[], NS::Range range); + + void setIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void setTexture(const class Texture* texture, NS::UInteger index); + + void setTextures(const class Texture* const textures[], NS::Range range); + + void setSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index); + + void setImageblockWidth(NS::UInteger width, NS::UInteger height); + + void setStageInRegion(MTL::Region region); + + void setStageInRegion(const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void dispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup); + + void dispatchThreadgroups(const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerThreadgroup); + + void dispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage); + + void useHeap(const class Heap* heap); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandbuffer, const class Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset); + + void memoryBarrier(MTL::BarrierScope scope); + + void memoryBarrier(const class Resource* const resources[], NS::UInteger count); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); +}; + +} + +// property: dispatchType +_MTL_INLINE MTL::DispatchType MTL::ComputeCommandEncoder::dispatchType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchType)); +} + +// method: setComputePipelineState: +_MTL_INLINE void MTL::ComputeCommandEncoder::setComputePipelineState(const MTL::ComputePipelineState* state) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineState_), state); +} + +// method: setBytes:length:atIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBytes_length_atIndex_), bytes, length, index); +} + +// method: setBuffer:offset:atIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setBufferOffset:atIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferOffset_atIndex_), offset, index); +} + +// method: setBuffers:offsets:withRange: +_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_withRange_), buffers, offsets, range); +} + +// method: setVisibleFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setVisibleFunctionTable(const MTL::VisibleFunctionTable* visibleFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTable_atBufferIndex_), visibleFunctionTable, bufferIndex); +} + +// method: setVisibleFunctionTables:withBufferRange: +_MTL_INLINE void MTL::ComputeCommandEncoder::setVisibleFunctionTables(const MTL::VisibleFunctionTable* const visibleFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTables_withBufferRange_), visibleFunctionTables, range); +} + +// method: setIntersectionFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +// method: setIntersectionFunctionTables:withBufferRange: +_MTL_INLINE void MTL::ComputeCommandEncoder::setIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +// method: setAccelerationStructure:atBufferIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +// method: setTexture:atIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTexture_atIndex_), texture, index); +} + +// method: setTextures:withRange: +_MTL_INLINE void MTL::ComputeCommandEncoder::setTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextures_withRange_), textures, range); +} + +// method: setSamplerState:atIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerState_atIndex_), sampler, index); +} + +// method: setSamplerStates:withRange: +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerStates_withRange_), samplers, range); +} + +// method: setSamplerState:lodMinClamp:lodMaxClamp:atIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +// method: setSamplerStates:lodMinClamps:lodMaxClamps:withRange: +_MTL_INLINE void MTL::ComputeCommandEncoder::setSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +// method: setThreadgroupMemoryLength:atIndex: +_MTL_INLINE void MTL::ComputeCommandEncoder::setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_atIndex_), length, index); +} + +// method: setImageblockWidth:height: +_MTL_INLINE void MTL::ComputeCommandEncoder::setImageblockWidth(NS::UInteger width, NS::UInteger height) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setImageblockWidth_height_), width, height); +} + +// method: setStageInRegion: +_MTL_INLINE void MTL::ComputeCommandEncoder::setStageInRegion(MTL::Region region) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInRegion_), region); +} + +// method: setStageInRegionWithIndirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::ComputeCommandEncoder::setStageInRegion(const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInRegionWithIndirectBuffer_indirectBufferOffset_), indirectBuffer, indirectBufferOffset); +} + +// method: dispatchThreadgroups:threadsPerThreadgroup: +_MTL_INLINE void MTL::ComputeCommandEncoder::dispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreadgroups_threadsPerThreadgroup_), threadgroupsPerGrid, threadsPerThreadgroup); +} + +// method: dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup: +_MTL_INLINE void MTL::ComputeCommandEncoder::dispatchThreadgroups(const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerThreadgroup_), indirectBuffer, indirectBufferOffset, threadsPerThreadgroup); +} + +// method: dispatchThreads:threadsPerThreadgroup: +_MTL_INLINE void MTL::ComputeCommandEncoder::dispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreads_threadsPerThreadgroup_), threadsPerGrid, threadsPerThreadgroup); +} + +// method: updateFence: +_MTL_INLINE void MTL::ComputeCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +// method: waitForFence: +_MTL_INLINE void MTL::ComputeCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +// method: useResource:usage: +_MTL_INLINE void MTL::ComputeCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_), resource, usage); +} + +// method: useResources:count:usage: +_MTL_INLINE void MTL::ComputeCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_), resources, count, usage); +} + +// method: useHeap: +_MTL_INLINE void MTL::ComputeCommandEncoder::useHeap(const MTL::Heap* heap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_), heap); +} + +// method: useHeaps:count: +_MTL_INLINE void MTL::ComputeCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_), heaps, count); +} + +// method: executeCommandsInBuffer:withRange: +_MTL_INLINE void MTL::ComputeCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_withRange_), indirectCommandBuffer, executionRange); +} + +// method: executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::ComputeCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandbuffer, const MTL::Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_), indirectCommandbuffer, indirectRangeBuffer, indirectBufferOffset); +} + +// method: memoryBarrierWithScope: +_MTL_INLINE void MTL::ComputeCommandEncoder::memoryBarrier(MTL::BarrierScope scope) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithScope_), scope); +} + +// method: memoryBarrierWithResources:count: +_MTL_INLINE void MTL::ComputeCommandEncoder::memoryBarrier(const MTL::Resource* const resources[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithResources_count_), resources, count); +} + +// method: sampleCountersInBuffer:atSampleIndex:withBarrier: +_MTL_INLINE void MTL::ComputeCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} diff --git a/vendor/metal-cpp/Metal/MTLComputePass.hpp b/vendor/metal-cpp/Metal/MTLComputePass.hpp new file mode 100644 index 000000000..bbc718418 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLComputePass.hpp @@ -0,0 +1,181 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLComputePass.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLCommandBuffer.hpp" + +namespace MTL +{ +class ComputePassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class ComputePassSampleBufferAttachmentDescriptor* alloc(); + + class ComputePassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class ComputePassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class ComputePassSampleBufferAttachmentDescriptorArray* alloc(); + + class ComputePassSampleBufferAttachmentDescriptorArray* init(); + + class ComputePassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class ComputePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class ComputePassDescriptor : public NS::Copying +{ +public: + static class ComputePassDescriptor* alloc(); + + class ComputePassDescriptor* init(); + + static class ComputePassDescriptor* computePassDescriptor(); + + MTL::DispatchType dispatchType() const; + void setDispatchType(MTL::DispatchType dispatchType); + + class ComputePassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptor* MTL::ComputePassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePassSampleBufferAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptor* MTL::ComputePassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: sampleBuffer +_MTL_INLINE MTL::CounterSampleBuffer* MTL::ComputePassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +// property: startOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::ComputePassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +// property: endOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::ComputePassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +// static method: alloc +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptorArray* MTL::ComputePassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePassSampleBufferAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptorArray* MTL::ComputePassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptor* MTL::ComputePassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::ComputePassSampleBufferAttachmentDescriptorArray::setObject(const MTL::ComputePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::ComputePassDescriptor* MTL::ComputePassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePassDescriptor)); +} + +// method: init +_MTL_INLINE MTL::ComputePassDescriptor* MTL::ComputePassDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: computePassDescriptor +_MTL_INLINE MTL::ComputePassDescriptor* MTL::ComputePassDescriptor::computePassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLComputePassDescriptor), _MTL_PRIVATE_SEL(computePassDescriptor)); +} + +// property: dispatchType +_MTL_INLINE MTL::DispatchType MTL::ComputePassDescriptor::dispatchType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchType)); +} + +_MTL_INLINE void MTL::ComputePassDescriptor::setDispatchType(MTL::DispatchType dispatchType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDispatchType_), dispatchType); +} + +// property: sampleBufferAttachments +_MTL_INLINE MTL::ComputePassSampleBufferAttachmentDescriptorArray* MTL::ComputePassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} diff --git a/vendor/metal-cpp/Metal/MTLComputePipeline.hpp b/vendor/metal-cpp/Metal/MTLComputePipeline.hpp new file mode 100644 index 000000000..3065b8f27 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLComputePipeline.hpp @@ -0,0 +1,373 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLComputePipeline.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLTypes.hpp" + +namespace MTL +{ +class ComputePipelineReflection : public NS::Referencing +{ +public: + static class ComputePipelineReflection* alloc(); + + class ComputePipelineReflection* init(); + + NS::Array* bindings() const; + + NS::Array* arguments() const; +}; + +class ComputePipelineDescriptor : public NS::Copying +{ +public: + static class ComputePipelineDescriptor* alloc(); + + class ComputePipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* computeFunction() const; + void setComputeFunction(const class Function* computeFunction); + + bool threadGroupSizeIsMultipleOfThreadExecutionWidth() const; + void setThreadGroupSizeIsMultipleOfThreadExecutionWidth(bool threadGroupSizeIsMultipleOfThreadExecutionWidth); + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup); + + class StageInputOutputDescriptor* stageInputDescriptor() const; + void setStageInputDescriptor(const class StageInputOutputDescriptor* stageInputDescriptor); + + class PipelineBufferDescriptorArray* buffers() const; + + bool supportIndirectCommandBuffers() const; + void setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers); + + NS::Array* insertLibraries() const; + void setInsertLibraries(const NS::Array* insertLibraries); + + NS::Array* preloadedLibraries() const; + void setPreloadedLibraries(const NS::Array* preloadedLibraries); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + void reset(); + + class LinkedFunctions* linkedFunctions() const; + void setLinkedFunctions(const class LinkedFunctions* linkedFunctions); + + bool supportAddingBinaryFunctions() const; + void setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions); + + NS::UInteger maxCallStackDepth() const; + void setMaxCallStackDepth(NS::UInteger maxCallStackDepth); +}; + +class ComputePipelineState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + + NS::UInteger threadExecutionWidth() const; + + NS::UInteger staticThreadgroupMemoryLength() const; + + NS::UInteger imageblockMemoryLength(MTL::Size imageblockDimensions); + + bool supportIndirectCommandBuffers() const; + + MTL::ResourceID gpuResourceID() const; + + class FunctionHandle* functionHandle(const class Function* function); + + class ComputePipelineState* newComputePipelineState(const NS::Array* functions, NS::Error** error); + + class VisibleFunctionTable* newVisibleFunctionTable(const class VisibleFunctionTableDescriptor* descriptor); + + class IntersectionFunctionTable* newIntersectionFunctionTable(const class IntersectionFunctionTableDescriptor* descriptor); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::ComputePipelineReflection* MTL::ComputePipelineReflection::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePipelineReflection)); +} + +// method: init +_MTL_INLINE MTL::ComputePipelineReflection* MTL::ComputePipelineReflection::init() +{ + return NS::Object::init(); +} + +// property: bindings +_MTL_INLINE NS::Array* MTL::ComputePipelineReflection::bindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bindings)); +} + +// property: arguments +_MTL_INLINE NS::Array* MTL::ComputePipelineReflection::arguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arguments)); +} + +// static method: alloc +_MTL_INLINE MTL::ComputePipelineDescriptor* MTL::ComputePipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLComputePipelineDescriptor)); +} + +// method: init +_MTL_INLINE MTL::ComputePipelineDescriptor* MTL::ComputePipelineDescriptor::init() +{ + return NS::Object::init(); +} + +// property: label +_MTL_INLINE NS::String* MTL::ComputePipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: computeFunction +_MTL_INLINE MTL::Function* MTL::ComputePipelineDescriptor::computeFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(computeFunction)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setComputeFunction(const MTL::Function* computeFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputeFunction_), computeFunction); +} + +// property: threadGroupSizeIsMultipleOfThreadExecutionWidth +_MTL_INLINE bool MTL::ComputePipelineDescriptor::threadGroupSizeIsMultipleOfThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadGroupSizeIsMultipleOfThreadExecutionWidth)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setThreadGroupSizeIsMultipleOfThreadExecutionWidth(bool threadGroupSizeIsMultipleOfThreadExecutionWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadGroupSizeIsMultipleOfThreadExecutionWidth_), threadGroupSizeIsMultipleOfThreadExecutionWidth); +} + +// property: maxTotalThreadsPerThreadgroup +_MTL_INLINE NS::UInteger MTL::ComputePipelineDescriptor::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup); +} + +// property: stageInputDescriptor +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::ComputePipelineDescriptor::stageInputDescriptor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stageInputDescriptor)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setStageInputDescriptor(const MTL::StageInputOutputDescriptor* stageInputDescriptor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInputDescriptor_), stageInputDescriptor); +} + +// property: buffers +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::ComputePipelineDescriptor::buffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffers)); +} + +// property: supportIndirectCommandBuffers +_MTL_INLINE bool MTL::ComputePipelineDescriptor::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportIndirectCommandBuffers_), supportIndirectCommandBuffers); +} + +// property: insertLibraries +_MTL_INLINE NS::Array* MTL::ComputePipelineDescriptor::insertLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(insertLibraries)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setInsertLibraries(const NS::Array* insertLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInsertLibraries_), insertLibraries); +} + +// property: preloadedLibraries +_MTL_INLINE NS::Array* MTL::ComputePipelineDescriptor::preloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preloadedLibraries)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setPreloadedLibraries(const NS::Array* preloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreloadedLibraries_), preloadedLibraries); +} + +// property: binaryArchives +_MTL_INLINE NS::Array* MTL::ComputePipelineDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +// method: reset +_MTL_INLINE void MTL::ComputePipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +// property: linkedFunctions +_MTL_INLINE MTL::LinkedFunctions* MTL::ComputePipelineDescriptor::linkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(linkedFunctions)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setLinkedFunctions(const MTL::LinkedFunctions* linkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLinkedFunctions_), linkedFunctions); +} + +// property: supportAddingBinaryFunctions +_MTL_INLINE bool MTL::ComputePipelineDescriptor::supportAddingBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingBinaryFunctions)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingBinaryFunctions_), supportAddingBinaryFunctions); +} + +// property: maxCallStackDepth +_MTL_INLINE NS::UInteger MTL::ComputePipelineDescriptor::maxCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCallStackDepth)); +} + +_MTL_INLINE void MTL::ComputePipelineDescriptor::setMaxCallStackDepth(NS::UInteger maxCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCallStackDepth_), maxCallStackDepth); +} + +// property: label +_MTL_INLINE NS::String* MTL::ComputePipelineState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::ComputePipelineState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: maxTotalThreadsPerThreadgroup +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +// property: threadExecutionWidth +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::threadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadExecutionWidth)); +} + +// property: staticThreadgroupMemoryLength +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::staticThreadgroupMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(staticThreadgroupMemoryLength)); +} + +// method: imageblockMemoryLengthForDimensions: +_MTL_INLINE NS::UInteger MTL::ComputePipelineState::imageblockMemoryLength(MTL::Size imageblockDimensions) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockMemoryLengthForDimensions_), imageblockDimensions); +} + +// property: supportIndirectCommandBuffers +_MTL_INLINE bool MTL::ComputePipelineState::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::ComputePipelineState::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +// method: functionHandleWithFunction: +_MTL_INLINE MTL::FunctionHandle* MTL::ComputePipelineState::functionHandle(const MTL::Function* function) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionHandleWithFunction_), function); +} + +// method: newComputePipelineStateWithAdditionalBinaryFunctions:error: +_MTL_INLINE MTL::ComputePipelineState* MTL::ComputePipelineState::newComputePipelineState(const NS::Array* functions, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithAdditionalBinaryFunctions_error_), functions, error); +} + +// method: newVisibleFunctionTableWithDescriptor: +_MTL_INLINE MTL::VisibleFunctionTable* MTL::ComputePipelineState::newVisibleFunctionTable(const MTL::VisibleFunctionTableDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newVisibleFunctionTableWithDescriptor_), descriptor); +} + +// method: newIntersectionFunctionTableWithDescriptor: +_MTL_INLINE MTL::IntersectionFunctionTable* MTL::ComputePipelineState::newIntersectionFunctionTable(const MTL::IntersectionFunctionTableDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionTableWithDescriptor_), descriptor); +} diff --git a/vendor/metal-cpp/Metal/MTLCounters.hpp b/vendor/metal-cpp/Metal/MTLCounters.hpp new file mode 100644 index 000000000..c552f7ed4 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLCounters.hpp @@ -0,0 +1,258 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLCounters.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLResource.hpp" + +namespace MTL +{ +struct CounterResultTimestamp +{ + uint64_t timestamp; +} _MTL_PACKED; + +struct CounterResultStageUtilization +{ + uint64_t totalCycles; + uint64_t vertexCycles; + uint64_t tessellationCycles; + uint64_t postTessellationVertexCycles; + uint64_t fragmentCycles; + uint64_t renderTargetCycles; +} _MTL_PACKED; + +struct CounterResultStatistic +{ + uint64_t tessellationInputPatches; + uint64_t vertexInvocations; + uint64_t postTessellationVertexInvocations; + uint64_t clipperInvocations; + uint64_t clipperPrimitivesOut; + uint64_t fragmentInvocations; + uint64_t fragmentsPassed; + uint64_t computeKernelInvocations; +} _MTL_PACKED; + +_MTL_CONST(NS::ErrorDomain, CounterErrorDomain); + +using CommonCounter = NS::String*; + +_MTL_CONST(CommonCounter, CommonCounterTimestamp); +_MTL_CONST(CommonCounter, CommonCounterTessellationInputPatches); +_MTL_CONST(CommonCounter, CommonCounterVertexInvocations); +_MTL_CONST(CommonCounter, CommonCounterPostTessellationVertexInvocations); +_MTL_CONST(CommonCounter, CommonCounterClipperInvocations); +_MTL_CONST(CommonCounter, CommonCounterClipperPrimitivesOut); +_MTL_CONST(CommonCounter, CommonCounterFragmentInvocations); +_MTL_CONST(CommonCounter, CommonCounterFragmentsPassed); +_MTL_CONST(CommonCounter, CommonCounterComputeKernelInvocations); +_MTL_CONST(CommonCounter, CommonCounterTotalCycles); +_MTL_CONST(CommonCounter, CommonCounterVertexCycles); +_MTL_CONST(CommonCounter, CommonCounterTessellationCycles); +_MTL_CONST(CommonCounter, CommonCounterPostTessellationVertexCycles); +_MTL_CONST(CommonCounter, CommonCounterFragmentCycles); +_MTL_CONST(CommonCounter, CommonCounterRenderTargetWriteCycles); + +using CommonCounterSet = NS::String*; + +_MTL_CONST(CommonCounterSet, CommonCounterSetTimestamp); +_MTL_CONST(CommonCounterSet, CommonCounterSetStageUtilization); +_MTL_CONST(CommonCounterSet, CommonCounterSetStatistic); + +class Counter : public NS::Referencing +{ +public: + NS::String* name() const; +}; + +class CounterSet : public NS::Referencing +{ +public: + NS::String* name() const; + + NS::Array* counters() const; +}; + +class CounterSampleBufferDescriptor : public NS::Copying +{ +public: + static class CounterSampleBufferDescriptor* alloc(); + + class CounterSampleBufferDescriptor* init(); + + class CounterSet* counterSet() const; + void setCounterSet(const class CounterSet* counterSet); + + NS::String* label() const; + void setLabel(const NS::String* label); + + MTL::StorageMode storageMode() const; + void setStorageMode(MTL::StorageMode storageMode); + + NS::UInteger sampleCount() const; + void setSampleCount(NS::UInteger sampleCount); +}; + +class CounterSampleBuffer : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + + NS::UInteger sampleCount() const; + + NS::Data* resolveCounterRange(NS::Range range); +}; + +_MTL_ENUM(NS::Integer, CounterSampleBufferError) { + CounterSampleBufferErrorOutOfMemory = 0, + CounterSampleBufferErrorInvalid = 1, + CounterSampleBufferErrorInternal = 2, +}; + +} + +_MTL_PRIVATE_DEF_STR(NS::ErrorDomain, CounterErrorDomain); + +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTimestamp); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTessellationInputPatches); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterVertexInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterPostTessellationVertexInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterClipperInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterClipperPrimitivesOut); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterFragmentInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterFragmentsPassed); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterComputeKernelInvocations); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTotalCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterVertexCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterTessellationCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterPostTessellationVertexCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterFragmentCycles); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounter, CommonCounterRenderTargetWriteCycles); + +_MTL_PRIVATE_DEF_STR(MTL::CommonCounterSet, CommonCounterSetTimestamp); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounterSet, CommonCounterSetStageUtilization); +_MTL_PRIVATE_DEF_STR(MTL::CommonCounterSet, CommonCounterSetStatistic); + +// property: name +_MTL_INLINE NS::String* MTL::Counter::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: name +_MTL_INLINE NS::String* MTL::CounterSet::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: counters +_MTL_INLINE NS::Array* MTL::CounterSet::counters() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(counters)); +} + +// static method: alloc +_MTL_INLINE MTL::CounterSampleBufferDescriptor* MTL::CounterSampleBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCounterSampleBufferDescriptor)); +} + +// method: init +_MTL_INLINE MTL::CounterSampleBufferDescriptor* MTL::CounterSampleBufferDescriptor::init() +{ + return NS::Object::init(); +} + +// property: counterSet +_MTL_INLINE MTL::CounterSet* MTL::CounterSampleBufferDescriptor::counterSet() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(counterSet)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setCounterSet(const MTL::CounterSet* counterSet) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCounterSet_), counterSet); +} + +// property: label +_MTL_INLINE NS::String* MTL::CounterSampleBufferDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: storageMode +_MTL_INLINE MTL::StorageMode MTL::CounterSampleBufferDescriptor::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setStorageMode(MTL::StorageMode storageMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode); +} + +// property: sampleCount +_MTL_INLINE NS::UInteger MTL::CounterSampleBufferDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE void MTL::CounterSampleBufferDescriptor::setSampleCount(NS::UInteger sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::CounterSampleBuffer::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: label +_MTL_INLINE NS::String* MTL::CounterSampleBuffer::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// property: sampleCount +_MTL_INLINE NS::UInteger MTL::CounterSampleBuffer::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +// method: resolveCounterRange: +_MTL_INLINE NS::Data* MTL::CounterSampleBuffer::resolveCounterRange(NS::Range range) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveCounterRange_), range); +} diff --git a/vendor/metal-cpp/Metal/MTLDefines.hpp b/vendor/metal-cpp/Metal/MTLDefines.hpp new file mode 100644 index 000000000..7dd8ff95d --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLDefines.hpp @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLDefines.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "../Foundation/NSDefines.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#define _MTL_EXPORT _NS_EXPORT +#define _MTL_EXTERN _NS_EXTERN +#define _MTL_INLINE _NS_INLINE +#define _MTL_PACKED _NS_PACKED + +#define _MTL_CONST(type, name) _NS_CONST(type, name) +#define _MTL_ENUM(type, name) _NS_ENUM(type, name) +#define _MTL_OPTIONS(type, name) _NS_OPTIONS(type, name) + +#define _MTL_VALIDATE_SIZE(ns, name) _NS_VALIDATE_SIZE(ns, name) +#define _MTL_VALIDATE_ENUM(ns, name) _NS_VALIDATE_ENUM(ns, name) + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Metal/MTLDepthStencil.hpp b/vendor/metal-cpp/Metal/MTLDepthStencil.hpp new file mode 100644 index 000000000..ba8bd8b00 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLDepthStencil.hpp @@ -0,0 +1,269 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLDepthStencil.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLDepthStencil.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, CompareFunction) { + CompareFunctionNever = 0, + CompareFunctionLess = 1, + CompareFunctionEqual = 2, + CompareFunctionLessEqual = 3, + CompareFunctionGreater = 4, + CompareFunctionNotEqual = 5, + CompareFunctionGreaterEqual = 6, + CompareFunctionAlways = 7, +}; + +_MTL_ENUM(NS::UInteger, StencilOperation) { + StencilOperationKeep = 0, + StencilOperationZero = 1, + StencilOperationReplace = 2, + StencilOperationIncrementClamp = 3, + StencilOperationDecrementClamp = 4, + StencilOperationInvert = 5, + StencilOperationIncrementWrap = 6, + StencilOperationDecrementWrap = 7, +}; + +class StencilDescriptor : public NS::Copying +{ +public: + static class StencilDescriptor* alloc(); + + class StencilDescriptor* init(); + + MTL::CompareFunction stencilCompareFunction() const; + void setStencilCompareFunction(MTL::CompareFunction stencilCompareFunction); + + MTL::StencilOperation stencilFailureOperation() const; + void setStencilFailureOperation(MTL::StencilOperation stencilFailureOperation); + + MTL::StencilOperation depthFailureOperation() const; + void setDepthFailureOperation(MTL::StencilOperation depthFailureOperation); + + MTL::StencilOperation depthStencilPassOperation() const; + void setDepthStencilPassOperation(MTL::StencilOperation depthStencilPassOperation); + + uint32_t readMask() const; + void setReadMask(uint32_t readMask); + + uint32_t writeMask() const; + void setWriteMask(uint32_t writeMask); +}; + +class DepthStencilDescriptor : public NS::Copying +{ +public: + static class DepthStencilDescriptor* alloc(); + + class DepthStencilDescriptor* init(); + + MTL::CompareFunction depthCompareFunction() const; + void setDepthCompareFunction(MTL::CompareFunction depthCompareFunction); + + bool depthWriteEnabled() const; + void setDepthWriteEnabled(bool depthWriteEnabled); + + class StencilDescriptor* frontFaceStencil() const; + void setFrontFaceStencil(const class StencilDescriptor* frontFaceStencil); + + class StencilDescriptor* backFaceStencil() const; + void setBackFaceStencil(const class StencilDescriptor* backFaceStencil); + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class DepthStencilState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::StencilDescriptor* MTL::StencilDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStencilDescriptor)); +} + +// method: init +_MTL_INLINE MTL::StencilDescriptor* MTL::StencilDescriptor::init() +{ + return NS::Object::init(); +} + +// property: stencilCompareFunction +_MTL_INLINE MTL::CompareFunction MTL::StencilDescriptor::stencilCompareFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilCompareFunction)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setStencilCompareFunction(MTL::CompareFunction stencilCompareFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilCompareFunction_), stencilCompareFunction); +} + +// property: stencilFailureOperation +_MTL_INLINE MTL::StencilOperation MTL::StencilDescriptor::stencilFailureOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilFailureOperation)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setStencilFailureOperation(MTL::StencilOperation stencilFailureOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilFailureOperation_), stencilFailureOperation); +} + +// property: depthFailureOperation +_MTL_INLINE MTL::StencilOperation MTL::StencilDescriptor::depthFailureOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthFailureOperation)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setDepthFailureOperation(MTL::StencilOperation depthFailureOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthFailureOperation_), depthFailureOperation); +} + +// property: depthStencilPassOperation +_MTL_INLINE MTL::StencilOperation MTL::StencilDescriptor::depthStencilPassOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthStencilPassOperation)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setDepthStencilPassOperation(MTL::StencilOperation depthStencilPassOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStencilPassOperation_), depthStencilPassOperation); +} + +// property: readMask +_MTL_INLINE uint32_t MTL::StencilDescriptor::readMask() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(readMask)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setReadMask(uint32_t readMask) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setReadMask_), readMask); +} + +// property: writeMask +_MTL_INLINE uint32_t MTL::StencilDescriptor::writeMask() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(writeMask)); +} + +_MTL_INLINE void MTL::StencilDescriptor::setWriteMask(uint32_t writeMask) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setWriteMask_), writeMask); +} + +// static method: alloc +_MTL_INLINE MTL::DepthStencilDescriptor* MTL::DepthStencilDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLDepthStencilDescriptor)); +} + +// method: init +_MTL_INLINE MTL::DepthStencilDescriptor* MTL::DepthStencilDescriptor::init() +{ + return NS::Object::init(); +} + +// property: depthCompareFunction +_MTL_INLINE MTL::CompareFunction MTL::DepthStencilDescriptor::depthCompareFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthCompareFunction)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setDepthCompareFunction(MTL::CompareFunction depthCompareFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthCompareFunction_), depthCompareFunction); +} + +// property: depthWriteEnabled +_MTL_INLINE bool MTL::DepthStencilDescriptor::depthWriteEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isDepthWriteEnabled)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setDepthWriteEnabled(bool depthWriteEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthWriteEnabled_), depthWriteEnabled); +} + +// property: frontFaceStencil +_MTL_INLINE MTL::StencilDescriptor* MTL::DepthStencilDescriptor::frontFaceStencil() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(frontFaceStencil)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setFrontFaceStencil(const MTL::StencilDescriptor* frontFaceStencil) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFrontFaceStencil_), frontFaceStencil); +} + +// property: backFaceStencil +_MTL_INLINE MTL::StencilDescriptor* MTL::DepthStencilDescriptor::backFaceStencil() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(backFaceStencil)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setBackFaceStencil(const MTL::StencilDescriptor* backFaceStencil) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBackFaceStencil_), backFaceStencil); +} + +// property: label +_MTL_INLINE NS::String* MTL::DepthStencilDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::DepthStencilDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: label +_MTL_INLINE NS::String* MTL::DepthStencilState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::DepthStencilState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} diff --git a/vendor/metal-cpp/Metal/MTLDevice.hpp b/vendor/metal-cpp/Metal/MTLDevice.hpp new file mode 100644 index 000000000..7628ddb60 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLDevice.hpp @@ -0,0 +1,1374 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLDevice.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLArgument.hpp" +#include "MTLDevice.hpp" +#include "MTLPixelFormat.hpp" +#include "MTLResource.hpp" +#include "MTLTexture.hpp" +#include "MTLTypes.hpp" +#include +#include + +namespace MTL +{ +_MTL_ENUM(NS::Integer, IOCompressionMethod) { + IOCompressionMethodZlib = 0, + IOCompressionMethodLZFSE = 1, + IOCompressionMethodLZ4 = 2, + IOCompressionMethodLZMA = 3, + IOCompressionMethodLZBitmap = 4, +}; + +_MTL_ENUM(NS::UInteger, FeatureSet) { + FeatureSet_iOS_GPUFamily1_v1 = 0, + FeatureSet_iOS_GPUFamily2_v1 = 1, + FeatureSet_iOS_GPUFamily1_v2 = 2, + FeatureSet_iOS_GPUFamily2_v2 = 3, + FeatureSet_iOS_GPUFamily3_v1 = 4, + FeatureSet_iOS_GPUFamily1_v3 = 5, + FeatureSet_iOS_GPUFamily2_v3 = 6, + FeatureSet_iOS_GPUFamily3_v2 = 7, + FeatureSet_iOS_GPUFamily1_v4 = 8, + FeatureSet_iOS_GPUFamily2_v4 = 9, + FeatureSet_iOS_GPUFamily3_v3 = 10, + FeatureSet_iOS_GPUFamily4_v1 = 11, + FeatureSet_iOS_GPUFamily1_v5 = 12, + FeatureSet_iOS_GPUFamily2_v5 = 13, + FeatureSet_iOS_GPUFamily3_v4 = 14, + FeatureSet_iOS_GPUFamily4_v2 = 15, + FeatureSet_iOS_GPUFamily5_v1 = 16, + FeatureSet_macOS_GPUFamily1_v1 = 10000, + FeatureSet_OSX_GPUFamily1_v1 = 10000, + FeatureSet_macOS_GPUFamily1_v2 = 10001, + FeatureSet_OSX_GPUFamily1_v2 = 10001, + FeatureSet_OSX_ReadWriteTextureTier2 = 10002, + FeatureSet_macOS_ReadWriteTextureTier2 = 10002, + FeatureSet_macOS_GPUFamily1_v3 = 10003, + FeatureSet_macOS_GPUFamily1_v4 = 10004, + FeatureSet_macOS_GPUFamily2_v1 = 10005, + FeatureSet_watchOS_GPUFamily1_v1 = 20000, + FeatureSet_WatchOS_GPUFamily1_v1 = 20000, + FeatureSet_watchOS_GPUFamily2_v1 = 20001, + FeatureSet_WatchOS_GPUFamily2_v1 = 20001, + FeatureSet_tvOS_GPUFamily1_v1 = 30000, + FeatureSet_TVOS_GPUFamily1_v1 = 30000, + FeatureSet_tvOS_GPUFamily1_v2 = 30001, + FeatureSet_tvOS_GPUFamily1_v3 = 30002, + FeatureSet_tvOS_GPUFamily2_v1 = 30003, + FeatureSet_tvOS_GPUFamily1_v4 = 30004, + FeatureSet_tvOS_GPUFamily2_v2 = 30005, +}; + +_MTL_ENUM(NS::Integer, GPUFamily) { + GPUFamilyApple1 = 1001, + GPUFamilyApple2 = 1002, + GPUFamilyApple3 = 1003, + GPUFamilyApple4 = 1004, + GPUFamilyApple5 = 1005, + GPUFamilyApple6 = 1006, + GPUFamilyApple7 = 1007, + GPUFamilyApple8 = 1008, + GPUFamilyMac1 = 2001, + GPUFamilyMac2 = 2002, + GPUFamilyCommon1 = 3001, + GPUFamilyCommon2 = 3002, + GPUFamilyCommon3 = 3003, + GPUFamilyMacCatalyst1 = 4001, + GPUFamilyMacCatalyst2 = 4002, + GPUFamilyMetal3 = 5001, +}; + +_MTL_ENUM(NS::UInteger, DeviceLocation) { + DeviceLocationBuiltIn = 0, + DeviceLocationSlot = 1, + DeviceLocationExternal = 2, + DeviceLocationUnspecified = NS::UIntegerMax, +}; + +_MTL_OPTIONS(NS::UInteger, PipelineOption) { + PipelineOptionNone = 0, + PipelineOptionArgumentInfo = 1, + PipelineOptionBufferTypeInfo = 2, + PipelineOptionFailOnBinaryArchiveMiss = 4, +}; + +_MTL_ENUM(NS::UInteger, ReadWriteTextureTier) { + ReadWriteTextureTierNone = 0, + ReadWriteTextureTier1 = 1, + ReadWriteTextureTier2 = 2, +}; + +_MTL_ENUM(NS::UInteger, ArgumentBuffersTier) { + ArgumentBuffersTier1 = 0, + ArgumentBuffersTier2 = 1, +}; + +_MTL_ENUM(NS::UInteger, SparseTextureRegionAlignmentMode) { + SparseTextureRegionAlignmentModeOutward = 0, + SparseTextureRegionAlignmentModeInward = 1, +}; + +_MTL_ENUM(NS::Integer, SparsePageSize) { + SparsePageSize16 = 101, + SparsePageSize64 = 102, + SparsePageSize256 = 103, +}; + +struct AccelerationStructureSizes +{ + NS::UInteger accelerationStructureSize; + NS::UInteger buildScratchBufferSize; + NS::UInteger refitScratchBufferSize; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, CounterSamplingPoint) { + CounterSamplingPointAtStageBoundary = 0, + CounterSamplingPointAtDrawBoundary = 1, + CounterSamplingPointAtDispatchBoundary = 2, + CounterSamplingPointAtTileDispatchBoundary = 3, + CounterSamplingPointAtBlitBoundary = 4, +}; + +struct SizeAndAlign +{ + NS::UInteger size; + NS::UInteger align; +} _MTL_PACKED; + +class ArgumentDescriptor : public NS::Copying +{ +public: + static class ArgumentDescriptor* alloc(); + + class ArgumentDescriptor* init(); + + static class ArgumentDescriptor* argumentDescriptor(); + + MTL::DataType dataType() const; + void setDataType(MTL::DataType dataType); + + NS::UInteger index() const; + void setIndex(NS::UInteger index); + + NS::UInteger arrayLength() const; + void setArrayLength(NS::UInteger arrayLength); + + MTL::ArgumentAccess access() const; + void setAccess(MTL::ArgumentAccess access); + + MTL::TextureType textureType() const; + void setTextureType(MTL::TextureType textureType); + + NS::UInteger constantBlockAlignment() const; + void setConstantBlockAlignment(NS::UInteger constantBlockAlignment); +}; + +using DeviceNotificationName = NS::String*; +_MTL_CONST(DeviceNotificationName, DeviceWasAddedNotification); +_MTL_CONST(DeviceNotificationName, DeviceRemovalRequestedNotification); +_MTL_CONST(DeviceNotificationName, DeviceWasRemovedNotification); +_MTL_CONST(NS::ErrorUserInfoKey, CommandBufferEncoderInfoErrorKey); + +using DeviceNotificationHandlerBlock = void (^)(class Device* pDevice, DeviceNotificationName notifyName); + +using DeviceNotificationHandlerFunction = std::function; + +using AutoreleasedComputePipelineReflection = class ComputePipelineReflection*; + +using AutoreleasedRenderPipelineReflection = class RenderPipelineReflection*; + +using NewLibraryCompletionHandler = void (^)(class Library*, NS::Error*); + +using NewLibraryCompletionHandlerFunction = std::function; + +using NewRenderPipelineStateCompletionHandler = void (^)(class RenderPipelineState*, NS::Error*); + +using NewRenderPipelineStateCompletionHandlerFunction = std::function; + +using NewRenderPipelineStateWithReflectionCompletionHandler = void (^)(class RenderPipelineState*, class RenderPipelineReflection*, NS::Error*); + +using NewRenderPipelineStateWithReflectionCompletionHandlerFunction = std::function; + +using NewComputePipelineStateCompletionHandler = void (^)(class ComputePipelineState*, NS::Error*); + +using NewComputePipelineStateCompletionHandlerFunction = std::function; + +using NewComputePipelineStateWithReflectionCompletionHandler = void (^)(class ComputePipelineState*, class ComputePipelineReflection*, NS::Error*); + +using NewComputePipelineStateWithReflectionCompletionHandlerFunction = std::function; + +using Timestamp = std::uint64_t; + +MTL::Device* CreateSystemDefaultDevice(); + +NS::Array* CopyAllDevices(); + +NS::Array* CopyAllDevicesWithObserver(NS::Object** pOutObserver, DeviceNotificationHandlerBlock handler); + +NS::Array* CopyAllDevicesWithObserver(NS::Object** pOutObserver, const DeviceNotificationHandlerFunction& handler); + +void RemoveDeviceObserver(const NS::Object* pObserver); + +class Device : public NS::Referencing +{ +public: + void newLibrary(const NS::String* pSource, const class CompileOptions* pOptions, const NewLibraryCompletionHandlerFunction& completionHandler); + + void newLibrary(const class StitchedLibraryDescriptor* pDescriptor, const MTL::NewLibraryCompletionHandlerFunction& completionHandler); + + void newRenderPipelineState(const class RenderPipelineDescriptor* pDescriptor, const NewRenderPipelineStateCompletionHandlerFunction& completionHandler); + + void newRenderPipelineState(const class RenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + void newRenderPipelineState(const class TileRenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + void newComputePipelineState(const class Function* pFunction, const NewComputePipelineStateCompletionHandlerFunction& completionHandler); + + void newComputePipelineState(const class Function* pFunction, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + void newComputePipelineState(const class ComputePipelineDescriptor* pDescriptor, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler); + + bool isHeadless() const; + + NS::String* name() const; + + uint64_t registryID() const; + + MTL::Size maxThreadsPerThreadgroup() const; + + bool lowPower() const; + + bool headless() const; + + bool removable() const; + + bool hasUnifiedMemory() const; + + uint64_t recommendedMaxWorkingSetSize() const; + + MTL::DeviceLocation location() const; + + NS::UInteger locationNumber() const; + + uint64_t maxTransferRate() const; + + bool depth24Stencil8PixelFormatSupported() const; + + MTL::ReadWriteTextureTier readWriteTextureSupport() const; + + MTL::ArgumentBuffersTier argumentBuffersSupport() const; + + bool rasterOrderGroupsSupported() const; + + bool supports32BitFloatFiltering() const; + + bool supports32BitMSAA() const; + + bool supportsQueryTextureLOD() const; + + bool supportsBCTextureCompression() const; + + bool supportsPullModelInterpolation() const; + + bool barycentricCoordsSupported() const; + + bool supportsShaderBarycentricCoordinates() const; + + NS::UInteger currentAllocatedSize() const; + + class CommandQueue* newCommandQueue(); + + class CommandQueue* newCommandQueue(NS::UInteger maxCommandBufferCount); + + MTL::SizeAndAlign heapTextureSizeAndAlign(const class TextureDescriptor* desc); + + MTL::SizeAndAlign heapBufferSizeAndAlign(NS::UInteger length, MTL::ResourceOptions options); + + class Heap* newHeap(const class HeapDescriptor* descriptor); + + class Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options); + + class Buffer* newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options); + + class Buffer* newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options, void (^deallocator)(void*, NS::UInteger)); + + class DepthStencilState* newDepthStencilState(const class DepthStencilDescriptor* descriptor); + + class Texture* newTexture(const class TextureDescriptor* descriptor); + + class Texture* newTexture(const class TextureDescriptor* descriptor, const IOSurfaceRef iosurface, NS::UInteger plane); + + class Texture* newSharedTexture(const class TextureDescriptor* descriptor); + + class Texture* newSharedTexture(const class SharedTextureHandle* sharedHandle); + + class SamplerState* newSamplerState(const class SamplerDescriptor* descriptor); + + class Library* newDefaultLibrary(); + + class Library* newDefaultLibrary(const NS::Bundle* bundle, NS::Error** error); + + class Library* newLibrary(const NS::String* filepath, NS::Error** error); + + class Library* newLibrary(const NS::URL* url, NS::Error** error); + + class Library* newLibrary(const dispatch_data_t data, NS::Error** error); + + class Library* newLibrary(const NS::String* source, const class CompileOptions* options, NS::Error** error); + + void newLibrary(const NS::String* source, const class CompileOptions* options, const MTL::NewLibraryCompletionHandler completionHandler); + + class Library* newLibrary(const class StitchedLibraryDescriptor* descriptor, NS::Error** error); + + void newLibrary(const class StitchedLibraryDescriptor* descriptor, const MTL::NewLibraryCompletionHandler completionHandler); + + class RenderPipelineState* newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, NS::Error** error); + + class RenderPipelineState* newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error); + + void newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, const MTL::NewRenderPipelineStateCompletionHandler completionHandler); + + void newRenderPipelineState(const class RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler); + + class ComputePipelineState* newComputePipelineState(const class Function* computeFunction, NS::Error** error); + + class ComputePipelineState* newComputePipelineState(const class Function* computeFunction, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error); + + void newComputePipelineState(const class Function* computeFunction, const MTL::NewComputePipelineStateCompletionHandler completionHandler); + + void newComputePipelineState(const class Function* computeFunction, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler); + + class ComputePipelineState* newComputePipelineState(const class ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error); + + void newComputePipelineState(const class ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler); + + class Fence* newFence(); + + bool supportsFeatureSet(MTL::FeatureSet featureSet); + + bool supportsFamily(MTL::GPUFamily gpuFamily); + + bool supportsTextureSampleCount(NS::UInteger sampleCount); + + NS::UInteger minimumLinearTextureAlignmentForPixelFormat(MTL::PixelFormat format); + + NS::UInteger minimumTextureBufferAlignmentForPixelFormat(MTL::PixelFormat format); + + class RenderPipelineState* newRenderPipelineState(const class TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error); + + void newRenderPipelineState(const class TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler); + + class RenderPipelineState* newRenderPipelineState(const class MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error); + + void newRenderPipelineState(const class MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler); + + NS::UInteger maxThreadgroupMemoryLength() const; + + NS::UInteger maxArgumentBufferSamplerCount() const; + + bool programmableSamplePositionsSupported() const; + + void getDefaultSamplePositions(MTL::SamplePosition* positions, NS::UInteger count); + + class ArgumentEncoder* newArgumentEncoder(const NS::Array* arguments); + + bool supportsRasterizationRateMap(NS::UInteger layerCount); + + class RasterizationRateMap* newRasterizationRateMap(const class RasterizationRateMapDescriptor* descriptor); + + class IndirectCommandBuffer* newIndirectCommandBuffer(const class IndirectCommandBufferDescriptor* descriptor, NS::UInteger maxCount, MTL::ResourceOptions options); + + class Event* newEvent(); + + class SharedEvent* newSharedEvent(); + + class SharedEvent* newSharedEvent(const class SharedEventHandle* sharedEventHandle); + + uint64_t peerGroupID() const; + + uint32_t peerIndex() const; + + uint32_t peerCount() const; + + class IOFileHandle* newIOHandle(const NS::URL* url, NS::Error** error); + + class IOCommandQueue* newIOCommandQueue(const class IOCommandQueueDescriptor* descriptor, NS::Error** error); + + class IOFileHandle* newIOHandle(const NS::URL* url, MTL::IOCompressionMethod compressionMethod, NS::Error** error); + + MTL::Size sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount); + + NS::UInteger sparseTileSizeInBytes() const; + + void convertSparsePixelRegions(const MTL::Region* pixelRegions, MTL::Region* tileRegions, MTL::Size tileSize, MTL::SparseTextureRegionAlignmentMode mode, NS::UInteger numRegions); + + void convertSparseTileRegions(const MTL::Region* tileRegions, MTL::Region* pixelRegions, MTL::Size tileSize, NS::UInteger numRegions); + + NS::UInteger sparseTileSizeInBytes(MTL::SparsePageSize sparsePageSize); + + MTL::Size sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount, MTL::SparsePageSize sparsePageSize); + + NS::UInteger maxBufferLength() const; + + NS::Array* counterSets() const; + + class CounterSampleBuffer* newCounterSampleBuffer(const class CounterSampleBufferDescriptor* descriptor, NS::Error** error); + + void sampleTimestamps(MTL::Timestamp* cpuTimestamp, MTL::Timestamp* gpuTimestamp); + + class ArgumentEncoder* newArgumentEncoder(const class BufferBinding* bufferBinding); + + bool supportsCounterSampling(MTL::CounterSamplingPoint samplingPoint); + + bool supportsVertexAmplificationCount(NS::UInteger count); + + bool supportsDynamicLibraries() const; + + bool supportsRenderDynamicLibraries() const; + + class DynamicLibrary* newDynamicLibrary(const class Library* library, NS::Error** error); + + class DynamicLibrary* newDynamicLibrary(const NS::URL* url, NS::Error** error); + + class BinaryArchive* newBinaryArchive(const class BinaryArchiveDescriptor* descriptor, NS::Error** error); + + bool supportsRaytracing() const; + + MTL::AccelerationStructureSizes accelerationStructureSizes(const class AccelerationStructureDescriptor* descriptor); + + class AccelerationStructure* newAccelerationStructure(NS::UInteger size); + + class AccelerationStructure* newAccelerationStructure(const class AccelerationStructureDescriptor* descriptor); + + MTL::SizeAndAlign heapAccelerationStructureSizeAndAlign(NS::UInteger size); + + MTL::SizeAndAlign heapAccelerationStructureSizeAndAlign(const class AccelerationStructureDescriptor* descriptor); + + bool supportsFunctionPointers() const; + + bool supportsFunctionPointersFromRender() const; + + bool supportsRaytracingFromRender() const; + + bool supportsPrimitiveMotionBlur() const; + + bool shouldMaximizeConcurrentCompilation() const; + void setShouldMaximizeConcurrentCompilation(bool shouldMaximizeConcurrentCompilation); + + NS::UInteger maximumConcurrentCompilationTaskCount() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::ArgumentDescriptor* MTL::ArgumentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArgumentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::ArgumentDescriptor* MTL::ArgumentDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: argumentDescriptor +_MTL_INLINE MTL::ArgumentDescriptor* MTL::ArgumentDescriptor::argumentDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLArgumentDescriptor), _MTL_PRIVATE_SEL(argumentDescriptor)); +} + +// property: dataType +_MTL_INLINE MTL::DataType MTL::ArgumentDescriptor::dataType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dataType)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setDataType(MTL::DataType dataType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDataType_), dataType); +} + +// property: index +_MTL_INLINE NS::UInteger MTL::ArgumentDescriptor::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setIndex(NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndex_), index); +} + +// property: arrayLength +_MTL_INLINE NS::UInteger MTL::ArgumentDescriptor::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setArrayLength(NS::UInteger arrayLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArrayLength_), arrayLength); +} + +// property: access +_MTL_INLINE MTL::ArgumentAccess MTL::ArgumentDescriptor::access() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setAccess(MTL::ArgumentAccess access) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAccess_), access); +} + +// property: textureType +_MTL_INLINE MTL::TextureType MTL::ArgumentDescriptor::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setTextureType(MTL::TextureType textureType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextureType_), textureType); +} + +// property: constantBlockAlignment +_MTL_INLINE NS::UInteger MTL::ArgumentDescriptor::constantBlockAlignment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(constantBlockAlignment)); +} + +_MTL_INLINE void MTL::ArgumentDescriptor::setConstantBlockAlignment(NS::UInteger constantBlockAlignment) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantBlockAlignment_), constantBlockAlignment); +} + +_MTL_PRIVATE_DEF_WEAK_CONST(MTL::DeviceNotificationName, DeviceWasAddedNotification); +_MTL_PRIVATE_DEF_WEAK_CONST(MTL::DeviceNotificationName, DeviceRemovalRequestedNotification); +_MTL_PRIVATE_DEF_WEAK_CONST(MTL::DeviceNotificationName, DeviceWasRemovedNotification); +_MTL_PRIVATE_DEF_CONST(NS::ErrorUserInfoKey, CommandBufferEncoderInfoErrorKey); + +#if defined(MTL_PRIVATE_IMPLEMENTATION) + +extern "C" MTL::Device* MTLCreateSystemDefaultDevice(); + +extern "C" NS::Array* MTLCopyAllDevices(); + +extern "C" NS::Array* MTLCopyAllDevicesWithObserver(NS::Object**, MTL::DeviceNotificationHandlerBlock); + +extern "C" void MTLRemoveDeviceObserver(const NS::Object*); + +#include + +_NS_EXPORT MTL::Device* MTL::CreateSystemDefaultDevice() +{ + return ::MTLCreateSystemDefaultDevice(); +} + +_NS_EXPORT NS::Array* MTL::CopyAllDevices() +{ +#if TARGET_OS_OSX + return ::MTLCopyAllDevices(); +#else + return nullptr; +#endif // TARGET_OS_OSX +} + +_NS_EXPORT NS::Array* MTL::CopyAllDevicesWithObserver(NS::Object** pOutObserver, DeviceNotificationHandlerBlock handler) +{ +#if TARGET_OS_OSX + return ::MTLCopyAllDevicesWithObserver(pOutObserver, handler); +#else + (void)pOutObserver; + (void)handler; + + return nullptr; +#endif // TARGET_OS_OSX +} + +_NS_EXPORT NS::Array* MTL::CopyAllDevicesWithObserver(NS::Object** pOutObserver, const DeviceNotificationHandlerFunction& handler) +{ + __block DeviceNotificationHandlerFunction function = handler; + + return CopyAllDevicesWithObserver(pOutObserver, ^(Device* pDevice, DeviceNotificationName pNotificationName) { function(pDevice, pNotificationName); }); +} + +_NS_EXPORT void MTL::RemoveDeviceObserver(const NS::Object* pObserver) +{ +#if TARGET_OS_OSX + ::MTLRemoveDeviceObserver(pObserver); +#endif // TARGET_OS_OSX +} + +#endif // MTL_PRIVATE_IMPLEMENTATION + +_MTL_INLINE void MTL::Device::newLibrary(const NS::String* pSource, const CompileOptions* pOptions, const NewLibraryCompletionHandlerFunction& completionHandler) +{ + __block NewLibraryCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newLibrary(pSource, pOptions, ^(Library* pLibrary, NS::Error* pError) { blockCompletionHandler(pLibrary, pError); }); +} + +_MTL_INLINE void MTL::Device::newLibrary(const class StitchedLibraryDescriptor* pDescriptor, const MTL::NewLibraryCompletionHandlerFunction& completionHandler) +{ + __block NewLibraryCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newLibrary(pDescriptor, ^(Library* pLibrary, NS::Error* pError) { blockCompletionHandler(pLibrary, pError); }); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const RenderPipelineDescriptor* pDescriptor, const NewRenderPipelineStateCompletionHandlerFunction& completionHandler) +{ + __block NewRenderPipelineStateCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newRenderPipelineState(pDescriptor, ^(RenderPipelineState* pPipelineState, NS::Error* pError) { blockCompletionHandler(pPipelineState, pError); }); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const RenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewRenderPipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newRenderPipelineState(pDescriptor, options, ^(RenderPipelineState* pPipelineState, class RenderPipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE void MTL::Device::newRenderPipelineState(const TileRenderPipelineDescriptor* pDescriptor, PipelineOption options, const NewRenderPipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewRenderPipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newRenderPipelineState(pDescriptor, options, ^(RenderPipelineState* pPipelineState, class RenderPipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const class Function* pFunction, const NewComputePipelineStateCompletionHandlerFunction& completionHandler) +{ + __block NewComputePipelineStateCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newComputePipelineState(pFunction, ^(ComputePipelineState* pPipelineState, NS::Error* pError) { blockCompletionHandler(pPipelineState, pError); }); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const Function* pFunction, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewComputePipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newComputePipelineState(pFunction, options, ^(ComputePipelineState* pPipelineState, ComputePipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE void MTL::Device::newComputePipelineState(const ComputePipelineDescriptor* pDescriptor, PipelineOption options, const NewComputePipelineStateWithReflectionCompletionHandlerFunction& completionHandler) +{ + __block NewComputePipelineStateWithReflectionCompletionHandlerFunction blockCompletionHandler = completionHandler; + + newComputePipelineState(pDescriptor, options, ^(ComputePipelineState* pPipelineState, ComputePipelineReflection* pReflection, NS::Error* pError) { blockCompletionHandler(pPipelineState, pReflection, pError); }); +} + +_MTL_INLINE bool MTL::Device::isHeadless() const +{ + return headless(); +} + +// property: name +_MTL_INLINE NS::String* MTL::Device::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: registryID +_MTL_INLINE uint64_t MTL::Device::registryID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(registryID)); +} + +// property: maxThreadsPerThreadgroup +_MTL_INLINE MTL::Size MTL::Device::maxThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxThreadsPerThreadgroup)); +} + +// property: lowPower +_MTL_INLINE bool MTL::Device::lowPower() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isLowPower)); +} + +// property: headless +_MTL_INLINE bool MTL::Device::headless() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isHeadless)); +} + +// property: removable +_MTL_INLINE bool MTL::Device::removable() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isRemovable)); +} + +// property: hasUnifiedMemory +_MTL_INLINE bool MTL::Device::hasUnifiedMemory() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hasUnifiedMemory)); +} + +// property: recommendedMaxWorkingSetSize +_MTL_INLINE uint64_t MTL::Device::recommendedMaxWorkingSetSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(recommendedMaxWorkingSetSize)); +} + +// property: location +_MTL_INLINE MTL::DeviceLocation MTL::Device::location() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(location)); +} + +// property: locationNumber +_MTL_INLINE NS::UInteger MTL::Device::locationNumber() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(locationNumber)); +} + +// property: maxTransferRate +_MTL_INLINE uint64_t MTL::Device::maxTransferRate() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTransferRate)); +} + +// property: depth24Stencil8PixelFormatSupported +_MTL_INLINE bool MTL::Device::depth24Stencil8PixelFormatSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(isDepth24Stencil8PixelFormatSupported)); +} + +// property: readWriteTextureSupport +_MTL_INLINE MTL::ReadWriteTextureTier MTL::Device::readWriteTextureSupport() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(readWriteTextureSupport)); +} + +// property: argumentBuffersSupport +_MTL_INLINE MTL::ArgumentBuffersTier MTL::Device::argumentBuffersSupport() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentBuffersSupport)); +} + +// property: rasterOrderGroupsSupported +_MTL_INLINE bool MTL::Device::rasterOrderGroupsSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(areRasterOrderGroupsSupported)); +} + +// property: supports32BitFloatFiltering +_MTL_INLINE bool MTL::Device::supports32BitFloatFiltering() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supports32BitFloatFiltering)); +} + +// property: supports32BitMSAA +_MTL_INLINE bool MTL::Device::supports32BitMSAA() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supports32BitMSAA)); +} + +// property: supportsQueryTextureLOD +_MTL_INLINE bool MTL::Device::supportsQueryTextureLOD() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsQueryTextureLOD)); +} + +// property: supportsBCTextureCompression +_MTL_INLINE bool MTL::Device::supportsBCTextureCompression() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsBCTextureCompression)); +} + +// property: supportsPullModelInterpolation +_MTL_INLINE bool MTL::Device::supportsPullModelInterpolation() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsPullModelInterpolation)); +} + +// property: barycentricCoordsSupported +_MTL_INLINE bool MTL::Device::barycentricCoordsSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(areBarycentricCoordsSupported)); +} + +// property: supportsShaderBarycentricCoordinates +_MTL_INLINE bool MTL::Device::supportsShaderBarycentricCoordinates() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsShaderBarycentricCoordinates)); +} + +// property: currentAllocatedSize +_MTL_INLINE NS::UInteger MTL::Device::currentAllocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(currentAllocatedSize)); +} + +// method: newCommandQueue +_MTL_INLINE MTL::CommandQueue* MTL::Device::newCommandQueue() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCommandQueue)); +} + +// method: newCommandQueueWithMaxCommandBufferCount: +_MTL_INLINE MTL::CommandQueue* MTL::Device::newCommandQueue(NS::UInteger maxCommandBufferCount) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCommandQueueWithMaxCommandBufferCount_), maxCommandBufferCount); +} + +// method: heapTextureSizeAndAlignWithDescriptor: +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapTextureSizeAndAlign(const MTL::TextureDescriptor* desc) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapTextureSizeAndAlignWithDescriptor_), desc); +} + +// method: heapBufferSizeAndAlignWithLength:options: +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapBufferSizeAndAlign(NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapBufferSizeAndAlignWithLength_options_), length, options); +} + +// method: newHeapWithDescriptor: +_MTL_INLINE MTL::Heap* MTL::Device::newHeap(const MTL::HeapDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newHeapWithDescriptor_), descriptor); +} + +// method: newBufferWithLength:options: +_MTL_INLINE MTL::Buffer* MTL::Device::newBuffer(NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithLength_options_), length, options); +} + +// method: newBufferWithBytes:length:options: +_MTL_INLINE MTL::Buffer* MTL::Device::newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithBytes_length_options_), pointer, length, options); +} + +// method: newBufferWithBytesNoCopy:length:options:deallocator: +_MTL_INLINE MTL::Buffer* MTL::Device::newBuffer(const void* pointer, NS::UInteger length, MTL::ResourceOptions options, void (^deallocator)(void*, NS::UInteger)) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithBytesNoCopy_length_options_deallocator_), pointer, length, options, deallocator); +} + +// method: newDepthStencilStateWithDescriptor: +_MTL_INLINE MTL::DepthStencilState* MTL::Device::newDepthStencilState(const MTL::DepthStencilDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDepthStencilStateWithDescriptor_), descriptor); +} + +// method: newTextureWithDescriptor: +_MTL_INLINE MTL::Texture* MTL::Device::newTexture(const MTL::TextureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_), descriptor); +} + +// method: newTextureWithDescriptor:iosurface:plane: +_MTL_INLINE MTL::Texture* MTL::Device::newTexture(const MTL::TextureDescriptor* descriptor, const IOSurfaceRef iosurface, NS::UInteger plane) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_iosurface_plane_), descriptor, iosurface, plane); +} + +// method: newSharedTextureWithDescriptor: +_MTL_INLINE MTL::Texture* MTL::Device::newSharedTexture(const MTL::TextureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedTextureWithDescriptor_), descriptor); +} + +// method: newSharedTextureWithHandle: +_MTL_INLINE MTL::Texture* MTL::Device::newSharedTexture(const MTL::SharedTextureHandle* sharedHandle) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedTextureWithHandle_), sharedHandle); +} + +// method: newSamplerStateWithDescriptor: +_MTL_INLINE MTL::SamplerState* MTL::Device::newSamplerState(const MTL::SamplerDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSamplerStateWithDescriptor_), descriptor); +} + +// method: newDefaultLibrary +_MTL_INLINE MTL::Library* MTL::Device::newDefaultLibrary() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDefaultLibrary)); +} + +// method: newDefaultLibraryWithBundle:error: +_MTL_INLINE MTL::Library* MTL::Device::newDefaultLibrary(const NS::Bundle* bundle, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDefaultLibraryWithBundle_error_), bundle, error); +} + +// method: newLibraryWithFile:error: +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const NS::String* filepath, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithFile_error_), filepath, error); +} + +// method: newLibraryWithURL:error: +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithURL_error_), url, error); +} + +// method: newLibraryWithData:error: +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const dispatch_data_t data, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithData_error_), data, error); +} + +// method: newLibraryWithSource:options:error: +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const NS::String* source, const MTL::CompileOptions* options, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithSource_options_error_), source, options, error); +} + +// method: newLibraryWithSource:options:completionHandler: +_MTL_INLINE void MTL::Device::newLibrary(const NS::String* source, const MTL::CompileOptions* options, const MTL::NewLibraryCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithSource_options_completionHandler_), source, options, completionHandler); +} + +// method: newLibraryWithStitchedDescriptor:error: +_MTL_INLINE MTL::Library* MTL::Device::newLibrary(const MTL::StitchedLibraryDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithStitchedDescriptor_error_), descriptor, error); +} + +// method: newLibraryWithStitchedDescriptor:completionHandler: +_MTL_INLINE void MTL::Device::newLibrary(const MTL::StitchedLibraryDescriptor* descriptor, const MTL::NewLibraryCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newLibraryWithStitchedDescriptor_completionHandler_), descriptor, completionHandler); +} + +// method: newRenderPipelineStateWithDescriptor:error: +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_error_), descriptor, error); +} + +// method: newRenderPipelineStateWithDescriptor:options:reflection:error: +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +// method: newRenderPipelineStateWithDescriptor:completionHandler: +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, const MTL::NewRenderPipelineStateCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_completionHandler_), descriptor, completionHandler); +} + +// method: newRenderPipelineStateWithDescriptor:options:completionHandler: +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::RenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +// method: newComputePipelineStateWithFunction:error: +_MTL_INLINE MTL::ComputePipelineState* MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_error_), computeFunction, error); +} + +// method: newComputePipelineStateWithFunction:options:reflection:error: +_MTL_INLINE MTL::ComputePipelineState* MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_options_reflection_error_), computeFunction, options, reflection, error); +} + +// method: newComputePipelineStateWithFunction:completionHandler: +_MTL_INLINE void MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, const MTL::NewComputePipelineStateCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_completionHandler_), computeFunction, completionHandler); +} + +// method: newComputePipelineStateWithFunction:options:completionHandler: +_MTL_INLINE void MTL::Device::newComputePipelineState(const MTL::Function* computeFunction, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithFunction_options_completionHandler_), computeFunction, options, completionHandler); +} + +// method: newComputePipelineStateWithDescriptor:options:reflection:error: +_MTL_INLINE MTL::ComputePipelineState* MTL::Device::newComputePipelineState(const MTL::ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedComputePipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +// method: newComputePipelineStateWithDescriptor:options:completionHandler: +_MTL_INLINE void MTL::Device::newComputePipelineState(const MTL::ComputePipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewComputePipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newComputePipelineStateWithDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +// method: newFence +_MTL_INLINE MTL::Fence* MTL::Device::newFence() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFence)); +} + +// method: supportsFeatureSet: +_MTL_INLINE bool MTL::Device::supportsFeatureSet(MTL::FeatureSet featureSet) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFeatureSet_), featureSet); +} + +// method: supportsFamily: +_MTL_INLINE bool MTL::Device::supportsFamily(MTL::GPUFamily gpuFamily) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFamily_), gpuFamily); +} + +// method: supportsTextureSampleCount: +_MTL_INLINE bool MTL::Device::supportsTextureSampleCount(NS::UInteger sampleCount) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsTextureSampleCount_), sampleCount); +} + +// method: minimumLinearTextureAlignmentForPixelFormat: +_MTL_INLINE NS::UInteger MTL::Device::minimumLinearTextureAlignmentForPixelFormat(MTL::PixelFormat format) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(minimumLinearTextureAlignmentForPixelFormat_), format); +} + +// method: minimumTextureBufferAlignmentForPixelFormat: +_MTL_INLINE NS::UInteger MTL::Device::minimumTextureBufferAlignmentForPixelFormat(MTL::PixelFormat format) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(minimumTextureBufferAlignmentForPixelFormat_), format); +} + +// method: newRenderPipelineStateWithTileDescriptor:options:reflection:error: +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithTileDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +// method: newRenderPipelineStateWithTileDescriptor:options:completionHandler: +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::TileRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithTileDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +// method: newRenderPipelineStateWithMeshDescriptor:options:reflection:error: +_MTL_INLINE MTL::RenderPipelineState* MTL::Device::newRenderPipelineState(const MTL::MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::AutoreleasedRenderPipelineReflection* reflection, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithMeshDescriptor_options_reflection_error_), descriptor, options, reflection, error); +} + +// method: newRenderPipelineStateWithMeshDescriptor:options:completionHandler: +_MTL_INLINE void MTL::Device::newRenderPipelineState(const MTL::MeshRenderPipelineDescriptor* descriptor, MTL::PipelineOption options, const MTL::NewRenderPipelineStateWithReflectionCompletionHandler completionHandler) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithMeshDescriptor_options_completionHandler_), descriptor, options, completionHandler); +} + +// property: maxThreadgroupMemoryLength +_MTL_INLINE NS::UInteger MTL::Device::maxThreadgroupMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxThreadgroupMemoryLength)); +} + +// property: maxArgumentBufferSamplerCount +_MTL_INLINE NS::UInteger MTL::Device::maxArgumentBufferSamplerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxArgumentBufferSamplerCount)); +} + +// property: programmableSamplePositionsSupported +_MTL_INLINE bool MTL::Device::programmableSamplePositionsSupported() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(areProgrammableSamplePositionsSupported)); +} + +// method: getDefaultSamplePositions:count: +_MTL_INLINE void MTL::Device::getDefaultSamplePositions(MTL::SamplePosition* positions, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getDefaultSamplePositions_count_), positions, count); +} + +// method: newArgumentEncoderWithArguments: +_MTL_INLINE MTL::ArgumentEncoder* MTL::Device::newArgumentEncoder(const NS::Array* arguments) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithArguments_), arguments); +} + +// method: supportsRasterizationRateMapWithLayerCount: +_MTL_INLINE bool MTL::Device::supportsRasterizationRateMap(NS::UInteger layerCount) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRasterizationRateMapWithLayerCount_), layerCount); +} + +// method: newRasterizationRateMapWithDescriptor: +_MTL_INLINE MTL::RasterizationRateMap* MTL::Device::newRasterizationRateMap(const MTL::RasterizationRateMapDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRasterizationRateMapWithDescriptor_), descriptor); +} + +// method: newIndirectCommandBufferWithDescriptor:maxCommandCount:options: +_MTL_INLINE MTL::IndirectCommandBuffer* MTL::Device::newIndirectCommandBuffer(const MTL::IndirectCommandBufferDescriptor* descriptor, NS::UInteger maxCount, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIndirectCommandBufferWithDescriptor_maxCommandCount_options_), descriptor, maxCount, options); +} + +// method: newEvent +_MTL_INLINE MTL::Event* MTL::Device::newEvent() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newEvent)); +} + +// method: newSharedEvent +_MTL_INLINE MTL::SharedEvent* MTL::Device::newSharedEvent() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedEvent)); +} + +// method: newSharedEventWithHandle: +_MTL_INLINE MTL::SharedEvent* MTL::Device::newSharedEvent(const MTL::SharedEventHandle* sharedEventHandle) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedEventWithHandle_), sharedEventHandle); +} + +// property: peerGroupID +_MTL_INLINE uint64_t MTL::Device::peerGroupID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(peerGroupID)); +} + +// property: peerIndex +_MTL_INLINE uint32_t MTL::Device::peerIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(peerIndex)); +} + +// property: peerCount +_MTL_INLINE uint32_t MTL::Device::peerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(peerCount)); +} + +// method: newIOHandleWithURL:error: +_MTL_INLINE MTL::IOFileHandle* MTL::Device::newIOHandle(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOHandleWithURL_error_), url, error); +} + +// method: newIOCommandQueueWithDescriptor:error: +_MTL_INLINE MTL::IOCommandQueue* MTL::Device::newIOCommandQueue(const MTL::IOCommandQueueDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOCommandQueueWithDescriptor_error_), descriptor, error); +} + +// method: newIOHandleWithURL:compressionMethod:error: +_MTL_INLINE MTL::IOFileHandle* MTL::Device::newIOHandle(const NS::URL* url, MTL::IOCompressionMethod compressionMethod, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOHandleWithURL_compressionMethod_error_), url, compressionMethod, error); +} + +// method: sparseTileSizeWithTextureType:pixelFormat:sampleCount: +_MTL_INLINE MTL::Size MTL::Device::sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_), textureType, pixelFormat, sampleCount); +} + +// property: sparseTileSizeInBytes +_MTL_INLINE NS::UInteger MTL::Device::sparseTileSizeInBytes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeInBytes)); +} + +// method: convertSparsePixelRegions:toTileRegions:withTileSize:alignmentMode:numRegions: +_MTL_INLINE void MTL::Device::convertSparsePixelRegions(const MTL::Region* pixelRegions, MTL::Region* tileRegions, MTL::Size tileSize, MTL::SparseTextureRegionAlignmentMode mode, NS::UInteger numRegions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(convertSparsePixelRegions_toTileRegions_withTileSize_alignmentMode_numRegions_), pixelRegions, tileRegions, tileSize, mode, numRegions); +} + +// method: convertSparseTileRegions:toPixelRegions:withTileSize:numRegions: +_MTL_INLINE void MTL::Device::convertSparseTileRegions(const MTL::Region* tileRegions, MTL::Region* pixelRegions, MTL::Size tileSize, NS::UInteger numRegions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(convertSparseTileRegions_toPixelRegions_withTileSize_numRegions_), tileRegions, pixelRegions, tileSize, numRegions); +} + +// method: sparseTileSizeInBytesForSparsePageSize: +_MTL_INLINE NS::UInteger MTL::Device::sparseTileSizeInBytes(MTL::SparsePageSize sparsePageSize) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeInBytesForSparsePageSize_), sparsePageSize); +} + +// method: sparseTileSizeWithTextureType:pixelFormat:sampleCount:sparsePageSize: +_MTL_INLINE MTL::Size MTL::Device::sparseTileSize(MTL::TextureType textureType, MTL::PixelFormat pixelFormat, NS::UInteger sampleCount, MTL::SparsePageSize sparsePageSize) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_sparsePageSize_), textureType, pixelFormat, sampleCount, sparsePageSize); +} + +// property: maxBufferLength +_MTL_INLINE NS::UInteger MTL::Device::maxBufferLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxBufferLength)); +} + +// property: counterSets +_MTL_INLINE NS::Array* MTL::Device::counterSets() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(counterSets)); +} + +// method: newCounterSampleBufferWithDescriptor:error: +_MTL_INLINE MTL::CounterSampleBuffer* MTL::Device::newCounterSampleBuffer(const MTL::CounterSampleBufferDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newCounterSampleBufferWithDescriptor_error_), descriptor, error); +} + +// method: sampleTimestamps:gpuTimestamp: +_MTL_INLINE void MTL::Device::sampleTimestamps(MTL::Timestamp* cpuTimestamp, MTL::Timestamp* gpuTimestamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleTimestamps_gpuTimestamp_), cpuTimestamp, gpuTimestamp); +} + +// method: newArgumentEncoderWithBufferBinding: +_MTL_INLINE MTL::ArgumentEncoder* MTL::Device::newArgumentEncoder(const MTL::BufferBinding* bufferBinding) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferBinding_), bufferBinding); +} + +// method: supportsCounterSampling: +_MTL_INLINE bool MTL::Device::supportsCounterSampling(MTL::CounterSamplingPoint samplingPoint) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsCounterSampling_), samplingPoint); +} + +// method: supportsVertexAmplificationCount: +_MTL_INLINE bool MTL::Device::supportsVertexAmplificationCount(NS::UInteger count) +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsVertexAmplificationCount_), count); +} + +// property: supportsDynamicLibraries +_MTL_INLINE bool MTL::Device::supportsDynamicLibraries() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsDynamicLibraries)); +} + +// property: supportsRenderDynamicLibraries +_MTL_INLINE bool MTL::Device::supportsRenderDynamicLibraries() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRenderDynamicLibraries)); +} + +// method: newDynamicLibrary:error: +_MTL_INLINE MTL::DynamicLibrary* MTL::Device::newDynamicLibrary(const MTL::Library* library, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDynamicLibrary_error_), library, error); +} + +// method: newDynamicLibraryWithURL:error: +_MTL_INLINE MTL::DynamicLibrary* MTL::Device::newDynamicLibrary(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newDynamicLibraryWithURL_error_), url, error); +} + +// method: newBinaryArchiveWithDescriptor:error: +_MTL_INLINE MTL::BinaryArchive* MTL::Device::newBinaryArchive(const MTL::BinaryArchiveDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBinaryArchiveWithDescriptor_error_), descriptor, error); +} + +// property: supportsRaytracing +_MTL_INLINE bool MTL::Device::supportsRaytracing() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRaytracing)); +} + +// method: accelerationStructureSizesWithDescriptor: +_MTL_INLINE MTL::AccelerationStructureSizes MTL::Device::accelerationStructureSizes(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(accelerationStructureSizesWithDescriptor_), descriptor); +} + +// method: newAccelerationStructureWithSize: +_MTL_INLINE MTL::AccelerationStructure* MTL::Device::newAccelerationStructure(NS::UInteger size) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithSize_), size); +} + +// method: newAccelerationStructureWithDescriptor: +_MTL_INLINE MTL::AccelerationStructure* MTL::Device::newAccelerationStructure(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithDescriptor_), descriptor); +} + +// method: heapAccelerationStructureSizeAndAlignWithSize: +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapAccelerationStructureSizeAndAlign(NS::UInteger size) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapAccelerationStructureSizeAndAlignWithSize_), size); +} + +// method: heapAccelerationStructureSizeAndAlignWithDescriptor: +_MTL_INLINE MTL::SizeAndAlign MTL::Device::heapAccelerationStructureSizeAndAlign(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapAccelerationStructureSizeAndAlignWithDescriptor_), descriptor); +} + +// property: supportsFunctionPointers +_MTL_INLINE bool MTL::Device::supportsFunctionPointers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFunctionPointers)); +} + +// property: supportsFunctionPointersFromRender +_MTL_INLINE bool MTL::Device::supportsFunctionPointersFromRender() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsFunctionPointersFromRender)); +} + +// property: supportsRaytracingFromRender +_MTL_INLINE bool MTL::Device::supportsRaytracingFromRender() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsRaytracingFromRender)); +} + +// property: supportsPrimitiveMotionBlur +_MTL_INLINE bool MTL::Device::supportsPrimitiveMotionBlur() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportsPrimitiveMotionBlur)); +} + +// property: shouldMaximizeConcurrentCompilation +_MTL_INLINE bool MTL::Device::shouldMaximizeConcurrentCompilation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(shouldMaximizeConcurrentCompilation)); +} + +_MTL_INLINE void MTL::Device::setShouldMaximizeConcurrentCompilation(bool shouldMaximizeConcurrentCompilation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setShouldMaximizeConcurrentCompilation_), shouldMaximizeConcurrentCompilation); +} + +// property: maximumConcurrentCompilationTaskCount +_MTL_INLINE NS::UInteger MTL::Device::maximumConcurrentCompilationTaskCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maximumConcurrentCompilationTaskCount)); +} diff --git a/vendor/metal-cpp/Metal/MTLDrawable.hpp b/vendor/metal-cpp/Metal/MTLDrawable.hpp new file mode 100644 index 000000000..58945d036 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLDrawable.hpp @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLDrawable.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include +#include + +namespace MTL +{ +using DrawablePresentedHandler = void (^)(class Drawable*); + +using DrawablePresentedHandlerFunction = std::function; + +class Drawable : public NS::Referencing +{ +public: + void addPresentedHandler(const MTL::DrawablePresentedHandlerFunction& function); + + void present(); + + void presentAtTime(CFTimeInterval presentationTime); + + void presentAfterMinimumDuration(CFTimeInterval duration); + + void addPresentedHandler(const MTL::DrawablePresentedHandler block); + + CFTimeInterval presentedTime() const; + + NS::UInteger drawableID() const; +}; + +} + +_MTL_INLINE void MTL::Drawable::addPresentedHandler(const MTL::DrawablePresentedHandlerFunction& function) +{ + __block DrawablePresentedHandlerFunction blockFunction = function; + + addPresentedHandler(^(Drawable* pDrawable) { blockFunction(pDrawable); }); +} + +// method: present +_MTL_INLINE void MTL::Drawable::present() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(present)); +} + +// method: presentAtTime: +_MTL_INLINE void MTL::Drawable::presentAtTime(CFTimeInterval presentationTime) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentAtTime_), presentationTime); +} + +// method: presentAfterMinimumDuration: +_MTL_INLINE void MTL::Drawable::presentAfterMinimumDuration(CFTimeInterval duration) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(presentAfterMinimumDuration_), duration); +} + +// method: addPresentedHandler: +_MTL_INLINE void MTL::Drawable::addPresentedHandler(const MTL::DrawablePresentedHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addPresentedHandler_), block); +} + +// property: presentedTime +_MTL_INLINE CFTimeInterval MTL::Drawable::presentedTime() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(presentedTime)); +} + +// property: drawableID +_MTL_INLINE NS::UInteger MTL::Drawable::drawableID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(drawableID)); +} diff --git a/vendor/metal-cpp/Metal/MTLDynamicLibrary.hpp b/vendor/metal-cpp/Metal/MTLDynamicLibrary.hpp new file mode 100644 index 000000000..f951d1258 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLDynamicLibrary.hpp @@ -0,0 +1,82 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLDynamicLibrary.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, DynamicLibraryError) { + DynamicLibraryErrorNone = 0, + DynamicLibraryErrorInvalidFile = 1, + DynamicLibraryErrorCompilationFailure = 2, + DynamicLibraryErrorUnresolvedInstallName = 3, + DynamicLibraryErrorDependencyLoadFailure = 4, + DynamicLibraryErrorUnsupported = 5, +}; + +class DynamicLibrary : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + NS::String* installName() const; + + bool serializeToURL(const NS::URL* url, NS::Error** error); +}; + +} + +// property: label +_MTL_INLINE NS::String* MTL::DynamicLibrary::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::DynamicLibrary::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::DynamicLibrary::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: installName +_MTL_INLINE NS::String* MTL::DynamicLibrary::installName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(installName)); +} + +// method: serializeToURL:error: +_MTL_INLINE bool MTL::DynamicLibrary::serializeToURL(const NS::URL* url, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(serializeToURL_error_), url, error); +} diff --git a/vendor/metal-cpp/Metal/MTLEvent.hpp b/vendor/metal-cpp/Metal/MTLEvent.hpp new file mode 100644 index 000000000..965fc39e4 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLEvent.hpp @@ -0,0 +1,159 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLEvent.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLEvent.hpp" + +namespace MTL +{ +class Event : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class SharedEventListener : public NS::Referencing +{ +public: + static class SharedEventListener* alloc(); + + MTL::SharedEventListener* init(); + + MTL::SharedEventListener* init(const dispatch_queue_t dispatchQueue); + + dispatch_queue_t dispatchQueue() const; +}; + +using SharedEventNotificationBlock = void (^)(SharedEvent* pEvent, std::uint64_t value); + +class SharedEvent : public NS::Referencing +{ +public: + void notifyListener(const class SharedEventListener* listener, uint64_t value, const MTL::SharedEventNotificationBlock block); + + class SharedEventHandle* newSharedEventHandle(); + + uint64_t signaledValue() const; + void setSignaledValue(uint64_t signaledValue); +}; + +class SharedEventHandle : public NS::SecureCoding +{ +public: + static class SharedEventHandle* alloc(); + + class SharedEventHandle* init(); + + NS::String* label() const; +}; + +} + +// property: device +_MTL_INLINE MTL::Device* MTL::Event::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: label +_MTL_INLINE NS::String* MTL::Event::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Event::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// static method: alloc +_MTL_INLINE MTL::SharedEventListener* MTL::SharedEventListener::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSharedEventListener)); +} + +// method: init +_MTL_INLINE MTL::SharedEventListener* MTL::SharedEventListener::init() +{ + return NS::Object::init(); +} + +// method: initWithDispatchQueue: +_MTL_INLINE MTL::SharedEventListener* MTL::SharedEventListener::init(const dispatch_queue_t dispatchQueue) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithDispatchQueue_), dispatchQueue); +} + +// property: dispatchQueue +_MTL_INLINE dispatch_queue_t MTL::SharedEventListener::dispatchQueue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchQueue)); +} + +// method: notifyListener:atValue:block: +_MTL_INLINE void MTL::SharedEvent::notifyListener(const MTL::SharedEventListener* listener, uint64_t value, const MTL::SharedEventNotificationBlock block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(notifyListener_atValue_block_), listener, value, block); +} + +// method: newSharedEventHandle +_MTL_INLINE MTL::SharedEventHandle* MTL::SharedEvent::newSharedEventHandle() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedEventHandle)); +} + +// property: signaledValue +_MTL_INLINE uint64_t MTL::SharedEvent::signaledValue() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(signaledValue)); +} + +_MTL_INLINE void MTL::SharedEvent::setSignaledValue(uint64_t signaledValue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSignaledValue_), signaledValue); +} + +// static method: alloc +_MTL_INLINE MTL::SharedEventHandle* MTL::SharedEventHandle::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSharedEventHandle)); +} + +// method: init +_MTL_INLINE MTL::SharedEventHandle* MTL::SharedEventHandle::init() +{ + return NS::Object::init(); +} + +// property: label +_MTL_INLINE NS::String* MTL::SharedEventHandle::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} diff --git a/vendor/metal-cpp/Metal/MTLFence.hpp b/vendor/metal-cpp/Metal/MTLFence.hpp new file mode 100644 index 000000000..c8ef24ca7 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLFence.hpp @@ -0,0 +1,57 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLFence.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +class Fence : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +} + +// property: device +_MTL_INLINE MTL::Device* MTL::Fence::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: label +_MTL_INLINE NS::String* MTL::Fence::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Fence::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} diff --git a/vendor/metal-cpp/Metal/MTLFunctionConstantValues.hpp b/vendor/metal-cpp/Metal/MTLFunctionConstantValues.hpp new file mode 100644 index 000000000..d23d98fc4 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLFunctionConstantValues.hpp @@ -0,0 +1,85 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLFunctionConstantValues.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLArgument.hpp" + +namespace MTL +{ +class FunctionConstantValues : public NS::Copying +{ +public: + static class FunctionConstantValues* alloc(); + + class FunctionConstantValues* init(); + + void setConstantValue(const void* value, MTL::DataType type, NS::UInteger index); + + void setConstantValues(const void* values, MTL::DataType type, NS::Range range); + + void setConstantValue(const void* value, MTL::DataType type, const NS::String* name); + + void reset(); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::FunctionConstantValues* MTL::FunctionConstantValues::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionConstantValues)); +} + +// method: init +_MTL_INLINE MTL::FunctionConstantValues* MTL::FunctionConstantValues::init() +{ + return NS::Object::init(); +} + +// method: setConstantValue:type:atIndex: +_MTL_INLINE void MTL::FunctionConstantValues::setConstantValue(const void* value, MTL::DataType type, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValue_type_atIndex_), value, type, index); +} + +// method: setConstantValues:type:withRange: +_MTL_INLINE void MTL::FunctionConstantValues::setConstantValues(const void* values, MTL::DataType type, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValues_type_withRange_), values, type, range); +} + +// method: setConstantValue:type:withName: +_MTL_INLINE void MTL::FunctionConstantValues::setConstantValue(const void* value, MTL::DataType type, const NS::String* name) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValue_type_withName_), value, type, name); +} + +// method: reset +_MTL_INLINE void MTL::FunctionConstantValues::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} diff --git a/vendor/metal-cpp/Metal/MTLFunctionDescriptor.hpp b/vendor/metal-cpp/Metal/MTLFunctionDescriptor.hpp new file mode 100644 index 000000000..811ee1508 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLFunctionDescriptor.hpp @@ -0,0 +1,156 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLFunctionDescriptor.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLFunctionDescriptor.hpp" + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, FunctionOptions) { + FunctionOptionNone = 0, + FunctionOptionCompileToBinary = 1, +}; + +class FunctionDescriptor : public NS::Copying +{ +public: + static class FunctionDescriptor* alloc(); + + class FunctionDescriptor* init(); + + static class FunctionDescriptor* functionDescriptor(); + + NS::String* name() const; + void setName(const NS::String* name); + + NS::String* specializedName() const; + void setSpecializedName(const NS::String* specializedName); + + class FunctionConstantValues* constantValues() const; + void setConstantValues(const class FunctionConstantValues* constantValues); + + MTL::FunctionOptions options() const; + void setOptions(MTL::FunctionOptions options); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); +}; + +class IntersectionFunctionDescriptor : public NS::Copying +{ +public: + static class IntersectionFunctionDescriptor* alloc(); + + class IntersectionFunctionDescriptor* init(); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::FunctionDescriptor* MTL::FunctionDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionDescriptor)); +} + +// method: init +_MTL_INLINE MTL::FunctionDescriptor* MTL::FunctionDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: functionDescriptor +_MTL_INLINE MTL::FunctionDescriptor* MTL::FunctionDescriptor::functionDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLFunctionDescriptor), _MTL_PRIVATE_SEL(functionDescriptor)); +} + +// property: name +_MTL_INLINE NS::String* MTL::FunctionDescriptor::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setName(const NS::String* name) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setName_), name); +} + +// property: specializedName +_MTL_INLINE NS::String* MTL::FunctionDescriptor::specializedName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(specializedName)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setSpecializedName(const NS::String* specializedName) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSpecializedName_), specializedName); +} + +// property: constantValues +_MTL_INLINE MTL::FunctionConstantValues* MTL::FunctionDescriptor::constantValues() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(constantValues)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setConstantValues(const MTL::FunctionConstantValues* constantValues) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setConstantValues_), constantValues); +} + +// property: options +_MTL_INLINE MTL::FunctionOptions MTL::FunctionDescriptor::options() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(options)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setOptions(MTL::FunctionOptions options) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOptions_), options); +} + +// property: binaryArchives +_MTL_INLINE NS::Array* MTL::FunctionDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::FunctionDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +// static method: alloc +_MTL_INLINE MTL::IntersectionFunctionDescriptor* MTL::IntersectionFunctionDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIntersectionFunctionDescriptor)); +} + +// method: init +_MTL_INLINE MTL::IntersectionFunctionDescriptor* MTL::IntersectionFunctionDescriptor::init() +{ + return NS::Object::init(); +} diff --git a/vendor/metal-cpp/Metal/MTLFunctionHandle.hpp b/vendor/metal-cpp/Metal/MTLFunctionHandle.hpp new file mode 100644 index 000000000..30f71f2e5 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLFunctionHandle.hpp @@ -0,0 +1,61 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLFunctionHandle.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLLibrary.hpp" + +namespace MTL +{ +class FunctionHandle : public NS::Referencing +{ +public: + MTL::FunctionType functionType() const; + + NS::String* name() const; + + class Device* device() const; +}; + +} + +// property: functionType +_MTL_INLINE MTL::FunctionType MTL::FunctionHandle::functionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionType)); +} + +// property: name +_MTL_INLINE NS::String* MTL::FunctionHandle::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::FunctionHandle::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} diff --git a/vendor/metal-cpp/Metal/MTLFunctionLog.hpp b/vendor/metal-cpp/Metal/MTLFunctionLog.hpp new file mode 100644 index 000000000..2a8995256 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLFunctionLog.hpp @@ -0,0 +1,114 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLFunctionLog.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLFunctionLog.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, FunctionLogType) { + FunctionLogTypeValidation = 0, +}; + +class LogContainer : public NS::Referencing +{ +public: +}; + +class FunctionLogDebugLocation : public NS::Referencing +{ +public: + NS::String* functionName() const; + + NS::URL* URL() const; + + NS::UInteger line() const; + + NS::UInteger column() const; +}; + +class FunctionLog : public NS::Referencing +{ +public: + MTL::FunctionLogType type() const; + + NS::String* encoderLabel() const; + + class Function* function() const; + + class FunctionLogDebugLocation* debugLocation() const; +}; + +} + +// property: functionName +_MTL_INLINE NS::String* MTL::FunctionLogDebugLocation::functionName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionName)); +} + +// property: URL +_MTL_INLINE NS::URL* MTL::FunctionLogDebugLocation::URL() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(URL)); +} + +// property: line +_MTL_INLINE NS::UInteger MTL::FunctionLogDebugLocation::line() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(line)); +} + +// property: column +_MTL_INLINE NS::UInteger MTL::FunctionLogDebugLocation::column() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(column)); +} + +// property: type +_MTL_INLINE MTL::FunctionLogType MTL::FunctionLog::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +// property: encoderLabel +_MTL_INLINE NS::String* MTL::FunctionLog::encoderLabel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(encoderLabel)); +} + +// property: function +_MTL_INLINE MTL::Function* MTL::FunctionLog::function() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(function)); +} + +// property: debugLocation +_MTL_INLINE MTL::FunctionLogDebugLocation* MTL::FunctionLog::debugLocation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(debugLocation)); +} diff --git a/vendor/metal-cpp/Metal/MTLFunctionStitching.hpp b/vendor/metal-cpp/Metal/MTLFunctionStitching.hpp new file mode 100644 index 000000000..266afbd60 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLFunctionStitching.hpp @@ -0,0 +1,305 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLFunctionStitching.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLFunctionStitching.hpp" + +namespace MTL +{ +class FunctionStitchingAttribute : public NS::Referencing +{ +}; + +class FunctionStitchingAttributeAlwaysInline : public NS::Referencing +{ +public: + static class FunctionStitchingAttributeAlwaysInline* alloc(); + + class FunctionStitchingAttributeAlwaysInline* init(); +}; + +class FunctionStitchingNode : public NS::Copying +{ +}; + +class FunctionStitchingInputNode : public NS::Referencing +{ +public: + static class FunctionStitchingInputNode* alloc(); + + class FunctionStitchingInputNode* init(); + + NS::UInteger argumentIndex() const; + void setArgumentIndex(NS::UInteger argumentIndex); + + MTL::FunctionStitchingInputNode* init(NS::UInteger argument); +}; + +class FunctionStitchingFunctionNode : public NS::Referencing +{ +public: + static class FunctionStitchingFunctionNode* alloc(); + + class FunctionStitchingFunctionNode* init(); + + NS::String* name() const; + void setName(const NS::String* name); + + NS::Array* arguments() const; + void setArguments(const NS::Array* arguments); + + NS::Array* controlDependencies() const; + void setControlDependencies(const NS::Array* controlDependencies); + + MTL::FunctionStitchingFunctionNode* init(const NS::String* name, const NS::Array* arguments, const NS::Array* controlDependencies); +}; + +class FunctionStitchingGraph : public NS::Copying +{ +public: + static class FunctionStitchingGraph* alloc(); + + class FunctionStitchingGraph* init(); + + NS::String* functionName() const; + void setFunctionName(const NS::String* functionName); + + NS::Array* nodes() const; + void setNodes(const NS::Array* nodes); + + class FunctionStitchingFunctionNode* outputNode() const; + void setOutputNode(const class FunctionStitchingFunctionNode* outputNode); + + NS::Array* attributes() const; + void setAttributes(const NS::Array* attributes); + + MTL::FunctionStitchingGraph* init(const NS::String* functionName, const NS::Array* nodes, const class FunctionStitchingFunctionNode* outputNode, const NS::Array* attributes); +}; + +class StitchedLibraryDescriptor : public NS::Copying +{ +public: + static class StitchedLibraryDescriptor* alloc(); + + class StitchedLibraryDescriptor* init(); + + NS::Array* functionGraphs() const; + void setFunctionGraphs(const NS::Array* functionGraphs); + + NS::Array* functions() const; + void setFunctions(const NS::Array* functions); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::FunctionStitchingAttributeAlwaysInline* MTL::FunctionStitchingAttributeAlwaysInline::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingAttributeAlwaysInline)); +} + +// method: init +_MTL_INLINE MTL::FunctionStitchingAttributeAlwaysInline* MTL::FunctionStitchingAttributeAlwaysInline::init() +{ + return NS::Object::init(); +} + +// static method: alloc +_MTL_INLINE MTL::FunctionStitchingInputNode* MTL::FunctionStitchingInputNode::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingInputNode)); +} + +// method: init +_MTL_INLINE MTL::FunctionStitchingInputNode* MTL::FunctionStitchingInputNode::init() +{ + return NS::Object::init(); +} + +// property: argumentIndex +_MTL_INLINE NS::UInteger MTL::FunctionStitchingInputNode::argumentIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(argumentIndex)); +} + +_MTL_INLINE void MTL::FunctionStitchingInputNode::setArgumentIndex(NS::UInteger argumentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArgumentIndex_), argumentIndex); +} + +// method: initWithArgumentIndex: +_MTL_INLINE MTL::FunctionStitchingInputNode* MTL::FunctionStitchingInputNode::init(NS::UInteger argument) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithArgumentIndex_), argument); +} + +// static method: alloc +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingFunctionNode::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingFunctionNode)); +} + +// method: init +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingFunctionNode::init() +{ + return NS::Object::init(); +} + +// property: name +_MTL_INLINE NS::String* MTL::FunctionStitchingFunctionNode::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +_MTL_INLINE void MTL::FunctionStitchingFunctionNode::setName(const NS::String* name) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setName_), name); +} + +// property: arguments +_MTL_INLINE NS::Array* MTL::FunctionStitchingFunctionNode::arguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arguments)); +} + +_MTL_INLINE void MTL::FunctionStitchingFunctionNode::setArguments(const NS::Array* arguments) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArguments_), arguments); +} + +// property: controlDependencies +_MTL_INLINE NS::Array* MTL::FunctionStitchingFunctionNode::controlDependencies() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlDependencies)); +} + +_MTL_INLINE void MTL::FunctionStitchingFunctionNode::setControlDependencies(const NS::Array* controlDependencies) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlDependencies_), controlDependencies); +} + +// method: initWithName:arguments:controlDependencies: +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingFunctionNode::init(const NS::String* name, const NS::Array* arguments, const NS::Array* controlDependencies) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithName_arguments_controlDependencies_), name, arguments, controlDependencies); +} + +// static method: alloc +_MTL_INLINE MTL::FunctionStitchingGraph* MTL::FunctionStitchingGraph::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionStitchingGraph)); +} + +// method: init +_MTL_INLINE MTL::FunctionStitchingGraph* MTL::FunctionStitchingGraph::init() +{ + return NS::Object::init(); +} + +// property: functionName +_MTL_INLINE NS::String* MTL::FunctionStitchingGraph::functionName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionName)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setFunctionName(const NS::String* functionName) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionName_), functionName); +} + +// property: nodes +_MTL_INLINE NS::Array* MTL::FunctionStitchingGraph::nodes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(nodes)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setNodes(const NS::Array* nodes) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setNodes_), nodes); +} + +// property: outputNode +_MTL_INLINE MTL::FunctionStitchingFunctionNode* MTL::FunctionStitchingGraph::outputNode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(outputNode)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setOutputNode(const MTL::FunctionStitchingFunctionNode* outputNode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOutputNode_), outputNode); +} + +// property: attributes +_MTL_INLINE NS::Array* MTL::FunctionStitchingGraph::attributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributes)); +} + +_MTL_INLINE void MTL::FunctionStitchingGraph::setAttributes(const NS::Array* attributes) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAttributes_), attributes); +} + +// method: initWithFunctionName:nodes:outputNode:attributes: +_MTL_INLINE MTL::FunctionStitchingGraph* MTL::FunctionStitchingGraph::init(const NS::String* functionName, const NS::Array* nodes, const MTL::FunctionStitchingFunctionNode* outputNode, const NS::Array* attributes) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithFunctionName_nodes_outputNode_attributes_), functionName, nodes, outputNode, attributes); +} + +// static method: alloc +_MTL_INLINE MTL::StitchedLibraryDescriptor* MTL::StitchedLibraryDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStitchedLibraryDescriptor)); +} + +// method: init +_MTL_INLINE MTL::StitchedLibraryDescriptor* MTL::StitchedLibraryDescriptor::init() +{ + return NS::Object::init(); +} + +// property: functionGraphs +_MTL_INLINE NS::Array* MTL::StitchedLibraryDescriptor::functionGraphs() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionGraphs)); +} + +_MTL_INLINE void MTL::StitchedLibraryDescriptor::setFunctionGraphs(const NS::Array* functionGraphs) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionGraphs_), functionGraphs); +} + +// property: functions +_MTL_INLINE NS::Array* MTL::StitchedLibraryDescriptor::functions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functions)); +} + +_MTL_INLINE void MTL::StitchedLibraryDescriptor::setFunctions(const NS::Array* functions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_), functions); +} diff --git a/vendor/metal-cpp/Metal/MTLHeaderBridge.hpp b/vendor/metal-cpp/Metal/MTLHeaderBridge.hpp new file mode 100644 index 000000000..ac2866fc3 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLHeaderBridge.hpp @@ -0,0 +1,2300 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLHeaderBridge.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once +#include "MTLPrivate.hpp" + +namespace MTL::Private::Class +{ + +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureBoundingBoxGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureMotionTriangleGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructurePassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureTriangleGeometryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLArgument); +_MTL_PRIVATE_DEF_CLS(MTLArgumentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLArrayType); +_MTL_PRIVATE_DEF_CLS(MTLAttribute); +_MTL_PRIVATE_DEF_CLS(MTLAttributeDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLAttributeDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLBinaryArchiveDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBlitPassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBlitPassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBlitPassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLBufferLayoutDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLBufferLayoutDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLCaptureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLCaptureManager); +_MTL_PRIVATE_DEF_CLS(MTLCommandBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLCompileOptions); +_MTL_PRIVATE_DEF_CLS(MTLComputePassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLComputePassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLComputePassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLComputePipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLComputePipelineReflection); +_MTL_PRIVATE_DEF_CLS(MTLCounterSampleBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLDepthStencilDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLFunctionConstant); +_MTL_PRIVATE_DEF_CLS(MTLFunctionConstantValues); +_MTL_PRIVATE_DEF_CLS(MTLFunctionDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingAttributeAlwaysInline); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingFunctionNode); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingGraph); +_MTL_PRIVATE_DEF_CLS(MTLFunctionStitchingInputNode); +_MTL_PRIVATE_DEF_CLS(MTLHeapDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIOCommandQueueDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIndirectCommandBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLInstanceAccelerationStructureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIntersectionFunctionDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLIntersectionFunctionTableDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLLinkedFunctions); +_MTL_PRIVATE_DEF_CLS(MTLMeshRenderPipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLMotionKeyframeData); +_MTL_PRIVATE_DEF_CLS(MTLPipelineBufferDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLPipelineBufferDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLPointerType); +_MTL_PRIVATE_DEF_CLS(MTLPrimitiveAccelerationStructureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateLayerArray); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateLayerDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateMapDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRasterizationRateSampleArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassColorAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassColorAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassDepthAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPassStencilAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineColorAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineColorAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineFunctionsDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLRenderPipelineReflection); +_MTL_PRIVATE_DEF_CLS(MTLResourceStatePassDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLSamplerDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLSharedEventHandle); +_MTL_PRIVATE_DEF_CLS(MTLSharedEventListener); +_MTL_PRIVATE_DEF_CLS(MTLSharedTextureHandle); +_MTL_PRIVATE_DEF_CLS(MTLStageInputOutputDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLStencilDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLStitchedLibraryDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLStructMember); +_MTL_PRIVATE_DEF_CLS(MTLStructType); +_MTL_PRIVATE_DEF_CLS(MTLTextureDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLTextureReferenceType); +_MTL_PRIVATE_DEF_CLS(MTLTileRenderPipelineColorAttachmentDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLTileRenderPipelineColorAttachmentDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLTileRenderPipelineDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLType); +_MTL_PRIVATE_DEF_CLS(MTLVertexAttribute); +_MTL_PRIVATE_DEF_CLS(MTLVertexAttributeDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLVertexAttributeDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLVertexBufferLayoutDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLVertexBufferLayoutDescriptorArray); +_MTL_PRIVATE_DEF_CLS(MTLVertexDescriptor); +_MTL_PRIVATE_DEF_CLS(MTLVisibleFunctionTableDescriptor); + +} + +namespace MTL::Private::Protocol +{ + +_MTL_PRIVATE_DEF_PRO(MTLAccelerationStructure); +_MTL_PRIVATE_DEF_PRO(MTLAccelerationStructureCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLArgumentEncoder); +_MTL_PRIVATE_DEF_PRO(MTLBinaryArchive); +_MTL_PRIVATE_DEF_PRO(MTLBinding); +_MTL_PRIVATE_DEF_PRO(MTLBlitCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLBuffer); +_MTL_PRIVATE_DEF_PRO(MTLBufferBinding); +_MTL_PRIVATE_DEF_PRO(MTLCommandBuffer); +_MTL_PRIVATE_DEF_PRO(MTLCommandBufferEncoderInfo); +_MTL_PRIVATE_DEF_PRO(MTLCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLCommandQueue); +_MTL_PRIVATE_DEF_PRO(MTLComputeCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLComputePipelineState); +_MTL_PRIVATE_DEF_PRO(MTLCounter); +_MTL_PRIVATE_DEF_PRO(MTLCounterSampleBuffer); +_MTL_PRIVATE_DEF_PRO(MTLCounterSet); +_MTL_PRIVATE_DEF_PRO(MTLDepthStencilState); +_MTL_PRIVATE_DEF_PRO(MTLDevice); +_MTL_PRIVATE_DEF_PRO(MTLDrawable); +_MTL_PRIVATE_DEF_PRO(MTLDynamicLibrary); +_MTL_PRIVATE_DEF_PRO(MTLEvent); +_MTL_PRIVATE_DEF_PRO(MTLFence); +_MTL_PRIVATE_DEF_PRO(MTLFunction); +_MTL_PRIVATE_DEF_PRO(MTLFunctionHandle); +_MTL_PRIVATE_DEF_PRO(MTLFunctionLog); +_MTL_PRIVATE_DEF_PRO(MTLFunctionLogDebugLocation); +_MTL_PRIVATE_DEF_PRO(MTLFunctionStitchingAttribute); +_MTL_PRIVATE_DEF_PRO(MTLFunctionStitchingNode); +_MTL_PRIVATE_DEF_PRO(MTLHeap); +_MTL_PRIVATE_DEF_PRO(MTLIOCommandBuffer); +_MTL_PRIVATE_DEF_PRO(MTLIOCommandQueue); +_MTL_PRIVATE_DEF_PRO(MTLIOFileHandle); +_MTL_PRIVATE_DEF_PRO(MTLIOScratchBuffer); +_MTL_PRIVATE_DEF_PRO(MTLIOScratchBufferAllocator); +_MTL_PRIVATE_DEF_PRO(MTLIndirectCommandBuffer); +_MTL_PRIVATE_DEF_PRO(MTLIndirectComputeCommand); +_MTL_PRIVATE_DEF_PRO(MTLIndirectRenderCommand); +_MTL_PRIVATE_DEF_PRO(MTLIntersectionFunctionTable); +_MTL_PRIVATE_DEF_PRO(MTLLibrary); +_MTL_PRIVATE_DEF_PRO(MTLLogContainer); +_MTL_PRIVATE_DEF_PRO(MTLObjectPayloadBinding); +_MTL_PRIVATE_DEF_PRO(MTLParallelRenderCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLRasterizationRateMap); +_MTL_PRIVATE_DEF_PRO(MTLRenderCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLRenderPipelineState); +_MTL_PRIVATE_DEF_PRO(MTLResource); +_MTL_PRIVATE_DEF_PRO(MTLResourceStateCommandEncoder); +_MTL_PRIVATE_DEF_PRO(MTLSamplerState); +_MTL_PRIVATE_DEF_PRO(MTLSharedEvent); +_MTL_PRIVATE_DEF_PRO(MTLTexture); +_MTL_PRIVATE_DEF_PRO(MTLTextureBinding); +_MTL_PRIVATE_DEF_PRO(MTLThreadgroupBinding); +_MTL_PRIVATE_DEF_PRO(MTLVisibleFunctionTable); + +} + +namespace MTL::Private::Selector +{ + +_MTL_PRIVATE_DEF_SEL(GPUEndTime, + "GPUEndTime"); +_MTL_PRIVATE_DEF_SEL(GPUStartTime, + "GPUStartTime"); +_MTL_PRIVATE_DEF_SEL(URL, + "URL"); +_MTL_PRIVATE_DEF_SEL(accelerationStructureCommandEncoder, + "accelerationStructureCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(accelerationStructureCommandEncoderWithDescriptor_, + "accelerationStructureCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(accelerationStructurePassDescriptor, + "accelerationStructurePassDescriptor"); +_MTL_PRIVATE_DEF_SEL(accelerationStructureSizesWithDescriptor_, + "accelerationStructureSizesWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(access, + "access"); +_MTL_PRIVATE_DEF_SEL(addBarrier, + "addBarrier"); +_MTL_PRIVATE_DEF_SEL(addCompletedHandler_, + "addCompletedHandler:"); +_MTL_PRIVATE_DEF_SEL(addComputePipelineFunctionsWithDescriptor_error_, + "addComputePipelineFunctionsWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(addDebugMarker_range_, + "addDebugMarker:range:"); +_MTL_PRIVATE_DEF_SEL(addFunctionWithDescriptor_library_error_, + "addFunctionWithDescriptor:library:error:"); +_MTL_PRIVATE_DEF_SEL(addPresentedHandler_, + "addPresentedHandler:"); +_MTL_PRIVATE_DEF_SEL(addRenderPipelineFunctionsWithDescriptor_error_, + "addRenderPipelineFunctionsWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(addScheduledHandler_, + "addScheduledHandler:"); +_MTL_PRIVATE_DEF_SEL(addTileRenderPipelineFunctionsWithDescriptor_error_, + "addTileRenderPipelineFunctionsWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(alignment, + "alignment"); +_MTL_PRIVATE_DEF_SEL(allocatedSize, + "allocatedSize"); +_MTL_PRIVATE_DEF_SEL(allowDuplicateIntersectionFunctionInvocation, + "allowDuplicateIntersectionFunctionInvocation"); +_MTL_PRIVATE_DEF_SEL(allowGPUOptimizedContents, + "allowGPUOptimizedContents"); +_MTL_PRIVATE_DEF_SEL(allowReferencingUndefinedSymbols, + "allowReferencingUndefinedSymbols"); +_MTL_PRIVATE_DEF_SEL(alphaBlendOperation, + "alphaBlendOperation"); +_MTL_PRIVATE_DEF_SEL(areBarycentricCoordsSupported, + "areBarycentricCoordsSupported"); +_MTL_PRIVATE_DEF_SEL(areProgrammableSamplePositionsSupported, + "areProgrammableSamplePositionsSupported"); +_MTL_PRIVATE_DEF_SEL(areRasterOrderGroupsSupported, + "areRasterOrderGroupsSupported"); +_MTL_PRIVATE_DEF_SEL(argumentBuffersSupport, + "argumentBuffersSupport"); +_MTL_PRIVATE_DEF_SEL(argumentDescriptor, + "argumentDescriptor"); +_MTL_PRIVATE_DEF_SEL(argumentIndex, + "argumentIndex"); +_MTL_PRIVATE_DEF_SEL(argumentIndexStride, + "argumentIndexStride"); +_MTL_PRIVATE_DEF_SEL(arguments, + "arguments"); +_MTL_PRIVATE_DEF_SEL(arrayLength, + "arrayLength"); +_MTL_PRIVATE_DEF_SEL(arrayType, + "arrayType"); +_MTL_PRIVATE_DEF_SEL(attributeIndex, + "attributeIndex"); +_MTL_PRIVATE_DEF_SEL(attributeType, + "attributeType"); +_MTL_PRIVATE_DEF_SEL(attributes, + "attributes"); +_MTL_PRIVATE_DEF_SEL(backFaceStencil, + "backFaceStencil"); +_MTL_PRIVATE_DEF_SEL(binaryArchives, + "binaryArchives"); +_MTL_PRIVATE_DEF_SEL(binaryFunctions, + "binaryFunctions"); +_MTL_PRIVATE_DEF_SEL(bindings, + "bindings"); +_MTL_PRIVATE_DEF_SEL(blitCommandEncoder, + "blitCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(blitCommandEncoderWithDescriptor_, + "blitCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(blitPassDescriptor, + "blitPassDescriptor"); +_MTL_PRIVATE_DEF_SEL(borderColor, + "borderColor"); +_MTL_PRIVATE_DEF_SEL(boundingBoxBuffer, + "boundingBoxBuffer"); +_MTL_PRIVATE_DEF_SEL(boundingBoxBufferOffset, + "boundingBoxBufferOffset"); +_MTL_PRIVATE_DEF_SEL(boundingBoxBuffers, + "boundingBoxBuffers"); +_MTL_PRIVATE_DEF_SEL(boundingBoxCount, + "boundingBoxCount"); +_MTL_PRIVATE_DEF_SEL(boundingBoxStride, + "boundingBoxStride"); +_MTL_PRIVATE_DEF_SEL(buffer, + "buffer"); +_MTL_PRIVATE_DEF_SEL(bufferAlignment, + "bufferAlignment"); +_MTL_PRIVATE_DEF_SEL(bufferBytesPerRow, + "bufferBytesPerRow"); +_MTL_PRIVATE_DEF_SEL(bufferDataSize, + "bufferDataSize"); +_MTL_PRIVATE_DEF_SEL(bufferDataType, + "bufferDataType"); +_MTL_PRIVATE_DEF_SEL(bufferIndex, + "bufferIndex"); +_MTL_PRIVATE_DEF_SEL(bufferOffset, + "bufferOffset"); +_MTL_PRIVATE_DEF_SEL(bufferPointerType, + "bufferPointerType"); +_MTL_PRIVATE_DEF_SEL(bufferStructType, + "bufferStructType"); +_MTL_PRIVATE_DEF_SEL(buffers, + "buffers"); +_MTL_PRIVATE_DEF_SEL(buildAccelerationStructure_descriptor_scratchBuffer_scratchBufferOffset_, + "buildAccelerationStructure:descriptor:scratchBuffer:scratchBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(captureObject, + "captureObject"); +_MTL_PRIVATE_DEF_SEL(clearBarrier, + "clearBarrier"); +_MTL_PRIVATE_DEF_SEL(clearColor, + "clearColor"); +_MTL_PRIVATE_DEF_SEL(clearDepth, + "clearDepth"); +_MTL_PRIVATE_DEF_SEL(clearStencil, + "clearStencil"); +_MTL_PRIVATE_DEF_SEL(colorAttachments, + "colorAttachments"); +_MTL_PRIVATE_DEF_SEL(column, + "column"); +_MTL_PRIVATE_DEF_SEL(commandBuffer, + "commandBuffer"); +_MTL_PRIVATE_DEF_SEL(commandBufferWithDescriptor_, + "commandBufferWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(commandBufferWithUnretainedReferences, + "commandBufferWithUnretainedReferences"); +_MTL_PRIVATE_DEF_SEL(commandQueue, + "commandQueue"); +_MTL_PRIVATE_DEF_SEL(commandTypes, + "commandTypes"); +_MTL_PRIVATE_DEF_SEL(commit, + "commit"); +_MTL_PRIVATE_DEF_SEL(compareFunction, + "compareFunction"); +_MTL_PRIVATE_DEF_SEL(compileSymbolVisibility, + "compileSymbolVisibility"); +_MTL_PRIVATE_DEF_SEL(compressionType, + "compressionType"); +_MTL_PRIVATE_DEF_SEL(computeCommandEncoder, + "computeCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(computeCommandEncoderWithDescriptor_, + "computeCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(computeCommandEncoderWithDispatchType_, + "computeCommandEncoderWithDispatchType:"); +_MTL_PRIVATE_DEF_SEL(computeFunction, + "computeFunction"); +_MTL_PRIVATE_DEF_SEL(computePassDescriptor, + "computePassDescriptor"); +_MTL_PRIVATE_DEF_SEL(concurrentDispatchThreadgroups_threadsPerThreadgroup_, + "concurrentDispatchThreadgroups:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(concurrentDispatchThreads_threadsPerThreadgroup_, + "concurrentDispatchThreads:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(constantBlockAlignment, + "constantBlockAlignment"); +_MTL_PRIVATE_DEF_SEL(constantDataAtIndex_, + "constantDataAtIndex:"); +_MTL_PRIVATE_DEF_SEL(constantValues, + "constantValues"); +_MTL_PRIVATE_DEF_SEL(contents, + "contents"); +_MTL_PRIVATE_DEF_SEL(controlDependencies, + "controlDependencies"); +_MTL_PRIVATE_DEF_SEL(convertSparsePixelRegions_toTileRegions_withTileSize_alignmentMode_numRegions_, + "convertSparsePixelRegions:toTileRegions:withTileSize:alignmentMode:numRegions:"); +_MTL_PRIVATE_DEF_SEL(convertSparseTileRegions_toPixelRegions_withTileSize_numRegions_, + "convertSparseTileRegions:toPixelRegions:withTileSize:numRegions:"); +_MTL_PRIVATE_DEF_SEL(copyAccelerationStructure_toAccelerationStructure_, + "copyAccelerationStructure:toAccelerationStructure:"); +_MTL_PRIVATE_DEF_SEL(copyAndCompactAccelerationStructure_toAccelerationStructure_, + "copyAndCompactAccelerationStructure:toAccelerationStructure:"); +_MTL_PRIVATE_DEF_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_, + "copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:"); +_MTL_PRIVATE_DEF_SEL(copyFromBuffer_sourceOffset_sourceBytesPerRow_sourceBytesPerImage_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_options_, + "copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:"); +_MTL_PRIVATE_DEF_SEL(copyFromBuffer_sourceOffset_toBuffer_destinationOffset_size_, + "copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_, + "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toBuffer_destinationOffset_destinationBytesPerRow_destinationBytesPerImage_options_, + "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_, + "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_sourceSlice_sourceLevel_toTexture_destinationSlice_destinationLevel_sliceCount_levelCount_, + "copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:"); +_MTL_PRIVATE_DEF_SEL(copyFromTexture_toTexture_, + "copyFromTexture:toTexture:"); +_MTL_PRIVATE_DEF_SEL(copyIndirectCommandBuffer_sourceRange_destination_destinationIndex_, + "copyIndirectCommandBuffer:sourceRange:destination:destinationIndex:"); +_MTL_PRIVATE_DEF_SEL(copyParameterDataToBuffer_offset_, + "copyParameterDataToBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(copyStatusToBuffer_offset_, + "copyStatusToBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(counterSet, + "counterSet"); +_MTL_PRIVATE_DEF_SEL(counterSets, + "counterSets"); +_MTL_PRIVATE_DEF_SEL(counters, + "counters"); +_MTL_PRIVATE_DEF_SEL(cpuCacheMode, + "cpuCacheMode"); +_MTL_PRIVATE_DEF_SEL(currentAllocatedSize, + "currentAllocatedSize"); +_MTL_PRIVATE_DEF_SEL(data, + "data"); +_MTL_PRIVATE_DEF_SEL(dataSize, + "dataSize"); +_MTL_PRIVATE_DEF_SEL(dataType, + "dataType"); +_MTL_PRIVATE_DEF_SEL(dealloc, + "dealloc"); +_MTL_PRIVATE_DEF_SEL(debugLocation, + "debugLocation"); +_MTL_PRIVATE_DEF_SEL(debugSignposts, + "debugSignposts"); +_MTL_PRIVATE_DEF_SEL(defaultCaptureScope, + "defaultCaptureScope"); +_MTL_PRIVATE_DEF_SEL(defaultRasterSampleCount, + "defaultRasterSampleCount"); +_MTL_PRIVATE_DEF_SEL(depth, + "depth"); +_MTL_PRIVATE_DEF_SEL(depthAttachment, + "depthAttachment"); +_MTL_PRIVATE_DEF_SEL(depthAttachmentPixelFormat, + "depthAttachmentPixelFormat"); +_MTL_PRIVATE_DEF_SEL(depthCompareFunction, + "depthCompareFunction"); +_MTL_PRIVATE_DEF_SEL(depthFailureOperation, + "depthFailureOperation"); +_MTL_PRIVATE_DEF_SEL(depthPlane, + "depthPlane"); +_MTL_PRIVATE_DEF_SEL(depthResolveFilter, + "depthResolveFilter"); +_MTL_PRIVATE_DEF_SEL(depthStencilPassOperation, + "depthStencilPassOperation"); +_MTL_PRIVATE_DEF_SEL(descriptor, + "descriptor"); +_MTL_PRIVATE_DEF_SEL(destination, + "destination"); +_MTL_PRIVATE_DEF_SEL(destinationAlphaBlendFactor, + "destinationAlphaBlendFactor"); +_MTL_PRIVATE_DEF_SEL(destinationRGBBlendFactor, + "destinationRGBBlendFactor"); +_MTL_PRIVATE_DEF_SEL(device, + "device"); +_MTL_PRIVATE_DEF_SEL(didModifyRange_, + "didModifyRange:"); +_MTL_PRIVATE_DEF_SEL(dispatchQueue, + "dispatchQueue"); +_MTL_PRIVATE_DEF_SEL(dispatchThreadgroups_threadsPerThreadgroup_, + "dispatchThreadgroups:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(dispatchThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerThreadgroup_, + "dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(dispatchThreads_threadsPerThreadgroup_, + "dispatchThreads:threadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(dispatchThreadsPerTile_, + "dispatchThreadsPerTile:"); +_MTL_PRIVATE_DEF_SEL(dispatchType, + "dispatchType"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPatches_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_indirectBuffer_indirectBufferOffset_, + "drawIndexedPatches:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_, + "drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_, + "drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_, + "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_, + "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance_, + "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawIndexedPrimitives_indexType_indexBuffer_indexBufferOffset_indirectBuffer_indirectBufferOffset_, + "drawIndexedPrimitives:indexType:indexBuffer:indexBufferOffset:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawMeshThreadgroups_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_, + "drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(drawMeshThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_, + "drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(drawMeshThreads_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_, + "drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(drawPatches_patchIndexBuffer_patchIndexBufferOffset_indirectBuffer_indirectBufferOffset_, + "drawPatches:patchIndexBuffer:patchIndexBufferOffset:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_, + "drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_, + "drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_indirectBuffer_indirectBufferOffset_, + "drawPrimitives:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_vertexStart_vertexCount_, + "drawPrimitives:vertexStart:vertexCount:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_, + "drawPrimitives:vertexStart:vertexCount:instanceCount:"); +_MTL_PRIVATE_DEF_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance_, + "drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:"); +_MTL_PRIVATE_DEF_SEL(drawableID, + "drawableID"); +_MTL_PRIVATE_DEF_SEL(elementArrayType, + "elementArrayType"); +_MTL_PRIVATE_DEF_SEL(elementIsArgumentBuffer, + "elementIsArgumentBuffer"); +_MTL_PRIVATE_DEF_SEL(elementPointerType, + "elementPointerType"); +_MTL_PRIVATE_DEF_SEL(elementStructType, + "elementStructType"); +_MTL_PRIVATE_DEF_SEL(elementTextureReferenceType, + "elementTextureReferenceType"); +_MTL_PRIVATE_DEF_SEL(elementType, + "elementType"); +_MTL_PRIVATE_DEF_SEL(encodeSignalEvent_value_, + "encodeSignalEvent:value:"); +_MTL_PRIVATE_DEF_SEL(encodeWaitForEvent_value_, + "encodeWaitForEvent:value:"); +_MTL_PRIVATE_DEF_SEL(encodedLength, + "encodedLength"); +_MTL_PRIVATE_DEF_SEL(encoderLabel, + "encoderLabel"); +_MTL_PRIVATE_DEF_SEL(endEncoding, + "endEncoding"); +_MTL_PRIVATE_DEF_SEL(endOfEncoderSampleIndex, + "endOfEncoderSampleIndex"); +_MTL_PRIVATE_DEF_SEL(endOfFragmentSampleIndex, + "endOfFragmentSampleIndex"); +_MTL_PRIVATE_DEF_SEL(endOfVertexSampleIndex, + "endOfVertexSampleIndex"); +_MTL_PRIVATE_DEF_SEL(enqueue, + "enqueue"); +_MTL_PRIVATE_DEF_SEL(enqueueBarrier, + "enqueueBarrier"); +_MTL_PRIVATE_DEF_SEL(error, + "error"); +_MTL_PRIVATE_DEF_SEL(errorOptions, + "errorOptions"); +_MTL_PRIVATE_DEF_SEL(errorState, + "errorState"); +_MTL_PRIVATE_DEF_SEL(executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_, + "executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(executeCommandsInBuffer_withRange_, + "executeCommandsInBuffer:withRange:"); +_MTL_PRIVATE_DEF_SEL(fastMathEnabled, + "fastMathEnabled"); +_MTL_PRIVATE_DEF_SEL(fillBuffer_range_value_, + "fillBuffer:range:value:"); +_MTL_PRIVATE_DEF_SEL(firstMipmapInTail, + "firstMipmapInTail"); +_MTL_PRIVATE_DEF_SEL(format, + "format"); +_MTL_PRIVATE_DEF_SEL(fragmentAdditionalBinaryFunctions, + "fragmentAdditionalBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(fragmentArguments, + "fragmentArguments"); +_MTL_PRIVATE_DEF_SEL(fragmentBindings, + "fragmentBindings"); +_MTL_PRIVATE_DEF_SEL(fragmentBuffers, + "fragmentBuffers"); +_MTL_PRIVATE_DEF_SEL(fragmentFunction, + "fragmentFunction"); +_MTL_PRIVATE_DEF_SEL(fragmentLinkedFunctions, + "fragmentLinkedFunctions"); +_MTL_PRIVATE_DEF_SEL(fragmentPreloadedLibraries, + "fragmentPreloadedLibraries"); +_MTL_PRIVATE_DEF_SEL(frontFaceStencil, + "frontFaceStencil"); +_MTL_PRIVATE_DEF_SEL(function, + "function"); +_MTL_PRIVATE_DEF_SEL(functionConstantsDictionary, + "functionConstantsDictionary"); +_MTL_PRIVATE_DEF_SEL(functionCount, + "functionCount"); +_MTL_PRIVATE_DEF_SEL(functionDescriptor, + "functionDescriptor"); +_MTL_PRIVATE_DEF_SEL(functionGraphs, + "functionGraphs"); +_MTL_PRIVATE_DEF_SEL(functionHandleWithFunction_, + "functionHandleWithFunction:"); +_MTL_PRIVATE_DEF_SEL(functionHandleWithFunction_stage_, + "functionHandleWithFunction:stage:"); +_MTL_PRIVATE_DEF_SEL(functionName, + "functionName"); +_MTL_PRIVATE_DEF_SEL(functionNames, + "functionNames"); +_MTL_PRIVATE_DEF_SEL(functionType, + "functionType"); +_MTL_PRIVATE_DEF_SEL(functions, + "functions"); +_MTL_PRIVATE_DEF_SEL(generateMipmapsForTexture_, + "generateMipmapsForTexture:"); +_MTL_PRIVATE_DEF_SEL(geometryDescriptors, + "geometryDescriptors"); +_MTL_PRIVATE_DEF_SEL(getBytes_bytesPerRow_bytesPerImage_fromRegion_mipmapLevel_slice_, + "getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice:"); +_MTL_PRIVATE_DEF_SEL(getBytes_bytesPerRow_fromRegion_mipmapLevel_, + "getBytes:bytesPerRow:fromRegion:mipmapLevel:"); +_MTL_PRIVATE_DEF_SEL(getDefaultSamplePositions_count_, + "getDefaultSamplePositions:count:"); +_MTL_PRIVATE_DEF_SEL(getSamplePositions_count_, + "getSamplePositions:count:"); +_MTL_PRIVATE_DEF_SEL(getTextureAccessCounters_region_mipLevel_slice_resetCounters_countersBuffer_countersBufferOffset_, + "getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(gpuAddress, + "gpuAddress"); +_MTL_PRIVATE_DEF_SEL(gpuResourceID, + "gpuResourceID"); +_MTL_PRIVATE_DEF_SEL(groups, + "groups"); +_MTL_PRIVATE_DEF_SEL(hasUnifiedMemory, + "hasUnifiedMemory"); +_MTL_PRIVATE_DEF_SEL(hazardTrackingMode, + "hazardTrackingMode"); +_MTL_PRIVATE_DEF_SEL(heap, + "heap"); +_MTL_PRIVATE_DEF_SEL(heapAccelerationStructureSizeAndAlignWithDescriptor_, + "heapAccelerationStructureSizeAndAlignWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(heapAccelerationStructureSizeAndAlignWithSize_, + "heapAccelerationStructureSizeAndAlignWithSize:"); +_MTL_PRIVATE_DEF_SEL(heapBufferSizeAndAlignWithLength_options_, + "heapBufferSizeAndAlignWithLength:options:"); +_MTL_PRIVATE_DEF_SEL(heapOffset, + "heapOffset"); +_MTL_PRIVATE_DEF_SEL(heapTextureSizeAndAlignWithDescriptor_, + "heapTextureSizeAndAlignWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(height, + "height"); +_MTL_PRIVATE_DEF_SEL(horizontal, + "horizontal"); +_MTL_PRIVATE_DEF_SEL(horizontalSampleStorage, + "horizontalSampleStorage"); +_MTL_PRIVATE_DEF_SEL(imageblockMemoryLengthForDimensions_, + "imageblockMemoryLengthForDimensions:"); +_MTL_PRIVATE_DEF_SEL(imageblockSampleLength, + "imageblockSampleLength"); +_MTL_PRIVATE_DEF_SEL(index, + "index"); +_MTL_PRIVATE_DEF_SEL(indexBuffer, + "indexBuffer"); +_MTL_PRIVATE_DEF_SEL(indexBufferIndex, + "indexBufferIndex"); +_MTL_PRIVATE_DEF_SEL(indexBufferOffset, + "indexBufferOffset"); +_MTL_PRIVATE_DEF_SEL(indexType, + "indexType"); +_MTL_PRIVATE_DEF_SEL(indirectComputeCommandAtIndex_, + "indirectComputeCommandAtIndex:"); +_MTL_PRIVATE_DEF_SEL(indirectRenderCommandAtIndex_, + "indirectRenderCommandAtIndex:"); +_MTL_PRIVATE_DEF_SEL(inheritBuffers, + "inheritBuffers"); +_MTL_PRIVATE_DEF_SEL(inheritPipelineState, + "inheritPipelineState"); +_MTL_PRIVATE_DEF_SEL(init, + "init"); +_MTL_PRIVATE_DEF_SEL(initWithArgumentIndex_, + "initWithArgumentIndex:"); +_MTL_PRIVATE_DEF_SEL(initWithDispatchQueue_, + "initWithDispatchQueue:"); +_MTL_PRIVATE_DEF_SEL(initWithFunctionName_nodes_outputNode_attributes_, + "initWithFunctionName:nodes:outputNode:attributes:"); +_MTL_PRIVATE_DEF_SEL(initWithName_arguments_controlDependencies_, + "initWithName:arguments:controlDependencies:"); +_MTL_PRIVATE_DEF_SEL(initWithSampleCount_, + "initWithSampleCount:"); +_MTL_PRIVATE_DEF_SEL(initWithSampleCount_horizontal_vertical_, + "initWithSampleCount:horizontal:vertical:"); +_MTL_PRIVATE_DEF_SEL(inputPrimitiveTopology, + "inputPrimitiveTopology"); +_MTL_PRIVATE_DEF_SEL(insertDebugCaptureBoundary, + "insertDebugCaptureBoundary"); +_MTL_PRIVATE_DEF_SEL(insertDebugSignpost_, + "insertDebugSignpost:"); +_MTL_PRIVATE_DEF_SEL(insertLibraries, + "insertLibraries"); +_MTL_PRIVATE_DEF_SEL(installName, + "installName"); +_MTL_PRIVATE_DEF_SEL(instanceCount, + "instanceCount"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorBuffer, + "instanceDescriptorBuffer"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorBufferOffset, + "instanceDescriptorBufferOffset"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorStride, + "instanceDescriptorStride"); +_MTL_PRIVATE_DEF_SEL(instanceDescriptorType, + "instanceDescriptorType"); +_MTL_PRIVATE_DEF_SEL(instancedAccelerationStructures, + "instancedAccelerationStructures"); +_MTL_PRIVATE_DEF_SEL(intersectionFunctionTableDescriptor, + "intersectionFunctionTableDescriptor"); +_MTL_PRIVATE_DEF_SEL(intersectionFunctionTableOffset, + "intersectionFunctionTableOffset"); +_MTL_PRIVATE_DEF_SEL(iosurface, + "iosurface"); +_MTL_PRIVATE_DEF_SEL(iosurfacePlane, + "iosurfacePlane"); +_MTL_PRIVATE_DEF_SEL(isActive, + "isActive"); +_MTL_PRIVATE_DEF_SEL(isAliasable, + "isAliasable"); +_MTL_PRIVATE_DEF_SEL(isAlphaToCoverageEnabled, + "isAlphaToCoverageEnabled"); +_MTL_PRIVATE_DEF_SEL(isAlphaToOneEnabled, + "isAlphaToOneEnabled"); +_MTL_PRIVATE_DEF_SEL(isArgument, + "isArgument"); +_MTL_PRIVATE_DEF_SEL(isBlendingEnabled, + "isBlendingEnabled"); +_MTL_PRIVATE_DEF_SEL(isCapturing, + "isCapturing"); +_MTL_PRIVATE_DEF_SEL(isDepth24Stencil8PixelFormatSupported, + "isDepth24Stencil8PixelFormatSupported"); +_MTL_PRIVATE_DEF_SEL(isDepthTexture, + "isDepthTexture"); +_MTL_PRIVATE_DEF_SEL(isDepthWriteEnabled, + "isDepthWriteEnabled"); +_MTL_PRIVATE_DEF_SEL(isFramebufferOnly, + "isFramebufferOnly"); +_MTL_PRIVATE_DEF_SEL(isHeadless, + "isHeadless"); +_MTL_PRIVATE_DEF_SEL(isLowPower, + "isLowPower"); +_MTL_PRIVATE_DEF_SEL(isPatchControlPointData, + "isPatchControlPointData"); +_MTL_PRIVATE_DEF_SEL(isPatchData, + "isPatchData"); +_MTL_PRIVATE_DEF_SEL(isRasterizationEnabled, + "isRasterizationEnabled"); +_MTL_PRIVATE_DEF_SEL(isRemovable, + "isRemovable"); +_MTL_PRIVATE_DEF_SEL(isShareable, + "isShareable"); +_MTL_PRIVATE_DEF_SEL(isSparse, + "isSparse"); +_MTL_PRIVATE_DEF_SEL(isTessellationFactorScaleEnabled, + "isTessellationFactorScaleEnabled"); +_MTL_PRIVATE_DEF_SEL(isUsed, + "isUsed"); +_MTL_PRIVATE_DEF_SEL(kernelEndTime, + "kernelEndTime"); +_MTL_PRIVATE_DEF_SEL(kernelStartTime, + "kernelStartTime"); +_MTL_PRIVATE_DEF_SEL(label, + "label"); +_MTL_PRIVATE_DEF_SEL(languageVersion, + "languageVersion"); +_MTL_PRIVATE_DEF_SEL(layerAtIndex_, + "layerAtIndex:"); +_MTL_PRIVATE_DEF_SEL(layerCount, + "layerCount"); +_MTL_PRIVATE_DEF_SEL(layers, + "layers"); +_MTL_PRIVATE_DEF_SEL(layouts, + "layouts"); +_MTL_PRIVATE_DEF_SEL(length, + "length"); +_MTL_PRIVATE_DEF_SEL(level, + "level"); +_MTL_PRIVATE_DEF_SEL(libraries, + "libraries"); +_MTL_PRIVATE_DEF_SEL(libraryType, + "libraryType"); +_MTL_PRIVATE_DEF_SEL(line, + "line"); +_MTL_PRIVATE_DEF_SEL(linkedFunctions, + "linkedFunctions"); +_MTL_PRIVATE_DEF_SEL(loadAction, + "loadAction"); +_MTL_PRIVATE_DEF_SEL(loadBuffer_offset_size_sourceHandle_sourceHandleOffset_, + "loadBuffer:offset:size:sourceHandle:sourceHandleOffset:"); +_MTL_PRIVATE_DEF_SEL(loadBytes_size_sourceHandle_sourceHandleOffset_, + "loadBytes:size:sourceHandle:sourceHandleOffset:"); +_MTL_PRIVATE_DEF_SEL(loadTexture_slice_level_size_sourceBytesPerRow_sourceBytesPerImage_destinationOrigin_sourceHandle_sourceHandleOffset_, + "loadTexture:slice:level:size:sourceBytesPerRow:sourceBytesPerImage:destinationOrigin:sourceHandle:sourceHandleOffset:"); +_MTL_PRIVATE_DEF_SEL(location, + "location"); +_MTL_PRIVATE_DEF_SEL(locationNumber, + "locationNumber"); +_MTL_PRIVATE_DEF_SEL(lodAverage, + "lodAverage"); +_MTL_PRIVATE_DEF_SEL(lodMaxClamp, + "lodMaxClamp"); +_MTL_PRIVATE_DEF_SEL(lodMinClamp, + "lodMinClamp"); +_MTL_PRIVATE_DEF_SEL(logs, + "logs"); +_MTL_PRIVATE_DEF_SEL(magFilter, + "magFilter"); +_MTL_PRIVATE_DEF_SEL(makeAliasable, + "makeAliasable"); +_MTL_PRIVATE_DEF_SEL(mapPhysicalToScreenCoordinates_forLayer_, + "mapPhysicalToScreenCoordinates:forLayer:"); +_MTL_PRIVATE_DEF_SEL(mapScreenToPhysicalCoordinates_forLayer_, + "mapScreenToPhysicalCoordinates:forLayer:"); +_MTL_PRIVATE_DEF_SEL(maxAnisotropy, + "maxAnisotropy"); +_MTL_PRIVATE_DEF_SEL(maxArgumentBufferSamplerCount, + "maxArgumentBufferSamplerCount"); +_MTL_PRIVATE_DEF_SEL(maxAvailableSizeWithAlignment_, + "maxAvailableSizeWithAlignment:"); +_MTL_PRIVATE_DEF_SEL(maxBufferLength, + "maxBufferLength"); +_MTL_PRIVATE_DEF_SEL(maxCallStackDepth, + "maxCallStackDepth"); +_MTL_PRIVATE_DEF_SEL(maxCommandBufferCount, + "maxCommandBufferCount"); +_MTL_PRIVATE_DEF_SEL(maxCommandsInFlight, + "maxCommandsInFlight"); +_MTL_PRIVATE_DEF_SEL(maxFragmentBufferBindCount, + "maxFragmentBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxFragmentCallStackDepth, + "maxFragmentCallStackDepth"); +_MTL_PRIVATE_DEF_SEL(maxKernelBufferBindCount, + "maxKernelBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxSampleCount, + "maxSampleCount"); +_MTL_PRIVATE_DEF_SEL(maxTessellationFactor, + "maxTessellationFactor"); +_MTL_PRIVATE_DEF_SEL(maxThreadgroupMemoryLength, + "maxThreadgroupMemoryLength"); +_MTL_PRIVATE_DEF_SEL(maxThreadsPerThreadgroup, + "maxThreadsPerThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadgroupsPerMeshGrid, + "maxTotalThreadgroupsPerMeshGrid"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadsPerMeshThreadgroup, + "maxTotalThreadsPerMeshThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadsPerObjectThreadgroup, + "maxTotalThreadsPerObjectThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTotalThreadsPerThreadgroup, + "maxTotalThreadsPerThreadgroup"); +_MTL_PRIVATE_DEF_SEL(maxTransferRate, + "maxTransferRate"); +_MTL_PRIVATE_DEF_SEL(maxVertexAmplificationCount, + "maxVertexAmplificationCount"); +_MTL_PRIVATE_DEF_SEL(maxVertexBufferBindCount, + "maxVertexBufferBindCount"); +_MTL_PRIVATE_DEF_SEL(maxVertexCallStackDepth, + "maxVertexCallStackDepth"); +_MTL_PRIVATE_DEF_SEL(maximumConcurrentCompilationTaskCount, + "maximumConcurrentCompilationTaskCount"); +_MTL_PRIVATE_DEF_SEL(memberByName_, + "memberByName:"); +_MTL_PRIVATE_DEF_SEL(members, + "members"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithResources_count_, + "memoryBarrierWithResources:count:"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithResources_count_afterStages_beforeStages_, + "memoryBarrierWithResources:count:afterStages:beforeStages:"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithScope_, + "memoryBarrierWithScope:"); +_MTL_PRIVATE_DEF_SEL(memoryBarrierWithScope_afterStages_beforeStages_, + "memoryBarrierWithScope:afterStages:beforeStages:"); +_MTL_PRIVATE_DEF_SEL(meshBindings, + "meshBindings"); +_MTL_PRIVATE_DEF_SEL(meshBuffers, + "meshBuffers"); +_MTL_PRIVATE_DEF_SEL(meshFunction, + "meshFunction"); +_MTL_PRIVATE_DEF_SEL(meshThreadExecutionWidth, + "meshThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(meshThreadgroupSizeIsMultipleOfThreadExecutionWidth, + "meshThreadgroupSizeIsMultipleOfThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(minFilter, + "minFilter"); +_MTL_PRIVATE_DEF_SEL(minimumLinearTextureAlignmentForPixelFormat_, + "minimumLinearTextureAlignmentForPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(minimumTextureBufferAlignmentForPixelFormat_, + "minimumTextureBufferAlignmentForPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(mipFilter, + "mipFilter"); +_MTL_PRIVATE_DEF_SEL(mipmapLevelCount, + "mipmapLevelCount"); +_MTL_PRIVATE_DEF_SEL(motionEndBorderMode, + "motionEndBorderMode"); +_MTL_PRIVATE_DEF_SEL(motionEndTime, + "motionEndTime"); +_MTL_PRIVATE_DEF_SEL(motionKeyframeCount, + "motionKeyframeCount"); +_MTL_PRIVATE_DEF_SEL(motionStartBorderMode, + "motionStartBorderMode"); +_MTL_PRIVATE_DEF_SEL(motionStartTime, + "motionStartTime"); +_MTL_PRIVATE_DEF_SEL(motionTransformBuffer, + "motionTransformBuffer"); +_MTL_PRIVATE_DEF_SEL(motionTransformBufferOffset, + "motionTransformBufferOffset"); +_MTL_PRIVATE_DEF_SEL(motionTransformCount, + "motionTransformCount"); +_MTL_PRIVATE_DEF_SEL(moveTextureMappingsFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_, + "moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:"); +_MTL_PRIVATE_DEF_SEL(mutability, + "mutability"); +_MTL_PRIVATE_DEF_SEL(name, + "name"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithDescriptor_, + "newAccelerationStructureWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithDescriptor_offset_, + "newAccelerationStructureWithDescriptor:offset:"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithSize_, + "newAccelerationStructureWithSize:"); +_MTL_PRIVATE_DEF_SEL(newAccelerationStructureWithSize_offset_, + "newAccelerationStructureWithSize:offset:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderForBufferAtIndex_, + "newArgumentEncoderForBufferAtIndex:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithArguments_, + "newArgumentEncoderWithArguments:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithBufferBinding_, + "newArgumentEncoderWithBufferBinding:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithBufferIndex_, + "newArgumentEncoderWithBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(newArgumentEncoderWithBufferIndex_reflection_, + "newArgumentEncoderWithBufferIndex:reflection:"); +_MTL_PRIVATE_DEF_SEL(newBinaryArchiveWithDescriptor_error_, + "newBinaryArchiveWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithBytes_length_options_, + "newBufferWithBytes:length:options:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithBytesNoCopy_length_options_deallocator_, + "newBufferWithBytesNoCopy:length:options:deallocator:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithLength_options_, + "newBufferWithLength:options:"); +_MTL_PRIVATE_DEF_SEL(newBufferWithLength_options_offset_, + "newBufferWithLength:options:offset:"); +_MTL_PRIVATE_DEF_SEL(newCaptureScopeWithCommandQueue_, + "newCaptureScopeWithCommandQueue:"); +_MTL_PRIVATE_DEF_SEL(newCaptureScopeWithDevice_, + "newCaptureScopeWithDevice:"); +_MTL_PRIVATE_DEF_SEL(newCommandQueue, + "newCommandQueue"); +_MTL_PRIVATE_DEF_SEL(newCommandQueueWithMaxCommandBufferCount_, + "newCommandQueueWithMaxCommandBufferCount:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithAdditionalBinaryFunctions_error_, + "newComputePipelineStateWithAdditionalBinaryFunctions:error:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithDescriptor_options_completionHandler_, + "newComputePipelineStateWithDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithDescriptor_options_reflection_error_, + "newComputePipelineStateWithDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_completionHandler_, + "newComputePipelineStateWithFunction:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_error_, + "newComputePipelineStateWithFunction:error:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_options_completionHandler_, + "newComputePipelineStateWithFunction:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newComputePipelineStateWithFunction_options_reflection_error_, + "newComputePipelineStateWithFunction:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newCounterSampleBufferWithDescriptor_error_, + "newCounterSampleBufferWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newDefaultLibrary, + "newDefaultLibrary"); +_MTL_PRIVATE_DEF_SEL(newDefaultLibraryWithBundle_error_, + "newDefaultLibraryWithBundle:error:"); +_MTL_PRIVATE_DEF_SEL(newDepthStencilStateWithDescriptor_, + "newDepthStencilStateWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newDynamicLibrary_error_, + "newDynamicLibrary:error:"); +_MTL_PRIVATE_DEF_SEL(newDynamicLibraryWithURL_error_, + "newDynamicLibraryWithURL:error:"); +_MTL_PRIVATE_DEF_SEL(newEvent, + "newEvent"); +_MTL_PRIVATE_DEF_SEL(newFence, + "newFence"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithDescriptor_completionHandler_, + "newFunctionWithDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithDescriptor_error_, + "newFunctionWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithName_, + "newFunctionWithName:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithName_constantValues_completionHandler_, + "newFunctionWithName:constantValues:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newFunctionWithName_constantValues_error_, + "newFunctionWithName:constantValues:error:"); +_MTL_PRIVATE_DEF_SEL(newHeapWithDescriptor_, + "newHeapWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newIOCommandQueueWithDescriptor_error_, + "newIOCommandQueueWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newIOHandleWithURL_compressionMethod_error_, + "newIOHandleWithURL:compressionMethod:error:"); +_MTL_PRIVATE_DEF_SEL(newIOHandleWithURL_error_, + "newIOHandleWithURL:error:"); +_MTL_PRIVATE_DEF_SEL(newIndirectCommandBufferWithDescriptor_maxCommandCount_options_, + "newIndirectCommandBufferWithDescriptor:maxCommandCount:options:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionTableWithDescriptor_, + "newIntersectionFunctionTableWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionTableWithDescriptor_stage_, + "newIntersectionFunctionTableWithDescriptor:stage:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionWithDescriptor_completionHandler_, + "newIntersectionFunctionWithDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newIntersectionFunctionWithDescriptor_error_, + "newIntersectionFunctionWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithData_error_, + "newLibraryWithData:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithFile_error_, + "newLibraryWithFile:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithSource_options_completionHandler_, + "newLibraryWithSource:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithSource_options_error_, + "newLibraryWithSource:options:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithStitchedDescriptor_completionHandler_, + "newLibraryWithStitchedDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithStitchedDescriptor_error_, + "newLibraryWithStitchedDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newLibraryWithURL_error_, + "newLibraryWithURL:error:"); +_MTL_PRIVATE_DEF_SEL(newRasterizationRateMapWithDescriptor_, + "newRasterizationRateMapWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newRemoteBufferViewForDevice_, + "newRemoteBufferViewForDevice:"); +_MTL_PRIVATE_DEF_SEL(newRemoteTextureViewForDevice_, + "newRemoteTextureViewForDevice:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithAdditionalBinaryFunctions_error_, + "newRenderPipelineStateWithAdditionalBinaryFunctions:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_completionHandler_, + "newRenderPipelineStateWithDescriptor:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_error_, + "newRenderPipelineStateWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_options_completionHandler_, + "newRenderPipelineStateWithDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithDescriptor_options_reflection_error_, + "newRenderPipelineStateWithDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithMeshDescriptor_options_completionHandler_, + "newRenderPipelineStateWithMeshDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithMeshDescriptor_options_reflection_error_, + "newRenderPipelineStateWithMeshDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithTileDescriptor_options_completionHandler_, + "newRenderPipelineStateWithTileDescriptor:options:completionHandler:"); +_MTL_PRIVATE_DEF_SEL(newRenderPipelineStateWithTileDescriptor_options_reflection_error_, + "newRenderPipelineStateWithTileDescriptor:options:reflection:error:"); +_MTL_PRIVATE_DEF_SEL(newSamplerStateWithDescriptor_, + "newSamplerStateWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newScratchBufferWithMinimumSize_, + "newScratchBufferWithMinimumSize:"); +_MTL_PRIVATE_DEF_SEL(newSharedEvent, + "newSharedEvent"); +_MTL_PRIVATE_DEF_SEL(newSharedEventHandle, + "newSharedEventHandle"); +_MTL_PRIVATE_DEF_SEL(newSharedEventWithHandle_, + "newSharedEventWithHandle:"); +_MTL_PRIVATE_DEF_SEL(newSharedTextureHandle, + "newSharedTextureHandle"); +_MTL_PRIVATE_DEF_SEL(newSharedTextureWithDescriptor_, + "newSharedTextureWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newSharedTextureWithHandle_, + "newSharedTextureWithHandle:"); +_MTL_PRIVATE_DEF_SEL(newTextureViewWithPixelFormat_, + "newTextureViewWithPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_, + "newTextureViewWithPixelFormat:textureType:levels:slices:"); +_MTL_PRIVATE_DEF_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_swizzle_, + "newTextureViewWithPixelFormat:textureType:levels:slices:swizzle:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_, + "newTextureWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_iosurface_plane_, + "newTextureWithDescriptor:iosurface:plane:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_offset_, + "newTextureWithDescriptor:offset:"); +_MTL_PRIVATE_DEF_SEL(newTextureWithDescriptor_offset_bytesPerRow_, + "newTextureWithDescriptor:offset:bytesPerRow:"); +_MTL_PRIVATE_DEF_SEL(newVisibleFunctionTableWithDescriptor_, + "newVisibleFunctionTableWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(newVisibleFunctionTableWithDescriptor_stage_, + "newVisibleFunctionTableWithDescriptor:stage:"); +_MTL_PRIVATE_DEF_SEL(nodes, + "nodes"); +_MTL_PRIVATE_DEF_SEL(normalizedCoordinates, + "normalizedCoordinates"); +_MTL_PRIVATE_DEF_SEL(notifyListener_atValue_block_, + "notifyListener:atValue:block:"); +_MTL_PRIVATE_DEF_SEL(objectAtIndexedSubscript_, + "objectAtIndexedSubscript:"); +_MTL_PRIVATE_DEF_SEL(objectBindings, + "objectBindings"); +_MTL_PRIVATE_DEF_SEL(objectBuffers, + "objectBuffers"); +_MTL_PRIVATE_DEF_SEL(objectFunction, + "objectFunction"); +_MTL_PRIVATE_DEF_SEL(objectPayloadAlignment, + "objectPayloadAlignment"); +_MTL_PRIVATE_DEF_SEL(objectPayloadDataSize, + "objectPayloadDataSize"); +_MTL_PRIVATE_DEF_SEL(objectThreadExecutionWidth, + "objectThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(objectThreadgroupSizeIsMultipleOfThreadExecutionWidth, + "objectThreadgroupSizeIsMultipleOfThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(offset, + "offset"); +_MTL_PRIVATE_DEF_SEL(opaque, + "opaque"); +_MTL_PRIVATE_DEF_SEL(optimizationLevel, + "optimizationLevel"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForCPUAccess_, + "optimizeContentsForCPUAccess:"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForCPUAccess_slice_level_, + "optimizeContentsForCPUAccess:slice:level:"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForGPUAccess_, + "optimizeContentsForGPUAccess:"); +_MTL_PRIVATE_DEF_SEL(optimizeContentsForGPUAccess_slice_level_, + "optimizeContentsForGPUAccess:slice:level:"); +_MTL_PRIVATE_DEF_SEL(optimizeIndirectCommandBuffer_withRange_, + "optimizeIndirectCommandBuffer:withRange:"); +_MTL_PRIVATE_DEF_SEL(options, + "options"); +_MTL_PRIVATE_DEF_SEL(outputNode, + "outputNode"); +_MTL_PRIVATE_DEF_SEL(outputURL, + "outputURL"); +_MTL_PRIVATE_DEF_SEL(parallelRenderCommandEncoderWithDescriptor_, + "parallelRenderCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(parameterBufferSizeAndAlign, + "parameterBufferSizeAndAlign"); +_MTL_PRIVATE_DEF_SEL(parentRelativeLevel, + "parentRelativeLevel"); +_MTL_PRIVATE_DEF_SEL(parentRelativeSlice, + "parentRelativeSlice"); +_MTL_PRIVATE_DEF_SEL(parentTexture, + "parentTexture"); +_MTL_PRIVATE_DEF_SEL(patchControlPointCount, + "patchControlPointCount"); +_MTL_PRIVATE_DEF_SEL(patchType, + "patchType"); +_MTL_PRIVATE_DEF_SEL(payloadMemoryLength, + "payloadMemoryLength"); +_MTL_PRIVATE_DEF_SEL(peerCount, + "peerCount"); +_MTL_PRIVATE_DEF_SEL(peerGroupID, + "peerGroupID"); +_MTL_PRIVATE_DEF_SEL(peerIndex, + "peerIndex"); +_MTL_PRIVATE_DEF_SEL(physicalGranularity, + "physicalGranularity"); +_MTL_PRIVATE_DEF_SEL(physicalSizeForLayer_, + "physicalSizeForLayer:"); +_MTL_PRIVATE_DEF_SEL(pixelFormat, + "pixelFormat"); +_MTL_PRIVATE_DEF_SEL(pointerType, + "pointerType"); +_MTL_PRIVATE_DEF_SEL(popDebugGroup, + "popDebugGroup"); +_MTL_PRIVATE_DEF_SEL(preloadedLibraries, + "preloadedLibraries"); +_MTL_PRIVATE_DEF_SEL(preprocessorMacros, + "preprocessorMacros"); +_MTL_PRIVATE_DEF_SEL(present, + "present"); +_MTL_PRIVATE_DEF_SEL(presentAfterMinimumDuration_, + "presentAfterMinimumDuration:"); +_MTL_PRIVATE_DEF_SEL(presentAtTime_, + "presentAtTime:"); +_MTL_PRIVATE_DEF_SEL(presentDrawable_, + "presentDrawable:"); +_MTL_PRIVATE_DEF_SEL(presentDrawable_afterMinimumDuration_, + "presentDrawable:afterMinimumDuration:"); +_MTL_PRIVATE_DEF_SEL(presentDrawable_atTime_, + "presentDrawable:atTime:"); +_MTL_PRIVATE_DEF_SEL(presentedTime, + "presentedTime"); +_MTL_PRIVATE_DEF_SEL(preserveInvariance, + "preserveInvariance"); +_MTL_PRIVATE_DEF_SEL(primitiveDataBuffer, + "primitiveDataBuffer"); +_MTL_PRIVATE_DEF_SEL(primitiveDataBufferOffset, + "primitiveDataBufferOffset"); +_MTL_PRIVATE_DEF_SEL(primitiveDataElementSize, + "primitiveDataElementSize"); +_MTL_PRIVATE_DEF_SEL(primitiveDataStride, + "primitiveDataStride"); +_MTL_PRIVATE_DEF_SEL(priority, + "priority"); +_MTL_PRIVATE_DEF_SEL(privateFunctions, + "privateFunctions"); +_MTL_PRIVATE_DEF_SEL(pushDebugGroup_, + "pushDebugGroup:"); +_MTL_PRIVATE_DEF_SEL(rAddressMode, + "rAddressMode"); +_MTL_PRIVATE_DEF_SEL(rasterSampleCount, + "rasterSampleCount"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMap, + "rasterizationRateMap"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMapDescriptorWithScreenSize_, + "rasterizationRateMapDescriptorWithScreenSize:"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMapDescriptorWithScreenSize_layer_, + "rasterizationRateMapDescriptorWithScreenSize:layer:"); +_MTL_PRIVATE_DEF_SEL(rasterizationRateMapDescriptorWithScreenSize_layerCount_layers_, + "rasterizationRateMapDescriptorWithScreenSize:layerCount:layers:"); +_MTL_PRIVATE_DEF_SEL(readMask, + "readMask"); +_MTL_PRIVATE_DEF_SEL(readWriteTextureSupport, + "readWriteTextureSupport"); +_MTL_PRIVATE_DEF_SEL(recommendedMaxWorkingSetSize, + "recommendedMaxWorkingSetSize"); +_MTL_PRIVATE_DEF_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_, + "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(refitAccelerationStructure_descriptor_destination_scratchBuffer_scratchBufferOffset_options_, + "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:options:"); +_MTL_PRIVATE_DEF_SEL(registryID, + "registryID"); +_MTL_PRIVATE_DEF_SEL(remoteStorageBuffer, + "remoteStorageBuffer"); +_MTL_PRIVATE_DEF_SEL(remoteStorageTexture, + "remoteStorageTexture"); +_MTL_PRIVATE_DEF_SEL(removeAllDebugMarkers, + "removeAllDebugMarkers"); +_MTL_PRIVATE_DEF_SEL(renderCommandEncoder, + "renderCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(renderCommandEncoderWithDescriptor_, + "renderCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(renderPassDescriptor, + "renderPassDescriptor"); +_MTL_PRIVATE_DEF_SEL(renderTargetArrayLength, + "renderTargetArrayLength"); +_MTL_PRIVATE_DEF_SEL(renderTargetHeight, + "renderTargetHeight"); +_MTL_PRIVATE_DEF_SEL(renderTargetWidth, + "renderTargetWidth"); +_MTL_PRIVATE_DEF_SEL(replaceRegion_mipmapLevel_slice_withBytes_bytesPerRow_bytesPerImage_, + "replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:"); +_MTL_PRIVATE_DEF_SEL(replaceRegion_mipmapLevel_withBytes_bytesPerRow_, + "replaceRegion:mipmapLevel:withBytes:bytesPerRow:"); +_MTL_PRIVATE_DEF_SEL(required, + "required"); +_MTL_PRIVATE_DEF_SEL(reset, + "reset"); +_MTL_PRIVATE_DEF_SEL(resetCommandsInBuffer_withRange_, + "resetCommandsInBuffer:withRange:"); +_MTL_PRIVATE_DEF_SEL(resetTextureAccessCounters_region_mipLevel_slice_, + "resetTextureAccessCounters:region:mipLevel:slice:"); +_MTL_PRIVATE_DEF_SEL(resetWithRange_, + "resetWithRange:"); +_MTL_PRIVATE_DEF_SEL(resolveCounterRange_, + "resolveCounterRange:"); +_MTL_PRIVATE_DEF_SEL(resolveCounters_inRange_destinationBuffer_destinationOffset_, + "resolveCounters:inRange:destinationBuffer:destinationOffset:"); +_MTL_PRIVATE_DEF_SEL(resolveDepthPlane, + "resolveDepthPlane"); +_MTL_PRIVATE_DEF_SEL(resolveLevel, + "resolveLevel"); +_MTL_PRIVATE_DEF_SEL(resolveSlice, + "resolveSlice"); +_MTL_PRIVATE_DEF_SEL(resolveTexture, + "resolveTexture"); +_MTL_PRIVATE_DEF_SEL(resourceOptions, + "resourceOptions"); +_MTL_PRIVATE_DEF_SEL(resourceStateCommandEncoder, + "resourceStateCommandEncoder"); +_MTL_PRIVATE_DEF_SEL(resourceStateCommandEncoderWithDescriptor_, + "resourceStateCommandEncoderWithDescriptor:"); +_MTL_PRIVATE_DEF_SEL(resourceStatePassDescriptor, + "resourceStatePassDescriptor"); +_MTL_PRIVATE_DEF_SEL(retainedReferences, + "retainedReferences"); +_MTL_PRIVATE_DEF_SEL(rgbBlendOperation, + "rgbBlendOperation"); +_MTL_PRIVATE_DEF_SEL(rootResource, + "rootResource"); +_MTL_PRIVATE_DEF_SEL(sAddressMode, + "sAddressMode"); +_MTL_PRIVATE_DEF_SEL(sampleBuffer, + "sampleBuffer"); +_MTL_PRIVATE_DEF_SEL(sampleBufferAttachments, + "sampleBufferAttachments"); +_MTL_PRIVATE_DEF_SEL(sampleCount, + "sampleCount"); +_MTL_PRIVATE_DEF_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_, + "sampleCountersInBuffer:atSampleIndex:withBarrier:"); +_MTL_PRIVATE_DEF_SEL(sampleTimestamps_gpuTimestamp_, + "sampleTimestamps:gpuTimestamp:"); +_MTL_PRIVATE_DEF_SEL(scratchBufferAllocator, + "scratchBufferAllocator"); +_MTL_PRIVATE_DEF_SEL(screenSize, + "screenSize"); +_MTL_PRIVATE_DEF_SEL(serializeToURL_error_, + "serializeToURL:error:"); +_MTL_PRIVATE_DEF_SEL(setAccelerationStructure_atBufferIndex_, + "setAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setAccelerationStructure_atIndex_, + "setAccelerationStructure:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setAccess_, + "setAccess:"); +_MTL_PRIVATE_DEF_SEL(setAllowDuplicateIntersectionFunctionInvocation_, + "setAllowDuplicateIntersectionFunctionInvocation:"); +_MTL_PRIVATE_DEF_SEL(setAllowGPUOptimizedContents_, + "setAllowGPUOptimizedContents:"); +_MTL_PRIVATE_DEF_SEL(setAllowReferencingUndefinedSymbols_, + "setAllowReferencingUndefinedSymbols:"); +_MTL_PRIVATE_DEF_SEL(setAlphaBlendOperation_, + "setAlphaBlendOperation:"); +_MTL_PRIVATE_DEF_SEL(setAlphaToCoverageEnabled_, + "setAlphaToCoverageEnabled:"); +_MTL_PRIVATE_DEF_SEL(setAlphaToOneEnabled_, + "setAlphaToOneEnabled:"); +_MTL_PRIVATE_DEF_SEL(setArgumentBuffer_offset_, + "setArgumentBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(setArgumentBuffer_startOffset_arrayElement_, + "setArgumentBuffer:startOffset:arrayElement:"); +_MTL_PRIVATE_DEF_SEL(setArgumentIndex_, + "setArgumentIndex:"); +_MTL_PRIVATE_DEF_SEL(setArguments_, + "setArguments:"); +_MTL_PRIVATE_DEF_SEL(setArrayLength_, + "setArrayLength:"); +_MTL_PRIVATE_DEF_SEL(setAttributes_, + "setAttributes:"); +_MTL_PRIVATE_DEF_SEL(setBackFaceStencil_, + "setBackFaceStencil:"); +_MTL_PRIVATE_DEF_SEL(setBarrier, + "setBarrier"); +_MTL_PRIVATE_DEF_SEL(setBinaryArchives_, + "setBinaryArchives:"); +_MTL_PRIVATE_DEF_SEL(setBinaryFunctions_, + "setBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setBlendColorRed_green_blue_alpha_, + "setBlendColorRed:green:blue:alpha:"); +_MTL_PRIVATE_DEF_SEL(setBlendingEnabled_, + "setBlendingEnabled:"); +_MTL_PRIVATE_DEF_SEL(setBorderColor_, + "setBorderColor:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxBuffer_, + "setBoundingBoxBuffer:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxBufferOffset_, + "setBoundingBoxBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxBuffers_, + "setBoundingBoxBuffers:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxCount_, + "setBoundingBoxCount:"); +_MTL_PRIVATE_DEF_SEL(setBoundingBoxStride_, + "setBoundingBoxStride:"); +_MTL_PRIVATE_DEF_SEL(setBuffer_, + "setBuffer:"); +_MTL_PRIVATE_DEF_SEL(setBuffer_offset_atIndex_, + "setBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setBufferIndex_, + "setBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setBufferOffset_atIndex_, + "setBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setBuffers_offsets_withRange_, + "setBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setBytes_length_atIndex_, + "setBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setCaptureObject_, + "setCaptureObject:"); +_MTL_PRIVATE_DEF_SEL(setClearColor_, + "setClearColor:"); +_MTL_PRIVATE_DEF_SEL(setClearDepth_, + "setClearDepth:"); +_MTL_PRIVATE_DEF_SEL(setClearStencil_, + "setClearStencil:"); +_MTL_PRIVATE_DEF_SEL(setColorStoreAction_atIndex_, + "setColorStoreAction:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setColorStoreActionOptions_atIndex_, + "setColorStoreActionOptions:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setCommandTypes_, + "setCommandTypes:"); +_MTL_PRIVATE_DEF_SEL(setCompareFunction_, + "setCompareFunction:"); +_MTL_PRIVATE_DEF_SEL(setCompileSymbolVisibility_, + "setCompileSymbolVisibility:"); +_MTL_PRIVATE_DEF_SEL(setCompressionType_, + "setCompressionType:"); +_MTL_PRIVATE_DEF_SEL(setComputeFunction_, + "setComputeFunction:"); +_MTL_PRIVATE_DEF_SEL(setComputePipelineState_, + "setComputePipelineState:"); +_MTL_PRIVATE_DEF_SEL(setComputePipelineState_atIndex_, + "setComputePipelineState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setComputePipelineStates_withRange_, + "setComputePipelineStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setConstantBlockAlignment_, + "setConstantBlockAlignment:"); +_MTL_PRIVATE_DEF_SEL(setConstantValue_type_atIndex_, + "setConstantValue:type:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setConstantValue_type_withName_, + "setConstantValue:type:withName:"); +_MTL_PRIVATE_DEF_SEL(setConstantValues_, + "setConstantValues:"); +_MTL_PRIVATE_DEF_SEL(setConstantValues_type_withRange_, + "setConstantValues:type:withRange:"); +_MTL_PRIVATE_DEF_SEL(setControlDependencies_, + "setControlDependencies:"); +_MTL_PRIVATE_DEF_SEL(setCounterSet_, + "setCounterSet:"); +_MTL_PRIVATE_DEF_SEL(setCpuCacheMode_, + "setCpuCacheMode:"); +_MTL_PRIVATE_DEF_SEL(setCullMode_, + "setCullMode:"); +_MTL_PRIVATE_DEF_SEL(setDataType_, + "setDataType:"); +_MTL_PRIVATE_DEF_SEL(setDefaultCaptureScope_, + "setDefaultCaptureScope:"); +_MTL_PRIVATE_DEF_SEL(setDefaultRasterSampleCount_, + "setDefaultRasterSampleCount:"); +_MTL_PRIVATE_DEF_SEL(setDepth_, + "setDepth:"); +_MTL_PRIVATE_DEF_SEL(setDepthAttachment_, + "setDepthAttachment:"); +_MTL_PRIVATE_DEF_SEL(setDepthAttachmentPixelFormat_, + "setDepthAttachmentPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(setDepthBias_slopeScale_clamp_, + "setDepthBias:slopeScale:clamp:"); +_MTL_PRIVATE_DEF_SEL(setDepthClipMode_, + "setDepthClipMode:"); +_MTL_PRIVATE_DEF_SEL(setDepthCompareFunction_, + "setDepthCompareFunction:"); +_MTL_PRIVATE_DEF_SEL(setDepthFailureOperation_, + "setDepthFailureOperation:"); +_MTL_PRIVATE_DEF_SEL(setDepthPlane_, + "setDepthPlane:"); +_MTL_PRIVATE_DEF_SEL(setDepthResolveFilter_, + "setDepthResolveFilter:"); +_MTL_PRIVATE_DEF_SEL(setDepthStencilPassOperation_, + "setDepthStencilPassOperation:"); +_MTL_PRIVATE_DEF_SEL(setDepthStencilState_, + "setDepthStencilState:"); +_MTL_PRIVATE_DEF_SEL(setDepthStoreAction_, + "setDepthStoreAction:"); +_MTL_PRIVATE_DEF_SEL(setDepthStoreActionOptions_, + "setDepthStoreActionOptions:"); +_MTL_PRIVATE_DEF_SEL(setDepthWriteEnabled_, + "setDepthWriteEnabled:"); +_MTL_PRIVATE_DEF_SEL(setDestination_, + "setDestination:"); +_MTL_PRIVATE_DEF_SEL(setDestinationAlphaBlendFactor_, + "setDestinationAlphaBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setDestinationRGBBlendFactor_, + "setDestinationRGBBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setDispatchType_, + "setDispatchType:"); +_MTL_PRIVATE_DEF_SEL(setEndOfEncoderSampleIndex_, + "setEndOfEncoderSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setEndOfFragmentSampleIndex_, + "setEndOfFragmentSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setEndOfVertexSampleIndex_, + "setEndOfVertexSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setErrorOptions_, + "setErrorOptions:"); +_MTL_PRIVATE_DEF_SEL(setFastMathEnabled_, + "setFastMathEnabled:"); +_MTL_PRIVATE_DEF_SEL(setFormat_, + "setFormat:"); +_MTL_PRIVATE_DEF_SEL(setFragmentAccelerationStructure_atBufferIndex_, + "setFragmentAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentAdditionalBinaryFunctions_, + "setFragmentAdditionalBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBuffer_offset_atIndex_, + "setFragmentBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBufferOffset_atIndex_, + "setFragmentBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBuffers_offsets_withRange_, + "setFragmentBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentBytes_length_atIndex_, + "setFragmentBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentFunction_, + "setFragmentFunction:"); +_MTL_PRIVATE_DEF_SEL(setFragmentIntersectionFunctionTable_atBufferIndex_, + "setFragmentIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentIntersectionFunctionTables_withBufferRange_, + "setFragmentIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentLinkedFunctions_, + "setFragmentLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setFragmentPreloadedLibraries_, + "setFragmentPreloadedLibraries:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerState_atIndex_, + "setFragmentSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentSamplerStates_withRange_, + "setFragmentSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentTexture_atIndex_, + "setFragmentTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentTextures_withRange_, + "setFragmentTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setFragmentVisibleFunctionTable_atBufferIndex_, + "setFragmentVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setFragmentVisibleFunctionTables_withBufferRange_, + "setFragmentVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setFrontFaceStencil_, + "setFrontFaceStencil:"); +_MTL_PRIVATE_DEF_SEL(setFrontFacingWinding_, + "setFrontFacingWinding:"); +_MTL_PRIVATE_DEF_SEL(setFunction_atIndex_, + "setFunction:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setFunctionCount_, + "setFunctionCount:"); +_MTL_PRIVATE_DEF_SEL(setFunctionGraphs_, + "setFunctionGraphs:"); +_MTL_PRIVATE_DEF_SEL(setFunctionName_, + "setFunctionName:"); +_MTL_PRIVATE_DEF_SEL(setFunctions_, + "setFunctions:"); +_MTL_PRIVATE_DEF_SEL(setFunctions_withRange_, + "setFunctions:withRange:"); +_MTL_PRIVATE_DEF_SEL(setGeometryDescriptors_, + "setGeometryDescriptors:"); +_MTL_PRIVATE_DEF_SEL(setGroups_, + "setGroups:"); +_MTL_PRIVATE_DEF_SEL(setHazardTrackingMode_, + "setHazardTrackingMode:"); +_MTL_PRIVATE_DEF_SEL(setHeight_, + "setHeight:"); +_MTL_PRIVATE_DEF_SEL(setImageblockSampleLength_, + "setImageblockSampleLength:"); +_MTL_PRIVATE_DEF_SEL(setImageblockWidth_height_, + "setImageblockWidth:height:"); +_MTL_PRIVATE_DEF_SEL(setIndex_, + "setIndex:"); +_MTL_PRIVATE_DEF_SEL(setIndexBuffer_, + "setIndexBuffer:"); +_MTL_PRIVATE_DEF_SEL(setIndexBufferIndex_, + "setIndexBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setIndexBufferOffset_, + "setIndexBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setIndexType_, + "setIndexType:"); +_MTL_PRIVATE_DEF_SEL(setIndirectCommandBuffer_atIndex_, + "setIndirectCommandBuffer:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setIndirectCommandBuffers_withRange_, + "setIndirectCommandBuffers:withRange:"); +_MTL_PRIVATE_DEF_SEL(setInheritBuffers_, + "setInheritBuffers:"); +_MTL_PRIVATE_DEF_SEL(setInheritPipelineState_, + "setInheritPipelineState:"); +_MTL_PRIVATE_DEF_SEL(setInputPrimitiveTopology_, + "setInputPrimitiveTopology:"); +_MTL_PRIVATE_DEF_SEL(setInsertLibraries_, + "setInsertLibraries:"); +_MTL_PRIVATE_DEF_SEL(setInstallName_, + "setInstallName:"); +_MTL_PRIVATE_DEF_SEL(setInstanceCount_, + "setInstanceCount:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorBuffer_, + "setInstanceDescriptorBuffer:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorBufferOffset_, + "setInstanceDescriptorBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorStride_, + "setInstanceDescriptorStride:"); +_MTL_PRIVATE_DEF_SEL(setInstanceDescriptorType_, + "setInstanceDescriptorType:"); +_MTL_PRIVATE_DEF_SEL(setInstancedAccelerationStructures_, + "setInstancedAccelerationStructures:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTable_atBufferIndex_, + "setIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTable_atIndex_, + "setIntersectionFunctionTable:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTableOffset_, + "setIntersectionFunctionTableOffset:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTables_withBufferRange_, + "setIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setIntersectionFunctionTables_withRange_, + "setIntersectionFunctionTables:withRange:"); +_MTL_PRIVATE_DEF_SEL(setKernelBuffer_offset_atIndex_, + "setKernelBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setLabel_, + "setLabel:"); +_MTL_PRIVATE_DEF_SEL(setLanguageVersion_, + "setLanguageVersion:"); +_MTL_PRIVATE_DEF_SEL(setLayer_atIndex_, + "setLayer:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setLevel_, + "setLevel:"); +_MTL_PRIVATE_DEF_SEL(setLibraries_, + "setLibraries:"); +_MTL_PRIVATE_DEF_SEL(setLibraryType_, + "setLibraryType:"); +_MTL_PRIVATE_DEF_SEL(setLinkedFunctions_, + "setLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setLoadAction_, + "setLoadAction:"); +_MTL_PRIVATE_DEF_SEL(setLodAverage_, + "setLodAverage:"); +_MTL_PRIVATE_DEF_SEL(setLodMaxClamp_, + "setLodMaxClamp:"); +_MTL_PRIVATE_DEF_SEL(setLodMinClamp_, + "setLodMinClamp:"); +_MTL_PRIVATE_DEF_SEL(setMagFilter_, + "setMagFilter:"); +_MTL_PRIVATE_DEF_SEL(setMaxAnisotropy_, + "setMaxAnisotropy:"); +_MTL_PRIVATE_DEF_SEL(setMaxCallStackDepth_, + "setMaxCallStackDepth:"); +_MTL_PRIVATE_DEF_SEL(setMaxCommandBufferCount_, + "setMaxCommandBufferCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxCommandsInFlight_, + "setMaxCommandsInFlight:"); +_MTL_PRIVATE_DEF_SEL(setMaxFragmentBufferBindCount_, + "setMaxFragmentBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxFragmentCallStackDepth_, + "setMaxFragmentCallStackDepth:"); +_MTL_PRIVATE_DEF_SEL(setMaxKernelBufferBindCount_, + "setMaxKernelBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxTessellationFactor_, + "setMaxTessellationFactor:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadgroupsPerMeshGrid_, + "setMaxTotalThreadgroupsPerMeshGrid:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadsPerMeshThreadgroup_, + "setMaxTotalThreadsPerMeshThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadsPerObjectThreadgroup_, + "setMaxTotalThreadsPerObjectThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(setMaxTotalThreadsPerThreadgroup_, + "setMaxTotalThreadsPerThreadgroup:"); +_MTL_PRIVATE_DEF_SEL(setMaxVertexAmplificationCount_, + "setMaxVertexAmplificationCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxVertexBufferBindCount_, + "setMaxVertexBufferBindCount:"); +_MTL_PRIVATE_DEF_SEL(setMaxVertexCallStackDepth_, + "setMaxVertexCallStackDepth:"); +_MTL_PRIVATE_DEF_SEL(setMeshBuffer_offset_atIndex_, + "setMeshBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshBufferOffset_atIndex_, + "setMeshBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshBuffers_offsets_withRange_, + "setMeshBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshBytes_length_atIndex_, + "setMeshBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshFunction_, + "setMeshFunction:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerState_atIndex_, + "setMeshSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setMeshSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshSamplerStates_withRange_, + "setMeshSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshTexture_atIndex_, + "setMeshTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setMeshTextures_withRange_, + "setMeshTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth_, + "setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth:"); +_MTL_PRIVATE_DEF_SEL(setMinFilter_, + "setMinFilter:"); +_MTL_PRIVATE_DEF_SEL(setMipFilter_, + "setMipFilter:"); +_MTL_PRIVATE_DEF_SEL(setMipmapLevelCount_, + "setMipmapLevelCount:"); +_MTL_PRIVATE_DEF_SEL(setMotionEndBorderMode_, + "setMotionEndBorderMode:"); +_MTL_PRIVATE_DEF_SEL(setMotionEndTime_, + "setMotionEndTime:"); +_MTL_PRIVATE_DEF_SEL(setMotionKeyframeCount_, + "setMotionKeyframeCount:"); +_MTL_PRIVATE_DEF_SEL(setMotionStartBorderMode_, + "setMotionStartBorderMode:"); +_MTL_PRIVATE_DEF_SEL(setMotionStartTime_, + "setMotionStartTime:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformBuffer_, + "setMotionTransformBuffer:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformBufferOffset_, + "setMotionTransformBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setMotionTransformCount_, + "setMotionTransformCount:"); +_MTL_PRIVATE_DEF_SEL(setMutability_, + "setMutability:"); +_MTL_PRIVATE_DEF_SEL(setName_, + "setName:"); +_MTL_PRIVATE_DEF_SEL(setNodes_, + "setNodes:"); +_MTL_PRIVATE_DEF_SEL(setNormalizedCoordinates_, + "setNormalizedCoordinates:"); +_MTL_PRIVATE_DEF_SEL(setObject_atIndexedSubscript_, + "setObject:atIndexedSubscript:"); +_MTL_PRIVATE_DEF_SEL(setObjectBuffer_offset_atIndex_, + "setObjectBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectBufferOffset_atIndex_, + "setObjectBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectBuffers_offsets_withRange_, + "setObjectBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectBytes_length_atIndex_, + "setObjectBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectFunction_, + "setObjectFunction:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerState_atIndex_, + "setObjectSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setObjectSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectSamplerStates_withRange_, + "setObjectSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectTexture_atIndex_, + "setObjectTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectTextures_withRange_, + "setObjectTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setObjectThreadgroupMemoryLength_atIndex_, + "setObjectThreadgroupMemoryLength:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth_, + "setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth:"); +_MTL_PRIVATE_DEF_SEL(setOffset_, + "setOffset:"); +_MTL_PRIVATE_DEF_SEL(setOpaque_, + "setOpaque:"); +_MTL_PRIVATE_DEF_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_atIndex_, + "setOpaqueTriangleIntersectionFunctionWithSignature:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_withRange_, + "setOpaqueTriangleIntersectionFunctionWithSignature:withRange:"); +_MTL_PRIVATE_DEF_SEL(setOptimizationLevel_, + "setOptimizationLevel:"); +_MTL_PRIVATE_DEF_SEL(setOptions_, + "setOptions:"); +_MTL_PRIVATE_DEF_SEL(setOutputNode_, + "setOutputNode:"); +_MTL_PRIVATE_DEF_SEL(setOutputURL_, + "setOutputURL:"); +_MTL_PRIVATE_DEF_SEL(setPayloadMemoryLength_, + "setPayloadMemoryLength:"); +_MTL_PRIVATE_DEF_SEL(setPixelFormat_, + "setPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(setPreloadedLibraries_, + "setPreloadedLibraries:"); +_MTL_PRIVATE_DEF_SEL(setPreprocessorMacros_, + "setPreprocessorMacros:"); +_MTL_PRIVATE_DEF_SEL(setPreserveInvariance_, + "setPreserveInvariance:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataBuffer_, + "setPrimitiveDataBuffer:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataBufferOffset_, + "setPrimitiveDataBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataElementSize_, + "setPrimitiveDataElementSize:"); +_MTL_PRIVATE_DEF_SEL(setPrimitiveDataStride_, + "setPrimitiveDataStride:"); +_MTL_PRIVATE_DEF_SEL(setPriority_, + "setPriority:"); +_MTL_PRIVATE_DEF_SEL(setPrivateFunctions_, + "setPrivateFunctions:"); +_MTL_PRIVATE_DEF_SEL(setPurgeableState_, + "setPurgeableState:"); +_MTL_PRIVATE_DEF_SEL(setRAddressMode_, + "setRAddressMode:"); +_MTL_PRIVATE_DEF_SEL(setRasterSampleCount_, + "setRasterSampleCount:"); +_MTL_PRIVATE_DEF_SEL(setRasterizationEnabled_, + "setRasterizationEnabled:"); +_MTL_PRIVATE_DEF_SEL(setRasterizationRateMap_, + "setRasterizationRateMap:"); +_MTL_PRIVATE_DEF_SEL(setReadMask_, + "setReadMask:"); +_MTL_PRIVATE_DEF_SEL(setRenderPipelineState_, + "setRenderPipelineState:"); +_MTL_PRIVATE_DEF_SEL(setRenderPipelineState_atIndex_, + "setRenderPipelineState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setRenderPipelineStates_withRange_, + "setRenderPipelineStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setRenderTargetArrayLength_, + "setRenderTargetArrayLength:"); +_MTL_PRIVATE_DEF_SEL(setRenderTargetHeight_, + "setRenderTargetHeight:"); +_MTL_PRIVATE_DEF_SEL(setRenderTargetWidth_, + "setRenderTargetWidth:"); +_MTL_PRIVATE_DEF_SEL(setResolveDepthPlane_, + "setResolveDepthPlane:"); +_MTL_PRIVATE_DEF_SEL(setResolveLevel_, + "setResolveLevel:"); +_MTL_PRIVATE_DEF_SEL(setResolveSlice_, + "setResolveSlice:"); +_MTL_PRIVATE_DEF_SEL(setResolveTexture_, + "setResolveTexture:"); +_MTL_PRIVATE_DEF_SEL(setResourceOptions_, + "setResourceOptions:"); +_MTL_PRIVATE_DEF_SEL(setRetainedReferences_, + "setRetainedReferences:"); +_MTL_PRIVATE_DEF_SEL(setRgbBlendOperation_, + "setRgbBlendOperation:"); +_MTL_PRIVATE_DEF_SEL(setSAddressMode_, + "setSAddressMode:"); +_MTL_PRIVATE_DEF_SEL(setSampleBuffer_, + "setSampleBuffer:"); +_MTL_PRIVATE_DEF_SEL(setSampleCount_, + "setSampleCount:"); +_MTL_PRIVATE_DEF_SEL(setSamplePositions_count_, + "setSamplePositions:count:"); +_MTL_PRIVATE_DEF_SEL(setSamplerState_atIndex_, + "setSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setSamplerStates_withRange_, + "setSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setScissorRect_, + "setScissorRect:"); +_MTL_PRIVATE_DEF_SEL(setScissorRects_count_, + "setScissorRects:count:"); +_MTL_PRIVATE_DEF_SEL(setScratchBufferAllocator_, + "setScratchBufferAllocator:"); +_MTL_PRIVATE_DEF_SEL(setScreenSize_, + "setScreenSize:"); +_MTL_PRIVATE_DEF_SEL(setShouldMaximizeConcurrentCompilation_, + "setShouldMaximizeConcurrentCompilation:"); +_MTL_PRIVATE_DEF_SEL(setSignaledValue_, + "setSignaledValue:"); +_MTL_PRIVATE_DEF_SEL(setSize_, + "setSize:"); +_MTL_PRIVATE_DEF_SEL(setSlice_, + "setSlice:"); +_MTL_PRIVATE_DEF_SEL(setSourceAlphaBlendFactor_, + "setSourceAlphaBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setSourceRGBBlendFactor_, + "setSourceRGBBlendFactor:"); +_MTL_PRIVATE_DEF_SEL(setSparsePageSize_, + "setSparsePageSize:"); +_MTL_PRIVATE_DEF_SEL(setSpecializedName_, + "setSpecializedName:"); +_MTL_PRIVATE_DEF_SEL(setStageInRegion_, + "setStageInRegion:"); +_MTL_PRIVATE_DEF_SEL(setStageInRegionWithIndirectBuffer_indirectBufferOffset_, + "setStageInRegionWithIndirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setStageInputDescriptor_, + "setStageInputDescriptor:"); +_MTL_PRIVATE_DEF_SEL(setStartOfEncoderSampleIndex_, + "setStartOfEncoderSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setStartOfFragmentSampleIndex_, + "setStartOfFragmentSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setStartOfVertexSampleIndex_, + "setStartOfVertexSampleIndex:"); +_MTL_PRIVATE_DEF_SEL(setStencilAttachment_, + "setStencilAttachment:"); +_MTL_PRIVATE_DEF_SEL(setStencilAttachmentPixelFormat_, + "setStencilAttachmentPixelFormat:"); +_MTL_PRIVATE_DEF_SEL(setStencilCompareFunction_, + "setStencilCompareFunction:"); +_MTL_PRIVATE_DEF_SEL(setStencilFailureOperation_, + "setStencilFailureOperation:"); +_MTL_PRIVATE_DEF_SEL(setStencilFrontReferenceValue_backReferenceValue_, + "setStencilFrontReferenceValue:backReferenceValue:"); +_MTL_PRIVATE_DEF_SEL(setStencilReferenceValue_, + "setStencilReferenceValue:"); +_MTL_PRIVATE_DEF_SEL(setStencilResolveFilter_, + "setStencilResolveFilter:"); +_MTL_PRIVATE_DEF_SEL(setStencilStoreAction_, + "setStencilStoreAction:"); +_MTL_PRIVATE_DEF_SEL(setStencilStoreActionOptions_, + "setStencilStoreActionOptions:"); +_MTL_PRIVATE_DEF_SEL(setStepFunction_, + "setStepFunction:"); +_MTL_PRIVATE_DEF_SEL(setStepRate_, + "setStepRate:"); +_MTL_PRIVATE_DEF_SEL(setStorageMode_, + "setStorageMode:"); +_MTL_PRIVATE_DEF_SEL(setStoreAction_, + "setStoreAction:"); +_MTL_PRIVATE_DEF_SEL(setStoreActionOptions_, + "setStoreActionOptions:"); +_MTL_PRIVATE_DEF_SEL(setStride_, + "setStride:"); +_MTL_PRIVATE_DEF_SEL(setSupportAddingBinaryFunctions_, + "setSupportAddingBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setSupportAddingFragmentBinaryFunctions_, + "setSupportAddingFragmentBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setSupportAddingVertexBinaryFunctions_, + "setSupportAddingVertexBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setSupportArgumentBuffers_, + "setSupportArgumentBuffers:"); +_MTL_PRIVATE_DEF_SEL(setSupportIndirectCommandBuffers_, + "setSupportIndirectCommandBuffers:"); +_MTL_PRIVATE_DEF_SEL(setSupportRayTracing_, + "setSupportRayTracing:"); +_MTL_PRIVATE_DEF_SEL(setSwizzle_, + "setSwizzle:"); +_MTL_PRIVATE_DEF_SEL(setTAddressMode_, + "setTAddressMode:"); +_MTL_PRIVATE_DEF_SEL(setTessellationControlPointIndexType_, + "setTessellationControlPointIndexType:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorBuffer_offset_instanceStride_, + "setTessellationFactorBuffer:offset:instanceStride:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorFormat_, + "setTessellationFactorFormat:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorScale_, + "setTessellationFactorScale:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorScaleEnabled_, + "setTessellationFactorScaleEnabled:"); +_MTL_PRIVATE_DEF_SEL(setTessellationFactorStepFunction_, + "setTessellationFactorStepFunction:"); +_MTL_PRIVATE_DEF_SEL(setTessellationOutputWindingOrder_, + "setTessellationOutputWindingOrder:"); +_MTL_PRIVATE_DEF_SEL(setTessellationPartitionMode_, + "setTessellationPartitionMode:"); +_MTL_PRIVATE_DEF_SEL(setTexture_, + "setTexture:"); +_MTL_PRIVATE_DEF_SEL(setTexture_atIndex_, + "setTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTextureType_, + "setTextureType:"); +_MTL_PRIVATE_DEF_SEL(setTextures_withRange_, + "setTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setThreadGroupSizeIsMultipleOfThreadExecutionWidth_, + "setThreadGroupSizeIsMultipleOfThreadExecutionWidth:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupMemoryLength_, + "setThreadgroupMemoryLength:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupMemoryLength_atIndex_, + "setThreadgroupMemoryLength:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupMemoryLength_offset_atIndex_, + "setThreadgroupMemoryLength:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setThreadgroupSizeMatchesTileSize_, + "setThreadgroupSizeMatchesTileSize:"); +_MTL_PRIVATE_DEF_SEL(setTileAccelerationStructure_atBufferIndex_, + "setTileAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileAdditionalBinaryFunctions_, + "setTileAdditionalBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setTileBuffer_offset_atIndex_, + "setTileBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileBufferOffset_atIndex_, + "setTileBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileBuffers_offsets_withRange_, + "setTileBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileBytes_length_atIndex_, + "setTileBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileFunction_, + "setTileFunction:"); +_MTL_PRIVATE_DEF_SEL(setTileHeight_, + "setTileHeight:"); +_MTL_PRIVATE_DEF_SEL(setTileIntersectionFunctionTable_atBufferIndex_, + "setTileIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileIntersectionFunctionTables_withBufferRange_, + "setTileIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerState_atIndex_, + "setTileSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setTileSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileSamplerStates_withRange_, + "setTileSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileTexture_atIndex_, + "setTileTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileTextures_withRange_, + "setTileTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setTileVisibleFunctionTable_atBufferIndex_, + "setTileVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setTileVisibleFunctionTables_withBufferRange_, + "setTileVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setTileWidth_, + "setTileWidth:"); +_MTL_PRIVATE_DEF_SEL(setTransformationMatrixBuffer_, + "setTransformationMatrixBuffer:"); +_MTL_PRIVATE_DEF_SEL(setTransformationMatrixBufferOffset_, + "setTransformationMatrixBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setTriangleCount_, + "setTriangleCount:"); +_MTL_PRIVATE_DEF_SEL(setTriangleFillMode_, + "setTriangleFillMode:"); +_MTL_PRIVATE_DEF_SEL(setType_, + "setType:"); +_MTL_PRIVATE_DEF_SEL(setUrl_, + "setUrl:"); +_MTL_PRIVATE_DEF_SEL(setUsage_, + "setUsage:"); +_MTL_PRIVATE_DEF_SEL(setVertexAccelerationStructure_atBufferIndex_, + "setVertexAccelerationStructure:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexAdditionalBinaryFunctions_, + "setVertexAdditionalBinaryFunctions:"); +_MTL_PRIVATE_DEF_SEL(setVertexAmplificationCount_viewMappings_, + "setVertexAmplificationCount:viewMappings:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffer_, + "setVertexBuffer:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffer_offset_atIndex_, + "setVertexBuffer:offset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_, + "setVertexBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_atIndex_, + "setVertexBufferOffset:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffers_, + "setVertexBuffers:"); +_MTL_PRIVATE_DEF_SEL(setVertexBuffers_offsets_withRange_, + "setVertexBuffers:offsets:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexBytes_length_atIndex_, + "setVertexBytes:length:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexDescriptor_, + "setVertexDescriptor:"); +_MTL_PRIVATE_DEF_SEL(setVertexFormat_, + "setVertexFormat:"); +_MTL_PRIVATE_DEF_SEL(setVertexFunction_, + "setVertexFunction:"); +_MTL_PRIVATE_DEF_SEL(setVertexIntersectionFunctionTable_atBufferIndex_, + "setVertexIntersectionFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexIntersectionFunctionTables_withBufferRange_, + "setVertexIntersectionFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexLinkedFunctions_, + "setVertexLinkedFunctions:"); +_MTL_PRIVATE_DEF_SEL(setVertexPreloadedLibraries_, + "setVertexPreloadedLibraries:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerState_atIndex_, + "setVertexSamplerState:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerState_lodMinClamp_lodMaxClamp_atIndex_, + "setVertexSamplerState:lodMinClamp:lodMaxClamp:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerStates_lodMinClamps_lodMaxClamps_withRange_, + "setVertexSamplerStates:lodMinClamps:lodMaxClamps:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexSamplerStates_withRange_, + "setVertexSamplerStates:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexStride_, + "setVertexStride:"); +_MTL_PRIVATE_DEF_SEL(setVertexTexture_atIndex_, + "setVertexTexture:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexTextures_withRange_, + "setVertexTextures:withRange:"); +_MTL_PRIVATE_DEF_SEL(setVertexVisibleFunctionTable_atBufferIndex_, + "setVertexVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVertexVisibleFunctionTables_withBufferRange_, + "setVertexVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setViewport_, + "setViewport:"); +_MTL_PRIVATE_DEF_SEL(setViewports_count_, + "setViewports:count:"); +_MTL_PRIVATE_DEF_SEL(setVisibilityResultBuffer_, + "setVisibilityResultBuffer:"); +_MTL_PRIVATE_DEF_SEL(setVisibilityResultMode_offset_, + "setVisibilityResultMode:offset:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTable_atBufferIndex_, + "setVisibleFunctionTable:atBufferIndex:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTable_atIndex_, + "setVisibleFunctionTable:atIndex:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTables_withBufferRange_, + "setVisibleFunctionTables:withBufferRange:"); +_MTL_PRIVATE_DEF_SEL(setVisibleFunctionTables_withRange_, + "setVisibleFunctionTables:withRange:"); +_MTL_PRIVATE_DEF_SEL(setWidth_, + "setWidth:"); +_MTL_PRIVATE_DEF_SEL(setWriteMask_, + "setWriteMask:"); +_MTL_PRIVATE_DEF_SEL(sharedCaptureManager, + "sharedCaptureManager"); +_MTL_PRIVATE_DEF_SEL(shouldMaximizeConcurrentCompilation, + "shouldMaximizeConcurrentCompilation"); +_MTL_PRIVATE_DEF_SEL(signalEvent_value_, + "signalEvent:value:"); +_MTL_PRIVATE_DEF_SEL(signaledValue, + "signaledValue"); +_MTL_PRIVATE_DEF_SEL(size, + "size"); +_MTL_PRIVATE_DEF_SEL(slice, + "slice"); +_MTL_PRIVATE_DEF_SEL(sourceAlphaBlendFactor, + "sourceAlphaBlendFactor"); +_MTL_PRIVATE_DEF_SEL(sourceRGBBlendFactor, + "sourceRGBBlendFactor"); +_MTL_PRIVATE_DEF_SEL(sparsePageSize, + "sparsePageSize"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeInBytes, + "sparseTileSizeInBytes"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeInBytesForSparsePageSize_, + "sparseTileSizeInBytesForSparsePageSize:"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_, + "sparseTileSizeWithTextureType:pixelFormat:sampleCount:"); +_MTL_PRIVATE_DEF_SEL(sparseTileSizeWithTextureType_pixelFormat_sampleCount_sparsePageSize_, + "sparseTileSizeWithTextureType:pixelFormat:sampleCount:sparsePageSize:"); +_MTL_PRIVATE_DEF_SEL(specializedName, + "specializedName"); +_MTL_PRIVATE_DEF_SEL(stageInputAttributes, + "stageInputAttributes"); +_MTL_PRIVATE_DEF_SEL(stageInputDescriptor, + "stageInputDescriptor"); +_MTL_PRIVATE_DEF_SEL(stageInputOutputDescriptor, + "stageInputOutputDescriptor"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithCommandQueue_, + "startCaptureWithCommandQueue:"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithDescriptor_error_, + "startCaptureWithDescriptor:error:"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithDevice_, + "startCaptureWithDevice:"); +_MTL_PRIVATE_DEF_SEL(startCaptureWithScope_, + "startCaptureWithScope:"); +_MTL_PRIVATE_DEF_SEL(startOfEncoderSampleIndex, + "startOfEncoderSampleIndex"); +_MTL_PRIVATE_DEF_SEL(startOfFragmentSampleIndex, + "startOfFragmentSampleIndex"); +_MTL_PRIVATE_DEF_SEL(startOfVertexSampleIndex, + "startOfVertexSampleIndex"); +_MTL_PRIVATE_DEF_SEL(staticThreadgroupMemoryLength, + "staticThreadgroupMemoryLength"); +_MTL_PRIVATE_DEF_SEL(status, + "status"); +_MTL_PRIVATE_DEF_SEL(stencilAttachment, + "stencilAttachment"); +_MTL_PRIVATE_DEF_SEL(stencilAttachmentPixelFormat, + "stencilAttachmentPixelFormat"); +_MTL_PRIVATE_DEF_SEL(stencilCompareFunction, + "stencilCompareFunction"); +_MTL_PRIVATE_DEF_SEL(stencilFailureOperation, + "stencilFailureOperation"); +_MTL_PRIVATE_DEF_SEL(stencilResolveFilter, + "stencilResolveFilter"); +_MTL_PRIVATE_DEF_SEL(stepFunction, + "stepFunction"); +_MTL_PRIVATE_DEF_SEL(stepRate, + "stepRate"); +_MTL_PRIVATE_DEF_SEL(stopCapture, + "stopCapture"); +_MTL_PRIVATE_DEF_SEL(storageMode, + "storageMode"); +_MTL_PRIVATE_DEF_SEL(storeAction, + "storeAction"); +_MTL_PRIVATE_DEF_SEL(storeActionOptions, + "storeActionOptions"); +_MTL_PRIVATE_DEF_SEL(stride, + "stride"); +_MTL_PRIVATE_DEF_SEL(structType, + "structType"); +_MTL_PRIVATE_DEF_SEL(supportAddingBinaryFunctions, + "supportAddingBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(supportAddingFragmentBinaryFunctions, + "supportAddingFragmentBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(supportAddingVertexBinaryFunctions, + "supportAddingVertexBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(supportArgumentBuffers, + "supportArgumentBuffers"); +_MTL_PRIVATE_DEF_SEL(supportIndirectCommandBuffers, + "supportIndirectCommandBuffers"); +_MTL_PRIVATE_DEF_SEL(supportRayTracing, + "supportRayTracing"); +_MTL_PRIVATE_DEF_SEL(supports32BitFloatFiltering, + "supports32BitFloatFiltering"); +_MTL_PRIVATE_DEF_SEL(supports32BitMSAA, + "supports32BitMSAA"); +_MTL_PRIVATE_DEF_SEL(supportsBCTextureCompression, + "supportsBCTextureCompression"); +_MTL_PRIVATE_DEF_SEL(supportsCounterSampling_, + "supportsCounterSampling:"); +_MTL_PRIVATE_DEF_SEL(supportsDestination_, + "supportsDestination:"); +_MTL_PRIVATE_DEF_SEL(supportsDynamicLibraries, + "supportsDynamicLibraries"); +_MTL_PRIVATE_DEF_SEL(supportsFamily_, + "supportsFamily:"); +_MTL_PRIVATE_DEF_SEL(supportsFeatureSet_, + "supportsFeatureSet:"); +_MTL_PRIVATE_DEF_SEL(supportsFunctionPointers, + "supportsFunctionPointers"); +_MTL_PRIVATE_DEF_SEL(supportsFunctionPointersFromRender, + "supportsFunctionPointersFromRender"); +_MTL_PRIVATE_DEF_SEL(supportsPrimitiveMotionBlur, + "supportsPrimitiveMotionBlur"); +_MTL_PRIVATE_DEF_SEL(supportsPullModelInterpolation, + "supportsPullModelInterpolation"); +_MTL_PRIVATE_DEF_SEL(supportsQueryTextureLOD, + "supportsQueryTextureLOD"); +_MTL_PRIVATE_DEF_SEL(supportsRasterizationRateMapWithLayerCount_, + "supportsRasterizationRateMapWithLayerCount:"); +_MTL_PRIVATE_DEF_SEL(supportsRaytracing, + "supportsRaytracing"); +_MTL_PRIVATE_DEF_SEL(supportsRaytracingFromRender, + "supportsRaytracingFromRender"); +_MTL_PRIVATE_DEF_SEL(supportsRenderDynamicLibraries, + "supportsRenderDynamicLibraries"); +_MTL_PRIVATE_DEF_SEL(supportsShaderBarycentricCoordinates, + "supportsShaderBarycentricCoordinates"); +_MTL_PRIVATE_DEF_SEL(supportsTextureSampleCount_, + "supportsTextureSampleCount:"); +_MTL_PRIVATE_DEF_SEL(supportsVertexAmplificationCount_, + "supportsVertexAmplificationCount:"); +_MTL_PRIVATE_DEF_SEL(swizzle, + "swizzle"); +_MTL_PRIVATE_DEF_SEL(synchronizeResource_, + "synchronizeResource:"); +_MTL_PRIVATE_DEF_SEL(synchronizeTexture_slice_level_, + "synchronizeTexture:slice:level:"); +_MTL_PRIVATE_DEF_SEL(tAddressMode, + "tAddressMode"); +_MTL_PRIVATE_DEF_SEL(tailSizeInBytes, + "tailSizeInBytes"); +_MTL_PRIVATE_DEF_SEL(tessellationControlPointIndexType, + "tessellationControlPointIndexType"); +_MTL_PRIVATE_DEF_SEL(tessellationFactorFormat, + "tessellationFactorFormat"); +_MTL_PRIVATE_DEF_SEL(tessellationFactorStepFunction, + "tessellationFactorStepFunction"); +_MTL_PRIVATE_DEF_SEL(tessellationOutputWindingOrder, + "tessellationOutputWindingOrder"); +_MTL_PRIVATE_DEF_SEL(tessellationPartitionMode, + "tessellationPartitionMode"); +_MTL_PRIVATE_DEF_SEL(texture, + "texture"); +_MTL_PRIVATE_DEF_SEL(texture2DDescriptorWithPixelFormat_width_height_mipmapped_, + "texture2DDescriptorWithPixelFormat:width:height:mipmapped:"); +_MTL_PRIVATE_DEF_SEL(textureBarrier, + "textureBarrier"); +_MTL_PRIVATE_DEF_SEL(textureBufferDescriptorWithPixelFormat_width_resourceOptions_usage_, + "textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage:"); +_MTL_PRIVATE_DEF_SEL(textureCubeDescriptorWithPixelFormat_size_mipmapped_, + "textureCubeDescriptorWithPixelFormat:size:mipmapped:"); +_MTL_PRIVATE_DEF_SEL(textureDataType, + "textureDataType"); +_MTL_PRIVATE_DEF_SEL(textureReferenceType, + "textureReferenceType"); +_MTL_PRIVATE_DEF_SEL(textureType, + "textureType"); +_MTL_PRIVATE_DEF_SEL(threadExecutionWidth, + "threadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(threadGroupSizeIsMultipleOfThreadExecutionWidth, + "threadGroupSizeIsMultipleOfThreadExecutionWidth"); +_MTL_PRIVATE_DEF_SEL(threadgroupMemoryAlignment, + "threadgroupMemoryAlignment"); +_MTL_PRIVATE_DEF_SEL(threadgroupMemoryDataSize, + "threadgroupMemoryDataSize"); +_MTL_PRIVATE_DEF_SEL(threadgroupMemoryLength, + "threadgroupMemoryLength"); +_MTL_PRIVATE_DEF_SEL(threadgroupSizeMatchesTileSize, + "threadgroupSizeMatchesTileSize"); +_MTL_PRIVATE_DEF_SEL(tileAdditionalBinaryFunctions, + "tileAdditionalBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(tileArguments, + "tileArguments"); +_MTL_PRIVATE_DEF_SEL(tileBindings, + "tileBindings"); +_MTL_PRIVATE_DEF_SEL(tileBuffers, + "tileBuffers"); +_MTL_PRIVATE_DEF_SEL(tileFunction, + "tileFunction"); +_MTL_PRIVATE_DEF_SEL(tileHeight, + "tileHeight"); +_MTL_PRIVATE_DEF_SEL(tileWidth, + "tileWidth"); +_MTL_PRIVATE_DEF_SEL(transformationMatrixBuffer, + "transformationMatrixBuffer"); +_MTL_PRIVATE_DEF_SEL(transformationMatrixBufferOffset, + "transformationMatrixBufferOffset"); +_MTL_PRIVATE_DEF_SEL(triangleCount, + "triangleCount"); +_MTL_PRIVATE_DEF_SEL(tryCancel, + "tryCancel"); +_MTL_PRIVATE_DEF_SEL(type, + "type"); +_MTL_PRIVATE_DEF_SEL(updateFence_, + "updateFence:"); +_MTL_PRIVATE_DEF_SEL(updateFence_afterStages_, + "updateFence:afterStages:"); +_MTL_PRIVATE_DEF_SEL(updateTextureMapping_mode_indirectBuffer_indirectBufferOffset_, + "updateTextureMapping:mode:indirectBuffer:indirectBufferOffset:"); +_MTL_PRIVATE_DEF_SEL(updateTextureMapping_mode_region_mipLevel_slice_, + "updateTextureMapping:mode:region:mipLevel:slice:"); +_MTL_PRIVATE_DEF_SEL(updateTextureMappings_mode_regions_mipLevels_slices_numRegions_, + "updateTextureMappings:mode:regions:mipLevels:slices:numRegions:"); +_MTL_PRIVATE_DEF_SEL(url, + "url"); +_MTL_PRIVATE_DEF_SEL(usage, + "usage"); +_MTL_PRIVATE_DEF_SEL(useHeap_, + "useHeap:"); +_MTL_PRIVATE_DEF_SEL(useHeap_stages_, + "useHeap:stages:"); +_MTL_PRIVATE_DEF_SEL(useHeaps_count_, + "useHeaps:count:"); +_MTL_PRIVATE_DEF_SEL(useHeaps_count_stages_, + "useHeaps:count:stages:"); +_MTL_PRIVATE_DEF_SEL(useResource_usage_, + "useResource:usage:"); +_MTL_PRIVATE_DEF_SEL(useResource_usage_stages_, + "useResource:usage:stages:"); +_MTL_PRIVATE_DEF_SEL(useResources_count_usage_, + "useResources:count:usage:"); +_MTL_PRIVATE_DEF_SEL(useResources_count_usage_stages_, + "useResources:count:usage:stages:"); +_MTL_PRIVATE_DEF_SEL(usedSize, + "usedSize"); +_MTL_PRIVATE_DEF_SEL(vertexAdditionalBinaryFunctions, + "vertexAdditionalBinaryFunctions"); +_MTL_PRIVATE_DEF_SEL(vertexArguments, + "vertexArguments"); +_MTL_PRIVATE_DEF_SEL(vertexAttributes, + "vertexAttributes"); +_MTL_PRIVATE_DEF_SEL(vertexBindings, + "vertexBindings"); +_MTL_PRIVATE_DEF_SEL(vertexBuffer, + "vertexBuffer"); +_MTL_PRIVATE_DEF_SEL(vertexBufferOffset, + "vertexBufferOffset"); +_MTL_PRIVATE_DEF_SEL(vertexBuffers, + "vertexBuffers"); +_MTL_PRIVATE_DEF_SEL(vertexDescriptor, + "vertexDescriptor"); +_MTL_PRIVATE_DEF_SEL(vertexFormat, + "vertexFormat"); +_MTL_PRIVATE_DEF_SEL(vertexFunction, + "vertexFunction"); +_MTL_PRIVATE_DEF_SEL(vertexLinkedFunctions, + "vertexLinkedFunctions"); +_MTL_PRIVATE_DEF_SEL(vertexPreloadedLibraries, + "vertexPreloadedLibraries"); +_MTL_PRIVATE_DEF_SEL(vertexStride, + "vertexStride"); +_MTL_PRIVATE_DEF_SEL(vertical, + "vertical"); +_MTL_PRIVATE_DEF_SEL(verticalSampleStorage, + "verticalSampleStorage"); +_MTL_PRIVATE_DEF_SEL(visibilityResultBuffer, + "visibilityResultBuffer"); +_MTL_PRIVATE_DEF_SEL(visibleFunctionTableDescriptor, + "visibleFunctionTableDescriptor"); +_MTL_PRIVATE_DEF_SEL(waitForEvent_value_, + "waitForEvent:value:"); +_MTL_PRIVATE_DEF_SEL(waitForFence_, + "waitForFence:"); +_MTL_PRIVATE_DEF_SEL(waitForFence_beforeStages_, + "waitForFence:beforeStages:"); +_MTL_PRIVATE_DEF_SEL(waitUntilCompleted, + "waitUntilCompleted"); +_MTL_PRIVATE_DEF_SEL(waitUntilScheduled, + "waitUntilScheduled"); +_MTL_PRIVATE_DEF_SEL(width, + "width"); +_MTL_PRIVATE_DEF_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_, + "writeCompactedAccelerationStructureSize:toBuffer:offset:"); +_MTL_PRIVATE_DEF_SEL(writeCompactedAccelerationStructureSize_toBuffer_offset_sizeDataType_, + "writeCompactedAccelerationStructureSize:toBuffer:offset:sizeDataType:"); +_MTL_PRIVATE_DEF_SEL(writeMask, + "writeMask"); + +} diff --git a/vendor/metal-cpp/Metal/MTLHeap.hpp b/vendor/metal-cpp/Metal/MTLHeap.hpp new file mode 100644 index 000000000..51af01259 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLHeap.hpp @@ -0,0 +1,329 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLHeap.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLDevice.hpp" +#include "MTLHeap.hpp" +#include "MTLResource.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::Integer, HeapType) { + HeapTypeAutomatic = 0, + HeapTypePlacement = 1, + HeapTypeSparse = 2, +}; + +class HeapDescriptor : public NS::Copying +{ +public: + static class HeapDescriptor* alloc(); + + class HeapDescriptor* init(); + + NS::UInteger size() const; + void setSize(NS::UInteger size); + + MTL::StorageMode storageMode() const; + void setStorageMode(MTL::StorageMode storageMode); + + MTL::CPUCacheMode cpuCacheMode() const; + void setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode); + + MTL::SparsePageSize sparsePageSize() const; + void setSparsePageSize(MTL::SparsePageSize sparsePageSize); + + MTL::HazardTrackingMode hazardTrackingMode() const; + void setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode); + + MTL::ResourceOptions resourceOptions() const; + void setResourceOptions(MTL::ResourceOptions resourceOptions); + + MTL::HeapType type() const; + void setType(MTL::HeapType type); +}; + +class Heap : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + MTL::StorageMode storageMode() const; + + MTL::CPUCacheMode cpuCacheMode() const; + + MTL::HazardTrackingMode hazardTrackingMode() const; + + MTL::ResourceOptions resourceOptions() const; + + NS::UInteger size() const; + + NS::UInteger usedSize() const; + + NS::UInteger currentAllocatedSize() const; + + NS::UInteger maxAvailableSize(NS::UInteger alignment); + + class Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options); + + class Texture* newTexture(const class TextureDescriptor* desc); + + MTL::PurgeableState setPurgeableState(MTL::PurgeableState state); + + MTL::HeapType type() const; + + class Buffer* newBuffer(NS::UInteger length, MTL::ResourceOptions options, NS::UInteger offset); + + class Texture* newTexture(const class TextureDescriptor* descriptor, NS::UInteger offset); + + class AccelerationStructure* newAccelerationStructure(NS::UInteger size); + + class AccelerationStructure* newAccelerationStructure(const class AccelerationStructureDescriptor* descriptor); + + class AccelerationStructure* newAccelerationStructure(NS::UInteger size, NS::UInteger offset); + + class AccelerationStructure* newAccelerationStructure(const class AccelerationStructureDescriptor* descriptor, NS::UInteger offset); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::HeapDescriptor* MTL::HeapDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLHeapDescriptor)); +} + +// method: init +_MTL_INLINE MTL::HeapDescriptor* MTL::HeapDescriptor::init() +{ + return NS::Object::init(); +} + +// property: size +_MTL_INLINE NS::UInteger MTL::HeapDescriptor::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setSize(NS::UInteger size) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSize_), size); +} + +// property: storageMode +_MTL_INLINE MTL::StorageMode MTL::HeapDescriptor::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setStorageMode(MTL::StorageMode storageMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode); +} + +// property: cpuCacheMode +_MTL_INLINE MTL::CPUCacheMode MTL::HeapDescriptor::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCpuCacheMode_), cpuCacheMode); +} + +// property: sparsePageSize +_MTL_INLINE MTL::SparsePageSize MTL::HeapDescriptor::sparsePageSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sparsePageSize)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setSparsePageSize(MTL::SparsePageSize sparsePageSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSparsePageSize_), sparsePageSize); +} + +// property: hazardTrackingMode +_MTL_INLINE MTL::HazardTrackingMode MTL::HeapDescriptor::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setHazardTrackingMode_), hazardTrackingMode); +} + +// property: resourceOptions +_MTL_INLINE MTL::ResourceOptions MTL::HeapDescriptor::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setResourceOptions(MTL::ResourceOptions resourceOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResourceOptions_), resourceOptions); +} + +// property: type +_MTL_INLINE MTL::HeapType MTL::HeapDescriptor::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE void MTL::HeapDescriptor::setType(MTL::HeapType type) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setType_), type); +} + +// property: label +_MTL_INLINE NS::String* MTL::Heap::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Heap::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::Heap::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: storageMode +_MTL_INLINE MTL::StorageMode MTL::Heap::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +// property: cpuCacheMode +_MTL_INLINE MTL::CPUCacheMode MTL::Heap::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +// property: hazardTrackingMode +_MTL_INLINE MTL::HazardTrackingMode MTL::Heap::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +// property: resourceOptions +_MTL_INLINE MTL::ResourceOptions MTL::Heap::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +// property: size +_MTL_INLINE NS::UInteger MTL::Heap::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +// property: usedSize +_MTL_INLINE NS::UInteger MTL::Heap::usedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usedSize)); +} + +// property: currentAllocatedSize +_MTL_INLINE NS::UInteger MTL::Heap::currentAllocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(currentAllocatedSize)); +} + +// method: maxAvailableSizeWithAlignment: +_MTL_INLINE NS::UInteger MTL::Heap::maxAvailableSize(NS::UInteger alignment) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxAvailableSizeWithAlignment_), alignment); +} + +// method: newBufferWithLength:options: +_MTL_INLINE MTL::Buffer* MTL::Heap::newBuffer(NS::UInteger length, MTL::ResourceOptions options) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithLength_options_), length, options); +} + +// method: newTextureWithDescriptor: +_MTL_INLINE MTL::Texture* MTL::Heap::newTexture(const MTL::TextureDescriptor* desc) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_), desc); +} + +// method: setPurgeableState: +_MTL_INLINE MTL::PurgeableState MTL::Heap::setPurgeableState(MTL::PurgeableState state) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(setPurgeableState_), state); +} + +// property: type +_MTL_INLINE MTL::HeapType MTL::Heap::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +// method: newBufferWithLength:options:offset: +_MTL_INLINE MTL::Buffer* MTL::Heap::newBuffer(NS::UInteger length, MTL::ResourceOptions options, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newBufferWithLength_options_offset_), length, options, offset); +} + +// method: newTextureWithDescriptor:offset: +_MTL_INLINE MTL::Texture* MTL::Heap::newTexture(const MTL::TextureDescriptor* descriptor, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_offset_), descriptor, offset); +} + +// method: newAccelerationStructureWithSize: +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(NS::UInteger size) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithSize_), size); +} + +// method: newAccelerationStructureWithDescriptor: +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(const MTL::AccelerationStructureDescriptor* descriptor) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithDescriptor_), descriptor); +} + +// method: newAccelerationStructureWithSize:offset: +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(NS::UInteger size, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithSize_offset_), size, offset); +} + +// method: newAccelerationStructureWithDescriptor:offset: +_MTL_INLINE MTL::AccelerationStructure* MTL::Heap::newAccelerationStructure(const MTL::AccelerationStructureDescriptor* descriptor, NS::UInteger offset) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newAccelerationStructureWithDescriptor_offset_), descriptor, offset); +} diff --git a/vendor/metal-cpp/Metal/MTLIOCommandBuffer.hpp b/vendor/metal-cpp/Metal/MTLIOCommandBuffer.hpp new file mode 100644 index 000000000..fb28f3e7c --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLIOCommandBuffer.hpp @@ -0,0 +1,200 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLIOCommandBuffer.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLIOCommandBuffer.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::Integer, IOStatus) { + IOStatusPending = 0, + IOStatusCancelled = 1, + IOStatusError = 2, + IOStatusComplete = 3, +}; + +using IOCommandBufferHandler = void (^)(class IOCommandBuffer*); + +using IOCommandBufferHandlerFunction = std::function; + +class IOCommandBuffer : public NS::Referencing +{ +public: + void addCompletedHandler(const MTL::IOCommandBufferHandlerFunction& function); + + void addCompletedHandler(const MTL::IOCommandBufferHandler block); + + void loadBytes(const void* pointer, NS::UInteger size, const class IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset); + + void loadBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger size, const class IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset); + + void loadTexture(const class Texture* texture, NS::UInteger slice, NS::UInteger level, MTL::Size size, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Origin destinationOrigin, const class IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset); + + void copyStatusToBuffer(const class Buffer* buffer, NS::UInteger offset); + + void commit(); + + void waitUntilCompleted(); + + void tryCancel(); + + void addBarrier(); + + void pushDebugGroup(const NS::String* string); + + void popDebugGroup(); + + void enqueue(); + + void wait(const class SharedEvent* event, uint64_t value); + + void signalEvent(const class SharedEvent* event, uint64_t value); + + NS::String* label() const; + void setLabel(const NS::String* label); + + MTL::IOStatus status() const; + + NS::Error* error() const; +}; + +} + +_MTL_INLINE void MTL::IOCommandBuffer::addCompletedHandler(const MTL::IOCommandBufferHandlerFunction& function) +{ + __block IOCommandBufferHandlerFunction blockFunction = function; + + addCompletedHandler(^(IOCommandBuffer* pCommandBuffer) { blockFunction(pCommandBuffer); }); +} + +// method: addCompletedHandler: +_MTL_INLINE void MTL::IOCommandBuffer::addCompletedHandler(const MTL::IOCommandBufferHandler block) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addCompletedHandler_), block); +} + +// method: loadBytes:size:sourceHandle:sourceHandleOffset: +_MTL_INLINE void MTL::IOCommandBuffer::loadBytes(const void* pointer, NS::UInteger size, const MTL::IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(loadBytes_size_sourceHandle_sourceHandleOffset_), pointer, size, sourceHandle, sourceHandleOffset); +} + +// method: loadBuffer:offset:size:sourceHandle:sourceHandleOffset: +_MTL_INLINE void MTL::IOCommandBuffer::loadBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger size, const MTL::IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(loadBuffer_offset_size_sourceHandle_sourceHandleOffset_), buffer, offset, size, sourceHandle, sourceHandleOffset); +} + +// method: loadTexture:slice:level:size:sourceBytesPerRow:sourceBytesPerImage:destinationOrigin:sourceHandle:sourceHandleOffset: +_MTL_INLINE void MTL::IOCommandBuffer::loadTexture(const MTL::Texture* texture, NS::UInteger slice, NS::UInteger level, MTL::Size size, NS::UInteger sourceBytesPerRow, NS::UInteger sourceBytesPerImage, MTL::Origin destinationOrigin, const MTL::IOFileHandle* sourceHandle, NS::UInteger sourceHandleOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(loadTexture_slice_level_size_sourceBytesPerRow_sourceBytesPerImage_destinationOrigin_sourceHandle_sourceHandleOffset_), texture, slice, level, size, sourceBytesPerRow, sourceBytesPerImage, destinationOrigin, sourceHandle, sourceHandleOffset); +} + +// method: copyStatusToBuffer:offset: +_MTL_INLINE void MTL::IOCommandBuffer::copyStatusToBuffer(const MTL::Buffer* buffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyStatusToBuffer_offset_), buffer, offset); +} + +// method: commit +_MTL_INLINE void MTL::IOCommandBuffer::commit() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(commit)); +} + +// method: waitUntilCompleted +_MTL_INLINE void MTL::IOCommandBuffer::waitUntilCompleted() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitUntilCompleted)); +} + +// method: tryCancel +_MTL_INLINE void MTL::IOCommandBuffer::tryCancel() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(tryCancel)); +} + +// method: addBarrier +_MTL_INLINE void MTL::IOCommandBuffer::addBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(addBarrier)); +} + +// method: pushDebugGroup: +_MTL_INLINE void MTL::IOCommandBuffer::pushDebugGroup(const NS::String* string) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(pushDebugGroup_), string); +} + +// method: popDebugGroup +_MTL_INLINE void MTL::IOCommandBuffer::popDebugGroup() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(popDebugGroup)); +} + +// method: enqueue +_MTL_INLINE void MTL::IOCommandBuffer::enqueue() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(enqueue)); +} + +// method: waitForEvent:value: +_MTL_INLINE void MTL::IOCommandBuffer::wait(const MTL::SharedEvent* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForEvent_value_), event, value); +} + +// method: signalEvent:value: +_MTL_INLINE void MTL::IOCommandBuffer::signalEvent(const MTL::SharedEvent* event, uint64_t value) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(signalEvent_value_), event, value); +} + +// property: label +_MTL_INLINE NS::String* MTL::IOCommandBuffer::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::IOCommandBuffer::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: status +_MTL_INLINE MTL::IOStatus MTL::IOCommandBuffer::status() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(status)); +} + +// property: error +_MTL_INLINE NS::Error* MTL::IOCommandBuffer::error() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(error)); +} diff --git a/vendor/metal-cpp/Metal/MTLIOCommandQueue.hpp b/vendor/metal-cpp/Metal/MTLIOCommandQueue.hpp new file mode 100644 index 000000000..b5f5d1c22 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLIOCommandQueue.hpp @@ -0,0 +1,225 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLIOCommandQueue.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLIOCommandQueue.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::Integer, IOPriority) { + IOPriorityHigh = 0, + IOPriorityNormal = 1, + IOPriorityLow = 2, +}; + +_MTL_ENUM(NS::Integer, IOCommandQueueType) { + IOCommandQueueTypeConcurrent = 0, + IOCommandQueueTypeSerial = 1, +}; + +_MTL_CONST(NS::ErrorDomain, IOErrorDomain); + +_MTL_ENUM(NS::Integer, IOError) { + IOErrorURLInvalid = 1, + IOErrorInternal = 2, +}; + +class IOCommandQueue : public NS::Referencing +{ +public: + void enqueueBarrier(); + + class IOCommandBuffer* commandBuffer(); + + class IOCommandBuffer* commandBufferWithUnretainedReferences(); + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class IOScratchBuffer : public NS::Referencing +{ +public: + class Buffer* buffer() const; +}; + +class IOScratchBufferAllocator : public NS::Referencing +{ +public: + class IOScratchBuffer* newScratchBuffer(NS::UInteger minimumSize); +}; + +class IOCommandQueueDescriptor : public NS::Copying +{ +public: + static class IOCommandQueueDescriptor* alloc(); + + class IOCommandQueueDescriptor* init(); + + NS::UInteger maxCommandBufferCount() const; + void setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount); + + MTL::IOPriority priority() const; + void setPriority(MTL::IOPriority priority); + + MTL::IOCommandQueueType type() const; + void setType(MTL::IOCommandQueueType type); + + NS::UInteger maxCommandsInFlight() const; + void setMaxCommandsInFlight(NS::UInteger maxCommandsInFlight); + + class IOScratchBufferAllocator* scratchBufferAllocator() const; + void setScratchBufferAllocator(const class IOScratchBufferAllocator* scratchBufferAllocator); +}; + +class IOFileHandle : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +} + +// method: enqueueBarrier +_MTL_INLINE void MTL::IOCommandQueue::enqueueBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(enqueueBarrier)); +} + +// method: commandBuffer +_MTL_INLINE MTL::IOCommandBuffer* MTL::IOCommandQueue::commandBuffer() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBuffer)); +} + +// method: commandBufferWithUnretainedReferences +_MTL_INLINE MTL::IOCommandBuffer* MTL::IOCommandQueue::commandBufferWithUnretainedReferences() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandBufferWithUnretainedReferences)); +} + +// property: label +_MTL_INLINE NS::String* MTL::IOCommandQueue::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::IOCommandQueue::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: buffer +_MTL_INLINE MTL::Buffer* MTL::IOScratchBuffer::buffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffer)); +} + +// method: newScratchBufferWithMinimumSize: +_MTL_INLINE MTL::IOScratchBuffer* MTL::IOScratchBufferAllocator::newScratchBuffer(NS::UInteger minimumSize) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newScratchBufferWithMinimumSize_), minimumSize); +} + +// static method: alloc +_MTL_INLINE MTL::IOCommandQueueDescriptor* MTL::IOCommandQueueDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIOCommandQueueDescriptor)); +} + +// method: init +_MTL_INLINE MTL::IOCommandQueueDescriptor* MTL::IOCommandQueueDescriptor::init() +{ + return NS::Object::init(); +} + +// property: maxCommandBufferCount +_MTL_INLINE NS::UInteger MTL::IOCommandQueueDescriptor::maxCommandBufferCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCommandBufferCount)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setMaxCommandBufferCount(NS::UInteger maxCommandBufferCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCommandBufferCount_), maxCommandBufferCount); +} + +// property: priority +_MTL_INLINE MTL::IOPriority MTL::IOCommandQueueDescriptor::priority() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(priority)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setPriority(MTL::IOPriority priority) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPriority_), priority); +} + +// property: type +_MTL_INLINE MTL::IOCommandQueueType MTL::IOCommandQueueDescriptor::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setType(MTL::IOCommandQueueType type) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setType_), type); +} + +// property: maxCommandsInFlight +_MTL_INLINE NS::UInteger MTL::IOCommandQueueDescriptor::maxCommandsInFlight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCommandsInFlight)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setMaxCommandsInFlight(NS::UInteger maxCommandsInFlight) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCommandsInFlight_), maxCommandsInFlight); +} + +// property: scratchBufferAllocator +_MTL_INLINE MTL::IOScratchBufferAllocator* MTL::IOCommandQueueDescriptor::scratchBufferAllocator() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(scratchBufferAllocator)); +} + +_MTL_INLINE void MTL::IOCommandQueueDescriptor::setScratchBufferAllocator(const MTL::IOScratchBufferAllocator* scratchBufferAllocator) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScratchBufferAllocator_), scratchBufferAllocator); +} + +// property: label +_MTL_INLINE NS::String* MTL::IOFileHandle::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::IOFileHandle::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} diff --git a/vendor/metal-cpp/Metal/MTLIOCompressor.hpp b/vendor/metal-cpp/Metal/MTLIOCompressor.hpp new file mode 100644 index 000000000..7719beccd --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLIOCompressor.hpp @@ -0,0 +1,92 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLIOCompressor.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" +#include "MTLDevice.hpp" + +#include + +namespace MTL +{ +_MTL_ENUM(NS::Integer, IOCompressionStatus) { + IOCompressionStatusComplete = 0, + IOCompressionStatusError = 1, +}; + +size_t IOCompressionContextDefaultChunkSize(); + +void* IOCreateCompressionContext(const char* path, IOCompressionMethod type, size_t chunkSize); + +void IOCompressionContextAppendData(void* context, const void* data, size_t size); + +IOCompressionStatus IOFlushAndDestroyCompressionContext(void* context); + +} + +#if defined(MTL_PRIVATE_IMPLEMENTATION) + +namespace MTL::Private { + +MTL_DEF_FUNC(MTLIOCompressionContextDefaultChunkSize, size_t (*)(void)); + +MTL_DEF_FUNC( MTLIOCreateCompressionContext, void* (*)(const char*, MTL::IOCompressionMethod, size_t) ); + +MTL_DEF_FUNC( MTLIOCompressionContextAppendData, void (*)(void*, const void*, size_t) ); + +MTL_DEF_FUNC( MTLIOFlushAndDestroyCompressionContext, MTL::IOCompressionStatus (*)(void*) ); + +} + +_NS_EXPORT size_t MTL::IOCompressionContextDefaultChunkSize() +{ + return MTL::Private::MTLIOCompressionContextDefaultChunkSize(); +} + +_NS_EXPORT void* MTL::IOCreateCompressionContext(const char* path, IOCompressionMethod type, size_t chunkSize) +{ + if ( MTL::Private::MTLIOCreateCompressionContext ) + { + return MTL::Private::MTLIOCreateCompressionContext( path, type, chunkSize ); + } + return nullptr; +} + +_NS_EXPORT void MTL::IOCompressionContextAppendData(void* context, const void* data, size_t size) +{ + if ( MTL::Private::MTLIOCompressionContextAppendData ) + { + MTL::Private::MTLIOCompressionContextAppendData( context, data, size ); + } +} + +_NS_EXPORT MTL::IOCompressionStatus MTL::IOFlushAndDestroyCompressionContext(void* context) +{ + if ( MTL::Private::MTLIOFlushAndDestroyCompressionContext ) + { + return MTL::Private::MTLIOFlushAndDestroyCompressionContext( context ); + } + return MTL::IOCompressionStatusError; +} + +#endif diff --git a/vendor/metal-cpp/Metal/MTLIndirectCommandBuffer.hpp b/vendor/metal-cpp/Metal/MTLIndirectCommandBuffer.hpp new file mode 100644 index 000000000..e933083cf --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLIndirectCommandBuffer.hpp @@ -0,0 +1,212 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLIndirectCommandBuffer.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLIndirectCommandBuffer.hpp" +#include "MTLResource.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, IndirectCommandType) { + IndirectCommandTypeDraw = 1, + IndirectCommandTypeDrawIndexed = 2, + IndirectCommandTypeDrawPatches = 4, + IndirectCommandTypeDrawIndexedPatches = 8, + IndirectCommandTypeConcurrentDispatch = 32, + IndirectCommandTypeConcurrentDispatchThreads = 64, +}; + +struct IndirectCommandBufferExecutionRange +{ + uint32_t location; + uint32_t length; +} _MTL_PACKED; + +class IndirectCommandBufferDescriptor : public NS::Copying +{ +public: + static class IndirectCommandBufferDescriptor* alloc(); + + class IndirectCommandBufferDescriptor* init(); + + MTL::IndirectCommandType commandTypes() const; + void setCommandTypes(MTL::IndirectCommandType commandTypes); + + bool inheritPipelineState() const; + void setInheritPipelineState(bool inheritPipelineState); + + bool inheritBuffers() const; + void setInheritBuffers(bool inheritBuffers); + + NS::UInteger maxVertexBufferBindCount() const; + void setMaxVertexBufferBindCount(NS::UInteger maxVertexBufferBindCount); + + NS::UInteger maxFragmentBufferBindCount() const; + void setMaxFragmentBufferBindCount(NS::UInteger maxFragmentBufferBindCount); + + NS::UInteger maxKernelBufferBindCount() const; + void setMaxKernelBufferBindCount(NS::UInteger maxKernelBufferBindCount); + + bool supportRayTracing() const; + void setSupportRayTracing(bool supportRayTracing); +}; + +class IndirectCommandBuffer : public NS::Referencing +{ +public: + NS::UInteger size() const; + + MTL::ResourceID gpuResourceID() const; + + void reset(NS::Range range); + + class IndirectRenderCommand* indirectRenderCommand(NS::UInteger commandIndex); + + class IndirectComputeCommand* indirectComputeCommand(NS::UInteger commandIndex); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::IndirectCommandBufferDescriptor* MTL::IndirectCommandBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIndirectCommandBufferDescriptor)); +} + +// method: init +_MTL_INLINE MTL::IndirectCommandBufferDescriptor* MTL::IndirectCommandBufferDescriptor::init() +{ + return NS::Object::init(); +} + +// property: commandTypes +_MTL_INLINE MTL::IndirectCommandType MTL::IndirectCommandBufferDescriptor::commandTypes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(commandTypes)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setCommandTypes(MTL::IndirectCommandType commandTypes) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCommandTypes_), commandTypes); +} + +// property: inheritPipelineState +_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::inheritPipelineState() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(inheritPipelineState)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setInheritPipelineState(bool inheritPipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInheritPipelineState_), inheritPipelineState); +} + +// property: inheritBuffers +_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::inheritBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(inheritBuffers)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setInheritBuffers(bool inheritBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInheritBuffers_), inheritBuffers); +} + +// property: maxVertexBufferBindCount +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxVertexBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxVertexBufferBindCount(NS::UInteger maxVertexBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexBufferBindCount_), maxVertexBufferBindCount); +} + +// property: maxFragmentBufferBindCount +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxFragmentBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxFragmentBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxFragmentBufferBindCount(NS::UInteger maxFragmentBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxFragmentBufferBindCount_), maxFragmentBufferBindCount); +} + +// property: maxKernelBufferBindCount +_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxKernelBufferBindCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxKernelBufferBindCount)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxKernelBufferBindCount(NS::UInteger maxKernelBufferBindCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxKernelBufferBindCount_), maxKernelBufferBindCount); +} + +// property: supportRayTracing +_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::supportRayTracing() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportRayTracing)); +} + +_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setSupportRayTracing(bool supportRayTracing) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportRayTracing_), supportRayTracing); +} + +// property: size +_MTL_INLINE NS::UInteger MTL::IndirectCommandBuffer::size() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(size)); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::IndirectCommandBuffer::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +// method: resetWithRange: +_MTL_INLINE void MTL::IndirectCommandBuffer::reset(NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(resetWithRange_), range); +} + +// method: indirectRenderCommandAtIndex: +_MTL_INLINE MTL::IndirectRenderCommand* MTL::IndirectCommandBuffer::indirectRenderCommand(NS::UInteger commandIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indirectRenderCommandAtIndex_), commandIndex); +} + +// method: indirectComputeCommandAtIndex: +_MTL_INLINE MTL::IndirectComputeCommand* MTL::IndirectCommandBuffer::indirectComputeCommand(NS::UInteger commandIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indirectComputeCommandAtIndex_), commandIndex); +} diff --git a/vendor/metal-cpp/Metal/MTLIndirectCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLIndirectCommandEncoder.hpp new file mode 100644 index 000000000..50ee75328 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLIndirectCommandEncoder.hpp @@ -0,0 +1,187 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLIndirectCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLRenderCommandEncoder.hpp" +#include "MTLStageInputOutputDescriptor.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +class IndirectRenderCommand : public NS::Referencing +{ +public: + void setRenderPipelineState(const class RenderPipelineState* pipelineState); + + void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setFragmentBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const class Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride); + + void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const class Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance); + + void reset(); +}; + +class IndirectComputeCommand : public NS::Referencing +{ +public: + void setComputePipelineState(const class ComputePipelineState* pipelineState); + + void setKernelBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void concurrentDispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup); + + void concurrentDispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup); + + void setBarrier(); + + void clearBarrier(); + + void setImageblockWidth(NS::UInteger width, NS::UInteger height); + + void reset(); + + void setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index); + + void setStageInRegion(MTL::Region region); +}; + +} + +// method: setRenderPipelineState: +_MTL_INLINE void MTL::IndirectRenderCommand::setRenderPipelineState(const MTL::RenderPipelineState* pipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineState_), pipelineState); +} + +// method: setVertexBuffer:offset:atIndex: +_MTL_INLINE void MTL::IndirectRenderCommand::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setFragmentBuffer:offset:atIndex: +_MTL_INLINE void MTL::IndirectRenderCommand::setFragmentBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride: +_MTL_INLINE void MTL::IndirectRenderCommand::drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance, buffer, offset, instanceStride); +} + +// method: drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride: +_MTL_INLINE void MTL::IndirectRenderCommand::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance, const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_tessellationFactorBuffer_tessellationFactorBufferOffset_tessellationFactorBufferInstanceStride_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, instanceCount, baseInstance, buffer, offset, instanceStride); +} + +// method: drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance: +_MTL_INLINE void MTL::IndirectRenderCommand::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance_), primitiveType, vertexStart, vertexCount, instanceCount, baseInstance); +} + +// method: drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance: +_MTL_INLINE void MTL::IndirectRenderCommand::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance); +} + +// method: reset +_MTL_INLINE void MTL::IndirectRenderCommand::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +// method: setComputePipelineState: +_MTL_INLINE void MTL::IndirectComputeCommand::setComputePipelineState(const MTL::ComputePipelineState* pipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setComputePipelineState_), pipelineState); +} + +// method: setKernelBuffer:offset:atIndex: +_MTL_INLINE void MTL::IndirectComputeCommand::setKernelBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setKernelBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: concurrentDispatchThreadgroups:threadsPerThreadgroup: +_MTL_INLINE void MTL::IndirectComputeCommand::concurrentDispatchThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(concurrentDispatchThreadgroups_threadsPerThreadgroup_), threadgroupsPerGrid, threadsPerThreadgroup); +} + +// method: concurrentDispatchThreads:threadsPerThreadgroup: +_MTL_INLINE void MTL::IndirectComputeCommand::concurrentDispatchThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(concurrentDispatchThreads_threadsPerThreadgroup_), threadsPerGrid, threadsPerThreadgroup); +} + +// method: setBarrier +_MTL_INLINE void MTL::IndirectComputeCommand::setBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBarrier)); +} + +// method: clearBarrier +_MTL_INLINE void MTL::IndirectComputeCommand::clearBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(clearBarrier)); +} + +// method: setImageblockWidth:height: +_MTL_INLINE void MTL::IndirectComputeCommand::setImageblockWidth(NS::UInteger width, NS::UInteger height) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setImageblockWidth_height_), width, height); +} + +// method: reset +_MTL_INLINE void MTL::IndirectComputeCommand::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +// method: setThreadgroupMemoryLength:atIndex: +_MTL_INLINE void MTL::IndirectComputeCommand::setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_atIndex_), length, index); +} + +// method: setStageInRegion: +_MTL_INLINE void MTL::IndirectComputeCommand::setStageInRegion(MTL::Region region) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStageInRegion_), region); +} diff --git a/vendor/metal-cpp/Metal/MTLIntersectionFunctionTable.hpp b/vendor/metal-cpp/Metal/MTLIntersectionFunctionTable.hpp new file mode 100644 index 000000000..68322c342 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLIntersectionFunctionTable.hpp @@ -0,0 +1,163 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLIntersectionFunctionTable.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLIntersectionFunctionTable.hpp" +#include "MTLResource.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_OPTIONS(NS::UInteger, IntersectionFunctionSignature) { + IntersectionFunctionSignatureNone = 0, + IntersectionFunctionSignatureInstancing = 1, + IntersectionFunctionSignatureTriangleData = 2, + IntersectionFunctionSignatureWorldSpaceData = 4, + IntersectionFunctionSignatureInstanceMotion = 8, + IntersectionFunctionSignaturePrimitiveMotion = 16, + IntersectionFunctionSignatureExtendedLimits = 32, +}; + +class IntersectionFunctionTableDescriptor : public NS::Copying +{ +public: + static class IntersectionFunctionTableDescriptor* alloc(); + + class IntersectionFunctionTableDescriptor* init(); + + static class IntersectionFunctionTableDescriptor* intersectionFunctionTableDescriptor(); + + NS::UInteger functionCount() const; + void setFunctionCount(NS::UInteger functionCount); +}; + +class IntersectionFunctionTable : public NS::Referencing +{ +public: + void setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + MTL::ResourceID gpuResourceID() const; + + void setFunction(const class FunctionHandle* function, NS::UInteger index); + + void setFunctions(const class FunctionHandle* const functions[], NS::Range range); + + void setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index); + + void setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range); + + void setVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range bufferRange); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIntersectionFunctionTableDescriptor)); +} + +// method: init +_MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: intersectionFunctionTableDescriptor +_MTL_INLINE MTL::IntersectionFunctionTableDescriptor* MTL::IntersectionFunctionTableDescriptor::intersectionFunctionTableDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLIntersectionFunctionTableDescriptor), _MTL_PRIVATE_SEL(intersectionFunctionTableDescriptor)); +} + +// property: functionCount +_MTL_INLINE NS::UInteger MTL::IntersectionFunctionTableDescriptor::functionCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionCount)); +} + +_MTL_INLINE void MTL::IntersectionFunctionTableDescriptor::setFunctionCount(NS::UInteger functionCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionCount_), functionCount); +} + +// method: setBuffer:offset:atIndex: +_MTL_INLINE void MTL::IntersectionFunctionTable::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setBuffers:offsets:withRange: +_MTL_INLINE void MTL::IntersectionFunctionTable::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_withRange_), buffers, offsets, range); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::IntersectionFunctionTable::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +// method: setFunction:atIndex: +_MTL_INLINE void MTL::IntersectionFunctionTable::setFunction(const MTL::FunctionHandle* function, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunction_atIndex_), function, index); +} + +// method: setFunctions:withRange: +_MTL_INLINE void MTL::IntersectionFunctionTable::setFunctions(const MTL::FunctionHandle* const functions[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_withRange_), functions, range); +} + +// method: setOpaqueTriangleIntersectionFunctionWithSignature:atIndex: +_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_atIndex_), signature, index); +} + +// method: setOpaqueTriangleIntersectionFunctionWithSignature:withRange: +_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueTriangleIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueTriangleIntersectionFunctionWithSignature_withRange_), signature, range); +} + +// method: setVisibleFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::IntersectionFunctionTable::setVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +// method: setVisibleFunctionTables:withBufferRange: +_MTL_INLINE void MTL::IntersectionFunctionTable::setVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range bufferRange) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibleFunctionTables_withBufferRange_), functionTables, bufferRange); +} diff --git a/vendor/metal-cpp/Metal/MTLLibrary.hpp b/vendor/metal-cpp/Metal/MTLLibrary.hpp new file mode 100644 index 000000000..234373d4b --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLLibrary.hpp @@ -0,0 +1,691 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLLibrary.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLArgument.hpp" +#include "MTLFunctionDescriptor.hpp" +#include "MTLLibrary.hpp" +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PatchType) { + PatchTypeNone = 0, + PatchTypeTriangle = 1, + PatchTypeQuad = 2, +}; + +class VertexAttribute : public NS::Referencing +{ +public: + static class VertexAttribute* alloc(); + + class VertexAttribute* init(); + + NS::String* name() const; + + NS::UInteger attributeIndex() const; + + MTL::DataType attributeType() const; + + bool active() const; + + bool patchData() const; + + bool patchControlPointData() const; +}; + +class Attribute : public NS::Referencing +{ +public: + static class Attribute* alloc(); + + class Attribute* init(); + + NS::String* name() const; + + NS::UInteger attributeIndex() const; + + MTL::DataType attributeType() const; + + bool active() const; + + bool patchData() const; + + bool patchControlPointData() const; +}; + +_MTL_ENUM(NS::UInteger, FunctionType) { + FunctionTypeVertex = 1, + FunctionTypeFragment = 2, + FunctionTypeKernel = 3, + FunctionTypeVisible = 5, + FunctionTypeIntersection = 6, + FunctionTypeMesh = 7, + FunctionTypeObject = 8, +}; + +class FunctionConstant : public NS::Referencing +{ +public: + static class FunctionConstant* alloc(); + + class FunctionConstant* init(); + + NS::String* name() const; + + MTL::DataType type() const; + + NS::UInteger index() const; + + bool required() const; +}; + +using AutoreleasedArgument = class Argument*; + +class Function : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + MTL::FunctionType functionType() const; + + MTL::PatchType patchType() const; + + NS::Integer patchControlPointCount() const; + + NS::Array* vertexAttributes() const; + + NS::Array* stageInputAttributes() const; + + NS::String* name() const; + + NS::Dictionary* functionConstantsDictionary() const; + + class ArgumentEncoder* newArgumentEncoder(NS::UInteger bufferIndex); + + class ArgumentEncoder* newArgumentEncoder(NS::UInteger bufferIndex, const MTL::AutoreleasedArgument* reflection); + + MTL::FunctionOptions options() const; +}; + +_MTL_ENUM(NS::UInteger, LanguageVersion) { + LanguageVersion1_0 = 65536, + LanguageVersion1_1 = 65537, + LanguageVersion1_2 = 65538, + LanguageVersion2_0 = 131072, + LanguageVersion2_1 = 131073, + LanguageVersion2_2 = 131074, + LanguageVersion2_3 = 131075, + LanguageVersion2_4 = 131076, + LanguageVersion3_0 = 196608, +}; + +_MTL_ENUM(NS::Integer, LibraryType) { + LibraryTypeExecutable = 0, + LibraryTypeDynamic = 1, +}; + +_MTL_ENUM(NS::Integer, LibraryOptimizationLevel) { + LibraryOptimizationLevelDefault = 0, + LibraryOptimizationLevelSize = 1, +}; + +_MTL_ENUM(NS::Integer, CompileSymbolVisibility) { + CompileSymbolVisibilityDefault = 0, + CompileSymbolVisibilityHidden = 1, +}; + +class CompileOptions : public NS::Copying +{ +public: + static class CompileOptions* alloc(); + + class CompileOptions* init(); + + NS::Dictionary* preprocessorMacros() const; + void setPreprocessorMacros(const NS::Dictionary* preprocessorMacros); + + bool fastMathEnabled() const; + void setFastMathEnabled(bool fastMathEnabled); + + MTL::LanguageVersion languageVersion() const; + void setLanguageVersion(MTL::LanguageVersion languageVersion); + + MTL::LibraryType libraryType() const; + void setLibraryType(MTL::LibraryType libraryType); + + NS::String* installName() const; + void setInstallName(const NS::String* installName); + + NS::Array* libraries() const; + void setLibraries(const NS::Array* libraries); + + bool preserveInvariance() const; + void setPreserveInvariance(bool preserveInvariance); + + MTL::LibraryOptimizationLevel optimizationLevel() const; + void setOptimizationLevel(MTL::LibraryOptimizationLevel optimizationLevel); + + MTL::CompileSymbolVisibility compileSymbolVisibility() const; + void setCompileSymbolVisibility(MTL::CompileSymbolVisibility compileSymbolVisibility); + + bool allowReferencingUndefinedSymbols() const; + void setAllowReferencingUndefinedSymbols(bool allowReferencingUndefinedSymbols); + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup); +}; + +_MTL_ENUM(NS::UInteger, LibraryError) { + LibraryErrorUnsupported = 1, + LibraryErrorInternal = 2, + LibraryErrorCompileFailure = 3, + LibraryErrorCompileWarning = 4, + LibraryErrorFunctionNotFound = 5, + LibraryErrorFileNotFound = 6, +}; + +class Library : public NS::Referencing +{ +public: + void newFunction(const NS::String* pFunctionName, const class FunctionConstantValues* pConstantValues, const std::function& completionHandler); + + void newFunction(const class FunctionDescriptor* pDescriptor, const std::function& completionHandler); + + void newIntersectionFunction(const class IntersectionFunctionDescriptor* pDescriptor, const std::function& completionHandler); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + class Function* newFunction(const NS::String* functionName); + + class Function* newFunction(const NS::String* name, const class FunctionConstantValues* constantValues, NS::Error** error); + + void newFunction(const NS::String* name, const class FunctionConstantValues* constantValues, void (^completionHandler)(MTL::Function*, NS::Error*)); + + void newFunction(const class FunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)); + + class Function* newFunction(const class FunctionDescriptor* descriptor, NS::Error** error); + + void newIntersectionFunction(const class IntersectionFunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)); + + class Function* newIntersectionFunction(const class IntersectionFunctionDescriptor* descriptor, NS::Error** error); + + NS::Array* functionNames() const; + + MTL::LibraryType type() const; + + NS::String* installName() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::VertexAttribute* MTL::VertexAttribute::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexAttribute)); +} + +// method: init +_MTL_INLINE MTL::VertexAttribute* MTL::VertexAttribute::init() +{ + return NS::Object::init(); +} + +// property: name +_MTL_INLINE NS::String* MTL::VertexAttribute::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: attributeIndex +_MTL_INLINE NS::UInteger MTL::VertexAttribute::attributeIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeIndex)); +} + +// property: attributeType +_MTL_INLINE MTL::DataType MTL::VertexAttribute::attributeType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeType)); +} + +// property: active +_MTL_INLINE bool MTL::VertexAttribute::active() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isActive)); +} + +// property: patchData +_MTL_INLINE bool MTL::VertexAttribute::patchData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchData)); +} + +// property: patchControlPointData +_MTL_INLINE bool MTL::VertexAttribute::patchControlPointData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchControlPointData)); +} + +// static method: alloc +_MTL_INLINE MTL::Attribute* MTL::Attribute::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAttribute)); +} + +// method: init +_MTL_INLINE MTL::Attribute* MTL::Attribute::init() +{ + return NS::Object::init(); +} + +// property: name +_MTL_INLINE NS::String* MTL::Attribute::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: attributeIndex +_MTL_INLINE NS::UInteger MTL::Attribute::attributeIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeIndex)); +} + +// property: attributeType +_MTL_INLINE MTL::DataType MTL::Attribute::attributeType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributeType)); +} + +// property: active +_MTL_INLINE bool MTL::Attribute::active() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isActive)); +} + +// property: patchData +_MTL_INLINE bool MTL::Attribute::patchData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchData)); +} + +// property: patchControlPointData +_MTL_INLINE bool MTL::Attribute::patchControlPointData() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isPatchControlPointData)); +} + +// static method: alloc +_MTL_INLINE MTL::FunctionConstant* MTL::FunctionConstant::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLFunctionConstant)); +} + +// method: init +_MTL_INLINE MTL::FunctionConstant* MTL::FunctionConstant::init() +{ + return NS::Object::init(); +} + +// property: name +_MTL_INLINE NS::String* MTL::FunctionConstant::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: type +_MTL_INLINE MTL::DataType MTL::FunctionConstant::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +// property: index +_MTL_INLINE NS::UInteger MTL::FunctionConstant::index() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(index)); +} + +// property: required +_MTL_INLINE bool MTL::FunctionConstant::required() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(required)); +} + +// property: label +_MTL_INLINE NS::String* MTL::Function::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Function::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::Function::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: functionType +_MTL_INLINE MTL::FunctionType MTL::Function::functionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionType)); +} + +// property: patchType +_MTL_INLINE MTL::PatchType MTL::Function::patchType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(patchType)); +} + +// property: patchControlPointCount +_MTL_INLINE NS::Integer MTL::Function::patchControlPointCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(patchControlPointCount)); +} + +// property: vertexAttributes +_MTL_INLINE NS::Array* MTL::Function::vertexAttributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexAttributes)); +} + +// property: stageInputAttributes +_MTL_INLINE NS::Array* MTL::Function::stageInputAttributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stageInputAttributes)); +} + +// property: name +_MTL_INLINE NS::String* MTL::Function::name() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); +} + +// property: functionConstantsDictionary +_MTL_INLINE NS::Dictionary* MTL::Function::functionConstantsDictionary() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionConstantsDictionary)); +} + +// method: newArgumentEncoderWithBufferIndex: +_MTL_INLINE MTL::ArgumentEncoder* MTL::Function::newArgumentEncoder(NS::UInteger bufferIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferIndex_), bufferIndex); +} + +// method: newArgumentEncoderWithBufferIndex:reflection: +_MTL_INLINE MTL::ArgumentEncoder* MTL::Function::newArgumentEncoder(NS::UInteger bufferIndex, const MTL::AutoreleasedArgument* reflection) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferIndex_reflection_), bufferIndex, reflection); +} + +// property: options +_MTL_INLINE MTL::FunctionOptions MTL::Function::options() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(options)); +} + +// static method: alloc +_MTL_INLINE MTL::CompileOptions* MTL::CompileOptions::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLCompileOptions)); +} + +// method: init +_MTL_INLINE MTL::CompileOptions* MTL::CompileOptions::init() +{ + return NS::Object::init(); +} + +// property: preprocessorMacros +_MTL_INLINE NS::Dictionary* MTL::CompileOptions::preprocessorMacros() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preprocessorMacros)); +} + +_MTL_INLINE void MTL::CompileOptions::setPreprocessorMacros(const NS::Dictionary* preprocessorMacros) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreprocessorMacros_), preprocessorMacros); +} + +// property: fastMathEnabled +_MTL_INLINE bool MTL::CompileOptions::fastMathEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fastMathEnabled)); +} + +_MTL_INLINE void MTL::CompileOptions::setFastMathEnabled(bool fastMathEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFastMathEnabled_), fastMathEnabled); +} + +// property: languageVersion +_MTL_INLINE MTL::LanguageVersion MTL::CompileOptions::languageVersion() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(languageVersion)); +} + +_MTL_INLINE void MTL::CompileOptions::setLanguageVersion(MTL::LanguageVersion languageVersion) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLanguageVersion_), languageVersion); +} + +// property: libraryType +_MTL_INLINE MTL::LibraryType MTL::CompileOptions::libraryType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(libraryType)); +} + +_MTL_INLINE void MTL::CompileOptions::setLibraryType(MTL::LibraryType libraryType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLibraryType_), libraryType); +} + +// property: installName +_MTL_INLINE NS::String* MTL::CompileOptions::installName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(installName)); +} + +_MTL_INLINE void MTL::CompileOptions::setInstallName(const NS::String* installName) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstallName_), installName); +} + +// property: libraries +_MTL_INLINE NS::Array* MTL::CompileOptions::libraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(libraries)); +} + +_MTL_INLINE void MTL::CompileOptions::setLibraries(const NS::Array* libraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLibraries_), libraries); +} + +// property: preserveInvariance +_MTL_INLINE bool MTL::CompileOptions::preserveInvariance() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preserveInvariance)); +} + +_MTL_INLINE void MTL::CompileOptions::setPreserveInvariance(bool preserveInvariance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreserveInvariance_), preserveInvariance); +} + +// property: optimizationLevel +_MTL_INLINE MTL::LibraryOptimizationLevel MTL::CompileOptions::optimizationLevel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(optimizationLevel)); +} + +_MTL_INLINE void MTL::CompileOptions::setOptimizationLevel(MTL::LibraryOptimizationLevel optimizationLevel) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOptimizationLevel_), optimizationLevel); +} + +// property: compileSymbolVisibility +_MTL_INLINE MTL::CompileSymbolVisibility MTL::CompileOptions::compileSymbolVisibility() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compileSymbolVisibility)); +} + +_MTL_INLINE void MTL::CompileOptions::setCompileSymbolVisibility(MTL::CompileSymbolVisibility compileSymbolVisibility) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCompileSymbolVisibility_), compileSymbolVisibility); +} + +// property: allowReferencingUndefinedSymbols +_MTL_INLINE bool MTL::CompileOptions::allowReferencingUndefinedSymbols() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowReferencingUndefinedSymbols)); +} + +_MTL_INLINE void MTL::CompileOptions::setAllowReferencingUndefinedSymbols(bool allowReferencingUndefinedSymbols) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAllowReferencingUndefinedSymbols_), allowReferencingUndefinedSymbols); +} + +// property: maxTotalThreadsPerThreadgroup +_MTL_INLINE NS::UInteger MTL::CompileOptions::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE void MTL::CompileOptions::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup); +} + +_MTL_INLINE void MTL::Library::newFunction(const NS::String* pFunctionName, const FunctionConstantValues* pConstantValues, const std::function& completionHandler) +{ + __block std::function blockCompletionHandler = completionHandler; + + newFunction(pFunctionName, pConstantValues, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); +} + +_MTL_INLINE void MTL::Library::newFunction(const FunctionDescriptor* pDescriptor, const std::function& completionHandler) +{ + __block std::function blockCompletionHandler = completionHandler; + + newFunction(pDescriptor, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); +} + +_MTL_INLINE void MTL::Library::newIntersectionFunction(const IntersectionFunctionDescriptor* pDescriptor, const std::function& completionHandler) +{ + __block std::function blockCompletionHandler = completionHandler; + + newIntersectionFunction(pDescriptor, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); +} + +// property: label +_MTL_INLINE NS::String* MTL::Library::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Library::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::Library::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// method: newFunctionWithName: +_MTL_INLINE MTL::Function* MTL::Library::newFunction(const NS::String* functionName) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithName_), functionName); +} + +// method: newFunctionWithName:constantValues:error: +_MTL_INLINE MTL::Function* MTL::Library::newFunction(const NS::String* name, const MTL::FunctionConstantValues* constantValues, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithName_constantValues_error_), name, constantValues, error); +} + +// method: newFunctionWithName:constantValues:completionHandler: +_MTL_INLINE void MTL::Library::newFunction(const NS::String* name, const MTL::FunctionConstantValues* constantValues, void (^completionHandler)(MTL::Function*, NS::Error*)) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithName_constantValues_completionHandler_), name, constantValues, completionHandler); +} + +// method: newFunctionWithDescriptor:completionHandler: +_MTL_INLINE void MTL::Library::newFunction(const MTL::FunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithDescriptor_completionHandler_), descriptor, completionHandler); +} + +// method: newFunctionWithDescriptor:error: +_MTL_INLINE MTL::Function* MTL::Library::newFunction(const MTL::FunctionDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newFunctionWithDescriptor_error_), descriptor, error); +} + +// method: newIntersectionFunctionWithDescriptor:completionHandler: +_MTL_INLINE void MTL::Library::newIntersectionFunction(const MTL::IntersectionFunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionWithDescriptor_completionHandler_), descriptor, completionHandler); +} + +// method: newIntersectionFunctionWithDescriptor:error: +_MTL_INLINE MTL::Function* MTL::Library::newIntersectionFunction(const MTL::IntersectionFunctionDescriptor* descriptor, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionWithDescriptor_error_), descriptor, error); +} + +// property: functionNames +_MTL_INLINE NS::Array* MTL::Library::functionNames() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionNames)); +} + +// property: type +_MTL_INLINE MTL::LibraryType MTL::Library::type() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(type)); +} + +// property: installName +_MTL_INLINE NS::String* MTL::Library::installName() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(installName)); +} diff --git a/vendor/metal-cpp/Metal/MTLLinkedFunctions.hpp b/vendor/metal-cpp/Metal/MTLLinkedFunctions.hpp new file mode 100644 index 000000000..89ee87599 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLLinkedFunctions.hpp @@ -0,0 +1,115 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLLinkedFunctions.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +class LinkedFunctions : public NS::Copying +{ +public: + static class LinkedFunctions* alloc(); + + class LinkedFunctions* init(); + + static class LinkedFunctions* linkedFunctions(); + + NS::Array* functions() const; + void setFunctions(const NS::Array* functions); + + NS::Array* binaryFunctions() const; + void setBinaryFunctions(const NS::Array* binaryFunctions); + + NS::Dictionary* groups() const; + void setGroups(const NS::Dictionary* groups); + + NS::Array* privateFunctions() const; + void setPrivateFunctions(const NS::Array* privateFunctions); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::LinkedFunctions* MTL::LinkedFunctions::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLLinkedFunctions)); +} + +// method: init +_MTL_INLINE MTL::LinkedFunctions* MTL::LinkedFunctions::init() +{ + return NS::Object::init(); +} + +// static method: linkedFunctions +_MTL_INLINE MTL::LinkedFunctions* MTL::LinkedFunctions::linkedFunctions() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLLinkedFunctions), _MTL_PRIVATE_SEL(linkedFunctions)); +} + +// property: functions +_MTL_INLINE NS::Array* MTL::LinkedFunctions::functions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functions)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setFunctions(const NS::Array* functions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_), functions); +} + +// property: binaryFunctions +_MTL_INLINE NS::Array* MTL::LinkedFunctions::binaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryFunctions)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setBinaryFunctions(const NS::Array* binaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryFunctions_), binaryFunctions); +} + +// property: groups +_MTL_INLINE NS::Dictionary* MTL::LinkedFunctions::groups() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(groups)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setGroups(const NS::Dictionary* groups) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setGroups_), groups); +} + +// property: privateFunctions +_MTL_INLINE NS::Array* MTL::LinkedFunctions::privateFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(privateFunctions)); +} + +_MTL_INLINE void MTL::LinkedFunctions::setPrivateFunctions(const NS::Array* privateFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPrivateFunctions_), privateFunctions); +} diff --git a/vendor/metal-cpp/Metal/MTLParallelRenderCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLParallelRenderCommandEncoder.hpp new file mode 100644 index 000000000..d6d6ad8cf --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLParallelRenderCommandEncoder.hpp @@ -0,0 +1,94 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLParallelRenderCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLCommandEncoder.hpp" +#include "MTLRenderPass.hpp" + +namespace MTL +{ +class ParallelRenderCommandEncoder : public NS::Referencing +{ +public: + class RenderCommandEncoder* renderCommandEncoder(); + + void setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex); + + void setDepthStoreAction(MTL::StoreAction storeAction); + + void setStencilStoreAction(MTL::StoreAction storeAction); + + void setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex); + + void setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions); + + void setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions); +}; + +} + +// method: renderCommandEncoder +_MTL_INLINE MTL::RenderCommandEncoder* MTL::ParallelRenderCommandEncoder::renderCommandEncoder() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderCommandEncoder)); +} + +// method: setColorStoreAction:atIndex: +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreAction_atIndex_), storeAction, colorAttachmentIndex); +} + +// method: setDepthStoreAction: +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setDepthStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreAction_), storeAction); +} + +// method: setStencilStoreAction: +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setStencilStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreAction_), storeAction); +} + +// method: setColorStoreActionOptions:atIndex: +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreActionOptions_atIndex_), storeActionOptions, colorAttachmentIndex); +} + +// method: setDepthStoreActionOptions: +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreActionOptions_), storeActionOptions); +} + +// method: setStencilStoreActionOptions: +_MTL_INLINE void MTL::ParallelRenderCommandEncoder::setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreActionOptions_), storeActionOptions); +} diff --git a/vendor/metal-cpp/Metal/MTLPipeline.hpp b/vendor/metal-cpp/Metal/MTLPipeline.hpp new file mode 100644 index 000000000..1b6859ca1 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLPipeline.hpp @@ -0,0 +1,109 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLPipeline.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLPipeline.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, Mutability) { + MutabilityDefault = 0, + MutabilityMutable = 1, + MutabilityImmutable = 2, +}; + +class PipelineBufferDescriptor : public NS::Copying +{ +public: + static class PipelineBufferDescriptor* alloc(); + + class PipelineBufferDescriptor* init(); + + MTL::Mutability mutability() const; + void setMutability(MTL::Mutability mutability); +}; + +class PipelineBufferDescriptorArray : public NS::Referencing +{ +public: + static class PipelineBufferDescriptorArray* alloc(); + + class PipelineBufferDescriptorArray* init(); + + class PipelineBufferDescriptor* object(NS::UInteger bufferIndex); + + void setObject(const class PipelineBufferDescriptor* buffer, NS::UInteger bufferIndex); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::PipelineBufferDescriptor* MTL::PipelineBufferDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPipelineBufferDescriptor)); +} + +// method: init +_MTL_INLINE MTL::PipelineBufferDescriptor* MTL::PipelineBufferDescriptor::init() +{ + return NS::Object::init(); +} + +// property: mutability +_MTL_INLINE MTL::Mutability MTL::PipelineBufferDescriptor::mutability() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mutability)); +} + +_MTL_INLINE void MTL::PipelineBufferDescriptor::setMutability(MTL::Mutability mutability) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMutability_), mutability); +} + +// static method: alloc +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::PipelineBufferDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLPipelineBufferDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::PipelineBufferDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::PipelineBufferDescriptor* MTL::PipelineBufferDescriptorArray::object(NS::UInteger bufferIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), bufferIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::PipelineBufferDescriptorArray::setObject(const MTL::PipelineBufferDescriptor* buffer, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), buffer, bufferIndex); +} diff --git a/vendor/metal-cpp/Metal/MTLPixelFormat.hpp b/vendor/metal-cpp/Metal/MTLPixelFormat.hpp new file mode 100644 index 000000000..7a0c3c09c --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLPixelFormat.hpp @@ -0,0 +1,173 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLPixelFormat.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PixelFormat) { + PixelFormatInvalid = 0, + PixelFormatA8Unorm = 1, + PixelFormatR8Unorm = 10, + PixelFormatR8Unorm_sRGB = 11, + PixelFormatR8Snorm = 12, + PixelFormatR8Uint = 13, + PixelFormatR8Sint = 14, + PixelFormatR16Unorm = 20, + PixelFormatR16Snorm = 22, + PixelFormatR16Uint = 23, + PixelFormatR16Sint = 24, + PixelFormatR16Float = 25, + PixelFormatRG8Unorm = 30, + PixelFormatRG8Unorm_sRGB = 31, + PixelFormatRG8Snorm = 32, + PixelFormatRG8Uint = 33, + PixelFormatRG8Sint = 34, + PixelFormatB5G6R5Unorm = 40, + PixelFormatA1BGR5Unorm = 41, + PixelFormatABGR4Unorm = 42, + PixelFormatBGR5A1Unorm = 43, + PixelFormatR32Uint = 53, + PixelFormatR32Sint = 54, + PixelFormatR32Float = 55, + PixelFormatRG16Unorm = 60, + PixelFormatRG16Snorm = 62, + PixelFormatRG16Uint = 63, + PixelFormatRG16Sint = 64, + PixelFormatRG16Float = 65, + PixelFormatRGBA8Unorm = 70, + PixelFormatRGBA8Unorm_sRGB = 71, + PixelFormatRGBA8Snorm = 72, + PixelFormatRGBA8Uint = 73, + PixelFormatRGBA8Sint = 74, + PixelFormatBGRA8Unorm = 80, + PixelFormatBGRA8Unorm_sRGB = 81, + PixelFormatRGB10A2Unorm = 90, + PixelFormatRGB10A2Uint = 91, + PixelFormatRG11B10Float = 92, + PixelFormatRGB9E5Float = 93, + PixelFormatBGR10A2Unorm = 94, + PixelFormatRG32Uint = 103, + PixelFormatRG32Sint = 104, + PixelFormatRG32Float = 105, + PixelFormatRGBA16Unorm = 110, + PixelFormatRGBA16Snorm = 112, + PixelFormatRGBA16Uint = 113, + PixelFormatRGBA16Sint = 114, + PixelFormatRGBA16Float = 115, + PixelFormatRGBA32Uint = 123, + PixelFormatRGBA32Sint = 124, + PixelFormatRGBA32Float = 125, + PixelFormatBC1_RGBA = 130, + PixelFormatBC1_RGBA_sRGB = 131, + PixelFormatBC2_RGBA = 132, + PixelFormatBC2_RGBA_sRGB = 133, + PixelFormatBC3_RGBA = 134, + PixelFormatBC3_RGBA_sRGB = 135, + PixelFormatBC4_RUnorm = 140, + PixelFormatBC4_RSnorm = 141, + PixelFormatBC5_RGUnorm = 142, + PixelFormatBC5_RGSnorm = 143, + PixelFormatBC6H_RGBFloat = 150, + PixelFormatBC6H_RGBUfloat = 151, + PixelFormatBC7_RGBAUnorm = 152, + PixelFormatBC7_RGBAUnorm_sRGB = 153, + PixelFormatPVRTC_RGB_2BPP = 160, + PixelFormatPVRTC_RGB_2BPP_sRGB = 161, + PixelFormatPVRTC_RGB_4BPP = 162, + PixelFormatPVRTC_RGB_4BPP_sRGB = 163, + PixelFormatPVRTC_RGBA_2BPP = 164, + PixelFormatPVRTC_RGBA_2BPP_sRGB = 165, + PixelFormatPVRTC_RGBA_4BPP = 166, + PixelFormatPVRTC_RGBA_4BPP_sRGB = 167, + PixelFormatEAC_R11Unorm = 170, + PixelFormatEAC_R11Snorm = 172, + PixelFormatEAC_RG11Unorm = 174, + PixelFormatEAC_RG11Snorm = 176, + PixelFormatEAC_RGBA8 = 178, + PixelFormatEAC_RGBA8_sRGB = 179, + PixelFormatETC2_RGB8 = 180, + PixelFormatETC2_RGB8_sRGB = 181, + PixelFormatETC2_RGB8A1 = 182, + PixelFormatETC2_RGB8A1_sRGB = 183, + PixelFormatASTC_4x4_sRGB = 186, + PixelFormatASTC_5x4_sRGB = 187, + PixelFormatASTC_5x5_sRGB = 188, + PixelFormatASTC_6x5_sRGB = 189, + PixelFormatASTC_6x6_sRGB = 190, + PixelFormatASTC_8x5_sRGB = 192, + PixelFormatASTC_8x6_sRGB = 193, + PixelFormatASTC_8x8_sRGB = 194, + PixelFormatASTC_10x5_sRGB = 195, + PixelFormatASTC_10x6_sRGB = 196, + PixelFormatASTC_10x8_sRGB = 197, + PixelFormatASTC_10x10_sRGB = 198, + PixelFormatASTC_12x10_sRGB = 199, + PixelFormatASTC_12x12_sRGB = 200, + PixelFormatASTC_4x4_LDR = 204, + PixelFormatASTC_5x4_LDR = 205, + PixelFormatASTC_5x5_LDR = 206, + PixelFormatASTC_6x5_LDR = 207, + PixelFormatASTC_6x6_LDR = 208, + PixelFormatASTC_8x5_LDR = 210, + PixelFormatASTC_8x6_LDR = 211, + PixelFormatASTC_8x8_LDR = 212, + PixelFormatASTC_10x5_LDR = 213, + PixelFormatASTC_10x6_LDR = 214, + PixelFormatASTC_10x8_LDR = 215, + PixelFormatASTC_10x10_LDR = 216, + PixelFormatASTC_12x10_LDR = 217, + PixelFormatASTC_12x12_LDR = 218, + PixelFormatASTC_4x4_HDR = 222, + PixelFormatASTC_5x4_HDR = 223, + PixelFormatASTC_5x5_HDR = 224, + PixelFormatASTC_6x5_HDR = 225, + PixelFormatASTC_6x6_HDR = 226, + PixelFormatASTC_8x5_HDR = 228, + PixelFormatASTC_8x6_HDR = 229, + PixelFormatASTC_8x8_HDR = 230, + PixelFormatASTC_10x5_HDR = 231, + PixelFormatASTC_10x6_HDR = 232, + PixelFormatASTC_10x8_HDR = 233, + PixelFormatASTC_10x10_HDR = 234, + PixelFormatASTC_12x10_HDR = 235, + PixelFormatASTC_12x12_HDR = 236, + PixelFormatGBGR422 = 240, + PixelFormatBGRG422 = 241, + PixelFormatDepth16Unorm = 250, + PixelFormatDepth32Float = 252, + PixelFormatStencil8 = 253, + PixelFormatDepth24Unorm_Stencil8 = 255, + PixelFormatDepth32Float_Stencil8 = 260, + PixelFormatX32_Stencil8 = 261, + PixelFormatX24_Stencil8 = 262, + PixelFormatBGRA10_XR = 552, + PixelFormatBGRA10_XR_sRGB = 553, + PixelFormatBGR10_XR = 554, + PixelFormatBGR10_XR_sRGB = 555, +}; + +} diff --git a/vendor/metal-cpp/Metal/MTLPrivate.hpp b/vendor/metal-cpp/Metal/MTLPrivate.hpp new file mode 100644 index 000000000..7db23cf57 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLPrivate.hpp @@ -0,0 +1,156 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLPrivate.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "MTLDefines.hpp" + +#include + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#define _MTL_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol) +#define _MTL_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor) + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#if defined(MTL_PRIVATE_IMPLEMENTATION) + +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _MTL_PRIVATE_VISIBILITY __attribute__((visibility("hidden"))) +#else +#define _MTL_PRIVATE_VISIBILITY __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN + +#define _MTL_PRIVATE_IMPORT __attribute__((weak_import)) + +#ifdef __OBJC__ +#define _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol)) +#define _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol)) +#else +#define _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol) +#define _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol) +#endif // __OBJC__ + +#define _MTL_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _MTL_PRIVATE_VISIBILITY = _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) +#define _MTL_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _MTL_PRIVATE_VISIBILITY = _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) +#define _MTL_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _MTL_PRIVATE_VISIBILITY = sel_registerName(symbol) + +#include +#define MTL_DEF_FUNC( name, signature ) \ + using Fn##name = signature; \ + Fn##name name = reinterpret_cast< Fn##name >( dlsym( RTLD_DEFAULT, #name ) ) + +namespace MTL::Private +{ + template + inline _Type const LoadSymbol(const char* pSymbol) + { + const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol)); + + return pAddress ? *pAddress : nullptr; + } +} // MTL::Private + +#if defined(__MAC_10_16) || defined(__MAC_11_0) || defined(__MAC_12_0) || defined(__MAC_13_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) + +#define _MTL_PRIVATE_DEF_STR(type, symbol) \ + _MTL_EXTERN type const MTL##symbol _MTL_PRIVATE_IMPORT; \ + type const MTL::symbol = (nullptr != &MTL##symbol) ? MTL##symbol : nullptr + +#define _MTL_PRIVATE_DEF_CONST(type, symbol) \ + _MTL_EXTERN type const MTL##symbol _MTL_PRIVATE_IMPORT; \ + type const MTL::symbol = (nullptr != &MTL##symbol) ? MTL##symbol : nullptr + +#define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) \ + _MTL_EXTERN type const MTL##symbol; \ + type const MTL::symbol = Private::LoadSymbol("MTL" #symbol) + +#else + +#define _MTL_PRIVATE_DEF_STR(type, symbol) \ + _MTL_EXTERN type const MTL##symbol; \ + type const MTL::symbol = Private::LoadSymbol("MTL" #symbol) + +#define _MTL_PRIVATE_DEF_CONST(type, symbol) \ + _MTL_EXTERN type const MTL##symbol; \ + type const MTL::symbol = Private::LoadSymbol("MTL" #symbol) + +#define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) _MTL_PRIVATE_DEF_CONST(type, symbol) + +#endif // defined(__MAC_10_16) || defined(__MAC_11_0) || defined(__MAC_12_0) || defined(__MAC_13_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) + +#else + +#define _MTL_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol +#define _MTL_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol +#define _MTL_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor +#define _MTL_PRIVATE_DEF_STR(type, symbol) extern type const MTL::symbol +#define _MTL_PRIVATE_DEF_CONST(type, symbol) extern type const MTL::symbol +#define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) extern type const MTL::symbol + +#endif // MTL_PRIVATE_IMPLEMENTATION + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace MTL +{ +namespace Private +{ + namespace Class + { + + } // Class +} // Private +} // MTL + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace MTL +{ +namespace Private +{ + namespace Protocol + { + + } // Protocol +} // Private +} // MTL + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace MTL +{ +namespace Private +{ + namespace Selector + { + + _MTL_PRIVATE_DEF_SEL(beginScope, + "beginScope"); + _MTL_PRIVATE_DEF_SEL(endScope, + "endScope"); + } // Class +} // Private +} // MTL + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/Metal/MTLRasterizationRate.hpp b/vendor/metal-cpp/Metal/MTLRasterizationRate.hpp new file mode 100644 index 000000000..cac233926 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLRasterizationRate.hpp @@ -0,0 +1,386 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLRasterizationRate.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLDevice.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +class RasterizationRateSampleArray : public NS::Referencing +{ +public: + static class RasterizationRateSampleArray* alloc(); + + class RasterizationRateSampleArray* init(); + + NS::Number* object(NS::UInteger index); + + void setObject(const NS::Number* value, NS::UInteger index); +}; + +class RasterizationRateLayerDescriptor : public NS::Copying +{ +public: + static class RasterizationRateLayerDescriptor* alloc(); + + MTL::RasterizationRateLayerDescriptor* init(); + + MTL::RasterizationRateLayerDescriptor* init(MTL::Size sampleCount); + + MTL::RasterizationRateLayerDescriptor* init(MTL::Size sampleCount, const float* horizontal, const float* vertical); + + MTL::Size sampleCount() const; + + MTL::Size maxSampleCount() const; + + float* horizontalSampleStorage() const; + + float* verticalSampleStorage() const; + + class RasterizationRateSampleArray* horizontal() const; + + class RasterizationRateSampleArray* vertical() const; + + void setSampleCount(MTL::Size sampleCount); +}; + +class RasterizationRateLayerArray : public NS::Referencing +{ +public: + static class RasterizationRateLayerArray* alloc(); + + class RasterizationRateLayerArray* init(); + + class RasterizationRateLayerDescriptor* object(NS::UInteger layerIndex); + + void setObject(const class RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex); +}; + +class RasterizationRateMapDescriptor : public NS::Copying +{ +public: + static class RasterizationRateMapDescriptor* alloc(); + + class RasterizationRateMapDescriptor* init(); + + static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize); + + static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize, const class RasterizationRateLayerDescriptor* layer); + + static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize, NS::UInteger layerCount, const class RasterizationRateLayerDescriptor* const* layers); + + class RasterizationRateLayerDescriptor* layer(NS::UInteger layerIndex); + + void setLayer(const class RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex); + + class RasterizationRateLayerArray* layers() const; + + MTL::Size screenSize() const; + void setScreenSize(MTL::Size screenSize); + + NS::String* label() const; + void setLabel(const NS::String* label); + + NS::UInteger layerCount() const; +}; + +class RasterizationRateMap : public NS::Referencing +{ +public: + class Device* device() const; + + NS::String* label() const; + + MTL::Size screenSize() const; + + MTL::Size physicalGranularity() const; + + NS::UInteger layerCount() const; + + MTL::SizeAndAlign parameterBufferSizeAndAlign() const; + + void copyParameterDataToBuffer(const class Buffer* buffer, NS::UInteger offset); + + MTL::Size physicalSize(NS::UInteger layerIndex); + + MTL::Coordinate2D mapScreenToPhysicalCoordinates(MTL::Coordinate2D screenCoordinates, NS::UInteger layerIndex); + + MTL::Coordinate2D mapPhysicalToScreenCoordinates(MTL::Coordinate2D physicalCoordinates, NS::UInteger layerIndex); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateSampleArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateSampleArray)); +} + +// method: init +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateSampleArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE NS::Number* MTL::RasterizationRateSampleArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::RasterizationRateSampleArray::setObject(const NS::Number* value, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), value, index); +} + +// static method: alloc +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateLayerDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init() +{ + return NS::Object::init(); +} + +// method: initWithSampleCount: +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init(MTL::Size sampleCount) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithSampleCount_), sampleCount); +} + +// method: initWithSampleCount:horizontal:vertical: +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init(MTL::Size sampleCount, const float* horizontal, const float* vertical) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(initWithSampleCount_horizontal_vertical_), sampleCount, horizontal, vertical); +} + +// property: sampleCount +_MTL_INLINE MTL::Size MTL::RasterizationRateLayerDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +// property: maxSampleCount +_MTL_INLINE MTL::Size MTL::RasterizationRateLayerDescriptor::maxSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxSampleCount)); +} + +// property: horizontalSampleStorage +_MTL_INLINE float* MTL::RasterizationRateLayerDescriptor::horizontalSampleStorage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(horizontalSampleStorage)); +} + +// property: verticalSampleStorage +_MTL_INLINE float* MTL::RasterizationRateLayerDescriptor::verticalSampleStorage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(verticalSampleStorage)); +} + +// property: horizontal +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateLayerDescriptor::horizontal() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(horizontal)); +} + +// property: vertical +_MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateLayerDescriptor::vertical() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertical)); +} + +// method: setSampleCount: +_MTL_INLINE void MTL::RasterizationRateLayerDescriptor::setSampleCount(MTL::Size sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +// static method: alloc +_MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateLayerArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateLayerArray)); +} + +// method: init +_MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateLayerArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerArray::object(NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), layerIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::RasterizationRateLayerArray::setObject(const MTL::RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), layer, layerIndex); +} + +// static method: alloc +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: rasterizationRateMapDescriptorWithScreenSize: +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_), screenSize); +} + +// static method: rasterizationRateMapDescriptorWithScreenSize:layer: +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize, const MTL::RasterizationRateLayerDescriptor* layer) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_layer_), screenSize, layer); +} + +// static method: rasterizationRateMapDescriptorWithScreenSize:layerCount:layers: +_MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize, NS::UInteger layerCount, const MTL::RasterizationRateLayerDescriptor* const* layers) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_layerCount_layers_), screenSize, layerCount, layers); +} + +// method: layerAtIndex: +_MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateMapDescriptor::layer(NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layerAtIndex_), layerIndex); +} + +// method: setLayer:atIndex: +_MTL_INLINE void MTL::RasterizationRateMapDescriptor::setLayer(const MTL::RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLayer_atIndex_), layer, layerIndex); +} + +// property: layers +_MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateMapDescriptor::layers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layers)); +} + +// property: screenSize +_MTL_INLINE MTL::Size MTL::RasterizationRateMapDescriptor::screenSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(screenSize)); +} + +_MTL_INLINE void MTL::RasterizationRateMapDescriptor::setScreenSize(MTL::Size screenSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScreenSize_), screenSize); +} + +// property: label +_MTL_INLINE NS::String* MTL::RasterizationRateMapDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::RasterizationRateMapDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: layerCount +_MTL_INLINE NS::UInteger MTL::RasterizationRateMapDescriptor::layerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layerCount)); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::RasterizationRateMap::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: label +_MTL_INLINE NS::String* MTL::RasterizationRateMap::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// property: screenSize +_MTL_INLINE MTL::Size MTL::RasterizationRateMap::screenSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(screenSize)); +} + +// property: physicalGranularity +_MTL_INLINE MTL::Size MTL::RasterizationRateMap::physicalGranularity() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(physicalGranularity)); +} + +// property: layerCount +_MTL_INLINE NS::UInteger MTL::RasterizationRateMap::layerCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layerCount)); +} + +// property: parameterBufferSizeAndAlign +_MTL_INLINE MTL::SizeAndAlign MTL::RasterizationRateMap::parameterBufferSizeAndAlign() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parameterBufferSizeAndAlign)); +} + +// method: copyParameterDataToBuffer:offset: +_MTL_INLINE void MTL::RasterizationRateMap::copyParameterDataToBuffer(const MTL::Buffer* buffer, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(copyParameterDataToBuffer_offset_), buffer, offset); +} + +// method: physicalSizeForLayer: +_MTL_INLINE MTL::Size MTL::RasterizationRateMap::physicalSize(NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(physicalSizeForLayer_), layerIndex); +} + +// method: mapScreenToPhysicalCoordinates:forLayer: +_MTL_INLINE MTL::Coordinate2D MTL::RasterizationRateMap::mapScreenToPhysicalCoordinates(MTL::Coordinate2D screenCoordinates, NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mapScreenToPhysicalCoordinates_forLayer_), screenCoordinates, layerIndex); +} + +// method: mapPhysicalToScreenCoordinates:forLayer: +_MTL_INLINE MTL::Coordinate2D MTL::RasterizationRateMap::mapPhysicalToScreenCoordinates(MTL::Coordinate2D physicalCoordinates, NS::UInteger layerIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mapPhysicalToScreenCoordinates_forLayer_), physicalCoordinates, layerIndex); +} diff --git a/vendor/metal-cpp/Metal/MTLRenderCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLRenderCommandEncoder.hpp new file mode 100644 index 000000000..3c14d6b6d --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLRenderCommandEncoder.hpp @@ -0,0 +1,1145 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLRenderCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLCommandEncoder.hpp" +#include "MTLRenderCommandEncoder.hpp" +#include "MTLRenderPass.hpp" +#include "MTLStageInputOutputDescriptor.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PrimitiveType) { + PrimitiveTypePoint = 0, + PrimitiveTypeLine = 1, + PrimitiveTypeLineStrip = 2, + PrimitiveTypeTriangle = 3, + PrimitiveTypeTriangleStrip = 4, +}; + +_MTL_ENUM(NS::UInteger, VisibilityResultMode) { + VisibilityResultModeDisabled = 0, + VisibilityResultModeBoolean = 1, + VisibilityResultModeCounting = 2, +}; + +struct ScissorRect +{ + NS::UInteger x; + NS::UInteger y; + NS::UInteger width; + NS::UInteger height; +} _MTL_PACKED; + +struct Viewport +{ + double originX; + double originY; + double width; + double height; + double znear; + double zfar; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, CullMode) { + CullModeNone = 0, + CullModeFront = 1, + CullModeBack = 2, +}; + +_MTL_ENUM(NS::UInteger, Winding) { + WindingClockwise = 0, + WindingCounterClockwise = 1, +}; + +_MTL_ENUM(NS::UInteger, DepthClipMode) { + DepthClipModeClip = 0, + DepthClipModeClamp = 1, +}; + +_MTL_ENUM(NS::UInteger, TriangleFillMode) { + TriangleFillModeFill = 0, + TriangleFillModeLines = 1, +}; + +struct DrawPrimitivesIndirectArguments +{ + uint32_t vertexCount; + uint32_t instanceCount; + uint32_t vertexStart; + uint32_t baseInstance; +} _MTL_PACKED; + +struct DrawIndexedPrimitivesIndirectArguments +{ + uint32_t indexCount; + uint32_t instanceCount; + uint32_t indexStart; + int32_t baseVertex; + uint32_t baseInstance; +} _MTL_PACKED; + +struct VertexAmplificationViewMapping +{ + uint32_t viewportArrayIndexOffset; + uint32_t renderTargetArrayIndexOffset; +} _MTL_PACKED; + +struct DrawPatchIndirectArguments +{ + uint32_t patchCount; + uint32_t instanceCount; + uint32_t patchStart; + uint32_t baseInstance; +} _MTL_PACKED; + +struct QuadTessellationFactorsHalf +{ + uint16_t edgeTessellationFactor[4]; + uint16_t insideTessellationFactor[2]; +} _MTL_PACKED; + +struct TriangleTessellationFactorsHalf +{ + uint16_t edgeTessellationFactor[3]; + uint16_t insideTessellationFactor; +} _MTL_PACKED; + +_MTL_OPTIONS(NS::UInteger, RenderStages) { + RenderStageVertex = 1, + RenderStageFragment = 2, + RenderStageTile = 4, + RenderStageObject = 8, + RenderStageMesh = 16, +}; + +class RenderCommandEncoder : public NS::Referencing +{ +public: + void setRenderPipelineState(const class RenderPipelineState* pipelineState); + + void setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setVertexBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setVertexBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setVertexTexture(const class Texture* texture, NS::UInteger index); + + void setVertexTextures(const class Texture* const textures[], NS::Range range); + + void setVertexSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setVertexSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setVertexSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setVertexSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setVertexVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setVertexVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range); + + void setVertexIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setVertexIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setVertexAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void setViewport(MTL::Viewport viewport); + + void setViewports(const MTL::Viewport* viewports, NS::UInteger count); + + void setFrontFacingWinding(MTL::Winding frontFacingWinding); + + void setVertexAmplificationCount(NS::UInteger count, const MTL::VertexAmplificationViewMapping* viewMappings); + + void setCullMode(MTL::CullMode cullMode); + + void setDepthClipMode(MTL::DepthClipMode depthClipMode); + + void setDepthBias(float depthBias, float slopeScale, float clamp); + + void setScissorRect(MTL::ScissorRect rect); + + void setScissorRects(const MTL::ScissorRect* scissorRects, NS::UInteger count); + + void setTriangleFillMode(MTL::TriangleFillMode fillMode); + + void setFragmentBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setFragmentBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setFragmentBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setFragmentBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range); + + void setFragmentTexture(const class Texture* texture, NS::UInteger index); + + void setFragmentTextures(const class Texture* const textures[], NS::Range range); + + void setFragmentSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setFragmentSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setFragmentSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setFragmentSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setFragmentVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setFragmentVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range); + + void setFragmentIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setFragmentIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setFragmentAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void setBlendColor(float red, float green, float blue, float alpha); + + void setDepthStencilState(const class DepthStencilState* depthStencilState); + + void setStencilReferenceValue(uint32_t referenceValue); + + void setStencilReferenceValues(uint32_t frontReferenceValue, uint32_t backReferenceValue); + + void setVisibilityResultMode(MTL::VisibilityResultMode mode, NS::UInteger offset); + + void setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex); + + void setDepthStoreAction(MTL::StoreAction storeAction); + + void setStencilStoreAction(MTL::StoreAction storeAction); + + void setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex); + + void setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions); + + void setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions); + + void setObjectBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setObjectBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setObjectBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setObjectBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range); + + void setObjectTexture(const class Texture* texture, NS::UInteger index); + + void setObjectTextures(const class Texture* const textures[], NS::Range range); + + void setObjectSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setObjectSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setObjectSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setObjectSamplerStates(const class SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range); + + void setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index); + + void setMeshBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setMeshBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setMeshBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setMeshBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range); + + void setMeshTexture(const class Texture* texture, NS::UInteger index); + + void setMeshTextures(const class Texture* const textures[], NS::Range range); + + void setMeshSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setMeshSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setMeshSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setMeshSamplerStates(const class SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range); + + void drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void drawMeshThreadgroups(const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset); + + void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance); + + void drawPrimitives(MTL::PrimitiveType primitiveType, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void textureBarrier(); + + void updateFence(const class Fence* fence, MTL::RenderStages stages); + + void waitForFence(const class Fence* fence, MTL::RenderStages stages); + + void setTessellationFactorBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride); + + void setTessellationFactorScale(float scale); + + void drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawPatches(NS::UInteger numberOfPatchControlPoints, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance); + + void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + NS::UInteger tileWidth() const; + + NS::UInteger tileHeight() const; + + void setTileBytes(const void* bytes, NS::UInteger length, NS::UInteger index); + + void setTileBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index); + + void setTileBufferOffset(NS::UInteger offset, NS::UInteger index); + + void setTileBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range); + + void setTileTexture(const class Texture* texture, NS::UInteger index); + + void setTileTextures(const class Texture* const textures[], NS::Range range); + + void setTileSamplerState(const class SamplerState* sampler, NS::UInteger index); + + void setTileSamplerStates(const class SamplerState* const samplers[], NS::Range range); + + void setTileSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index); + + void setTileSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range); + + void setTileVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex); + + void setTileVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range); + + void setTileIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex); + + void setTileIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range); + + void setTileAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex); + + void dispatchThreadsPerTile(MTL::Size threadsPerTile); + + void setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger offset, NS::UInteger index); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage); + + void useResource(const class Resource* resource, MTL::ResourceUsage usage, MTL::RenderStages stages); + + void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage, MTL::RenderStages stages); + + void useHeap(const class Heap* heap); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count); + + void useHeap(const class Heap* heap, MTL::RenderStages stages); + + void useHeaps(const class Heap* const heaps[], NS::UInteger count, MTL::RenderStages stages); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange); + + void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandbuffer, const class Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset); + + void memoryBarrier(MTL::BarrierScope scope, MTL::RenderStages after, MTL::RenderStages before); + + void memoryBarrier(const class Resource* const resources[], NS::UInteger count, MTL::RenderStages after, MTL::RenderStages before); + + void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier); +}; + +} + +// method: setRenderPipelineState: +_MTL_INLINE void MTL::RenderCommandEncoder::setRenderPipelineState(const MTL::RenderPipelineState* pipelineState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderPipelineState_), pipelineState); +} + +// method: setVertexBytes:length:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBytes_length_atIndex_), bytes, length, index); +} + +// method: setVertexBuffer:offset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setVertexBufferOffset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_atIndex_), offset, index); +} + +// method: setVertexBuffers:offsets:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffers_offsets_withRange_), buffers, offsets, range); +} + +// method: setVertexTexture:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexTexture_atIndex_), texture, index); +} + +// method: setVertexTextures:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexTextures_withRange_), textures, range); +} + +// method: setVertexSamplerState:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerState_atIndex_), sampler, index); +} + +// method: setVertexSamplerStates:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerStates_withRange_), samplers, range); +} + +// method: setVertexSamplerState:lodMinClamp:lodMaxClamp:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +// method: setVertexSamplerStates:lodMinClamps:lodMaxClamps:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +// method: setVertexVisibleFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +// method: setVertexVisibleFunctionTables:withBufferRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexVisibleFunctionTables_withBufferRange_), functionTables, range); +} + +// method: setVertexIntersectionFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +// method: setVertexIntersectionFunctionTables:withBufferRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +// method: setVertexAccelerationStructure:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +// method: setViewport: +_MTL_INLINE void MTL::RenderCommandEncoder::setViewport(MTL::Viewport viewport) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setViewport_), viewport); +} + +// method: setViewports:count: +_MTL_INLINE void MTL::RenderCommandEncoder::setViewports(const MTL::Viewport* viewports, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setViewports_count_), viewports, count); +} + +// method: setFrontFacingWinding: +_MTL_INLINE void MTL::RenderCommandEncoder::setFrontFacingWinding(MTL::Winding frontFacingWinding) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFrontFacingWinding_), frontFacingWinding); +} + +// method: setVertexAmplificationCount:viewMappings: +_MTL_INLINE void MTL::RenderCommandEncoder::setVertexAmplificationCount(NS::UInteger count, const MTL::VertexAmplificationViewMapping* viewMappings) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexAmplificationCount_viewMappings_), count, viewMappings); +} + +// method: setCullMode: +_MTL_INLINE void MTL::RenderCommandEncoder::setCullMode(MTL::CullMode cullMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCullMode_), cullMode); +} + +// method: setDepthClipMode: +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthClipMode(MTL::DepthClipMode depthClipMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthClipMode_), depthClipMode); +} + +// method: setDepthBias:slopeScale:clamp: +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthBias(float depthBias, float slopeScale, float clamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthBias_slopeScale_clamp_), depthBias, slopeScale, clamp); +} + +// method: setScissorRect: +_MTL_INLINE void MTL::RenderCommandEncoder::setScissorRect(MTL::ScissorRect rect) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScissorRect_), rect); +} + +// method: setScissorRects:count: +_MTL_INLINE void MTL::RenderCommandEncoder::setScissorRects(const MTL::ScissorRect* scissorRects, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setScissorRects_count_), scissorRects, count); +} + +// method: setTriangleFillMode: +_MTL_INLINE void MTL::RenderCommandEncoder::setTriangleFillMode(MTL::TriangleFillMode fillMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTriangleFillMode_), fillMode); +} + +// method: setFragmentBytes:length:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBytes_length_atIndex_), bytes, length, index); +} + +// method: setFragmentBuffer:offset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setFragmentBufferOffset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBufferOffset_atIndex_), offset, index); +} + +// method: setFragmentBuffers:offsets:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentBuffers_offsets_withRange_), buffers, offsets, range); +} + +// method: setFragmentTexture:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentTexture_atIndex_), texture, index); +} + +// method: setFragmentTextures:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentTextures_withRange_), textures, range); +} + +// method: setFragmentSamplerState:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerState_atIndex_), sampler, index); +} + +// method: setFragmentSamplerStates:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerStates_withRange_), samplers, range); +} + +// method: setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +// method: setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +// method: setFragmentVisibleFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +// method: setFragmentVisibleFunctionTables:withBufferRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentVisibleFunctionTables_withBufferRange_), functionTables, range); +} + +// method: setFragmentIntersectionFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +// method: setFragmentIntersectionFunctionTables:withBufferRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +// method: setFragmentAccelerationStructure:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setFragmentAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +// method: setBlendColorRed:green:blue:alpha: +_MTL_INLINE void MTL::RenderCommandEncoder::setBlendColor(float red, float green, float blue, float alpha) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBlendColorRed_green_blue_alpha_), red, green, blue, alpha); +} + +// method: setDepthStencilState: +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthStencilState(const MTL::DepthStencilState* depthStencilState) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStencilState_), depthStencilState); +} + +// method: setStencilReferenceValue: +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilReferenceValue(uint32_t referenceValue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilReferenceValue_), referenceValue); +} + +// method: setStencilFrontReferenceValue:backReferenceValue: +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilReferenceValues(uint32_t frontReferenceValue, uint32_t backReferenceValue) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilFrontReferenceValue_backReferenceValue_), frontReferenceValue, backReferenceValue); +} + +// method: setVisibilityResultMode:offset: +_MTL_INLINE void MTL::RenderCommandEncoder::setVisibilityResultMode(MTL::VisibilityResultMode mode, NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibilityResultMode_offset_), mode, offset); +} + +// method: setColorStoreAction:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreAction_atIndex_), storeAction, colorAttachmentIndex); +} + +// method: setDepthStoreAction: +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreAction_), storeAction); +} + +// method: setStencilStoreAction: +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreAction_), storeAction); +} + +// method: setColorStoreActionOptions:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setColorStoreActionOptions_atIndex_), storeActionOptions, colorAttachmentIndex); +} + +// method: setDepthStoreActionOptions: +_MTL_INLINE void MTL::RenderCommandEncoder::setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthStoreActionOptions_), storeActionOptions); +} + +// method: setStencilStoreActionOptions: +_MTL_INLINE void MTL::RenderCommandEncoder::setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilStoreActionOptions_), storeActionOptions); +} + +// method: setObjectBytes:length:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBytes_length_atIndex_), bytes, length, index); +} + +// method: setObjectBuffer:offset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setObjectBufferOffset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBufferOffset_atIndex_), offset, index); +} + +// method: setObjectBuffers:offsets:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectBuffers_offsets_withRange_), buffers, offsets, range); +} + +// method: setObjectTexture:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectTexture_atIndex_), texture, index); +} + +// method: setObjectTextures:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectTextures_withRange_), textures, range); +} + +// method: setObjectSamplerState:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerState_atIndex_), sampler, index); +} + +// method: setObjectSamplerStates:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerStates_withRange_), samplers, range); +} + +// method: setObjectSamplerState:lodMinClamp:lodMaxClamp:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +// method: setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerStates(const MTL::SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +// method: setObjectThreadgroupMemoryLength:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectThreadgroupMemoryLength_atIndex_), length, index); +} + +// method: setMeshBytes:length:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBytes_length_atIndex_), bytes, length, index); +} + +// method: setMeshBuffer:offset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setMeshBufferOffset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBufferOffset_atIndex_), offset, index); +} + +// method: setMeshBuffers:offsets:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshBuffers_offsets_withRange_), buffers, offsets, range); +} + +// method: setMeshTexture:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshTexture_atIndex_), texture, index); +} + +// method: setMeshTextures:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshTextures_withRange_), textures, range); +} + +// method: setMeshSamplerState:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerState_atIndex_), sampler, index); +} + +// method: setMeshSamplerStates:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerStates_withRange_), samplers, range); +} + +// method: setMeshSamplerState:lodMinClamp:lodMaxClamp:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +// method: setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerStates(const MTL::SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +// method: drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup: +_MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreadgroups_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadgroupsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +// method: drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup: +_MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreads_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +// method: drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup: +_MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreadgroups(const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawMeshThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), indirectBuffer, indirectBufferOffset, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup); +} + +// method: drawPrimitives:vertexStart:vertexCount:instanceCount: +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_), primitiveType, vertexStart, vertexCount, instanceCount); +} + +// method: drawPrimitives:vertexStart:vertexCount: +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_), primitiveType, vertexStart, vertexCount); +} + +// method: drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount: +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount); +} + +// method: drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset: +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset); +} + +// method: drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance: +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance_), primitiveType, vertexStart, vertexCount, instanceCount, baseInstance); +} + +// method: drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance: +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance); +} + +// method: drawPrimitives:indirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPrimitives_indirectBuffer_indirectBufferOffset_), primitiveType, indirectBuffer, indirectBufferOffset); +} + +// method: drawIndexedPrimitives:indexType:indexBuffer:indexBufferOffset:indirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexType_indexBuffer_indexBufferOffset_indirectBuffer_indirectBufferOffset_), primitiveType, indexType, indexBuffer, indexBufferOffset, indirectBuffer, indirectBufferOffset); +} + +// method: textureBarrier +_MTL_INLINE void MTL::RenderCommandEncoder::textureBarrier() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(textureBarrier)); +} + +// method: updateFence:afterStages: +_MTL_INLINE void MTL::RenderCommandEncoder::updateFence(const MTL::Fence* fence, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_afterStages_), fence, stages); +} + +// method: waitForFence:beforeStages: +_MTL_INLINE void MTL::RenderCommandEncoder::waitForFence(const MTL::Fence* fence, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_beforeStages_), fence, stages); +} + +// method: setTessellationFactorBuffer:offset:instanceStride: +_MTL_INLINE void MTL::RenderCommandEncoder::setTessellationFactorBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorBuffer_offset_instanceStride_), buffer, offset, instanceStride); +} + +// method: setTessellationFactorScale: +_MTL_INLINE void MTL::RenderCommandEncoder::setTessellationFactorScale(float scale) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorScale_), scale); +} + +// method: drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance: +_MTL_INLINE void MTL::RenderCommandEncoder::drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance); +} + +// method: drawPatches:patchIndexBuffer:patchIndexBufferOffset:indirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::RenderCommandEncoder::drawPatches(NS::UInteger numberOfPatchControlPoints, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawPatches_patchIndexBuffer_patchIndexBufferOffset_indirectBuffer_indirectBufferOffset_), numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, indirectBuffer, indirectBufferOffset); +} + +// method: drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance: +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, instanceCount, baseInstance); +} + +// method: drawIndexedPatches:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:indirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_indirectBuffer_indirectBufferOffset_), numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, indirectBuffer, indirectBufferOffset); +} + +// property: tileWidth +_MTL_INLINE NS::UInteger MTL::RenderCommandEncoder::tileWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileWidth)); +} + +// property: tileHeight +_MTL_INLINE NS::UInteger MTL::RenderCommandEncoder::tileHeight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileHeight)); +} + +// method: setTileBytes:length:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBytes(const void* bytes, NS::UInteger length, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBytes_length_atIndex_), bytes, length, index); +} + +// method: setTileBuffer:offset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBuffer_offset_atIndex_), buffer, offset, index); +} + +// method: setTileBufferOffset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBufferOffset(NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBufferOffset_atIndex_), offset, index); +} + +// method: setTileBuffers:offsets:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileBuffers_offsets_withRange_), buffers, offsets, range); +} + +// method: setTileTexture:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileTexture(const MTL::Texture* texture, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileTexture_atIndex_), texture, index); +} + +// method: setTileTextures:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileTextures(const MTL::Texture* const textures[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileTextures_withRange_), textures, range); +} + +// method: setTileSamplerState:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerState(const MTL::SamplerState* sampler, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerState_atIndex_), sampler, index); +} + +// method: setTileSamplerStates:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerStates_withRange_), samplers, range); +} + +// method: setTileSamplerState:lodMinClamp:lodMaxClamp:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index); +} + +// method: setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range); +} + +// method: setTileVisibleFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex); +} + +// method: setTileVisibleFunctionTables:withBufferRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileVisibleFunctionTables_withBufferRange_), functionTables, range); +} + +// method: setTileIntersectionFunctionTable:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex); +} + +// method: setTileIntersectionFunctionTables:withBufferRange: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range); +} + +// method: setTileAccelerationStructure:atBufferIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setTileAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex); +} + +// method: dispatchThreadsPerTile: +_MTL_INLINE void MTL::RenderCommandEncoder::dispatchThreadsPerTile(MTL::Size threadsPerTile) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(dispatchThreadsPerTile_), threadsPerTile); +} + +// method: setThreadgroupMemoryLength:offset:atIndex: +_MTL_INLINE void MTL::RenderCommandEncoder::setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger offset, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_offset_atIndex_), length, offset, index); +} + +// method: useResource:usage: +_MTL_INLINE void MTL::RenderCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_), resource, usage); +} + +// method: useResources:count:usage: +_MTL_INLINE void MTL::RenderCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_), resources, count, usage); +} + +// method: useResource:usage:stages: +_MTL_INLINE void MTL::RenderCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResource_usage_stages_), resource, usage, stages); +} + +// method: useResources:count:usage:stages: +_MTL_INLINE void MTL::RenderCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useResources_count_usage_stages_), resources, count, usage, stages); +} + +// method: useHeap: +_MTL_INLINE void MTL::RenderCommandEncoder::useHeap(const MTL::Heap* heap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_), heap); +} + +// method: useHeaps:count: +_MTL_INLINE void MTL::RenderCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_), heaps, count); +} + +// method: useHeap:stages: +_MTL_INLINE void MTL::RenderCommandEncoder::useHeap(const MTL::Heap* heap, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeap_stages_), heap, stages); +} + +// method: useHeaps:count:stages: +_MTL_INLINE void MTL::RenderCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count, MTL::RenderStages stages) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(useHeaps_count_stages_), heaps, count, stages); +} + +// method: executeCommandsInBuffer:withRange: +_MTL_INLINE void MTL::RenderCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_withRange_), indirectCommandBuffer, executionRange); +} + +// method: executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::RenderCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandbuffer, const MTL::Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_), indirectCommandbuffer, indirectRangeBuffer, indirectBufferOffset); +} + +// method: memoryBarrierWithScope:afterStages:beforeStages: +_MTL_INLINE void MTL::RenderCommandEncoder::memoryBarrier(MTL::BarrierScope scope, MTL::RenderStages after, MTL::RenderStages before) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithScope_afterStages_beforeStages_), scope, after, before); +} + +// method: memoryBarrierWithResources:count:afterStages:beforeStages: +_MTL_INLINE void MTL::RenderCommandEncoder::memoryBarrier(const MTL::Resource* const resources[], NS::UInteger count, MTL::RenderStages after, MTL::RenderStages before) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(memoryBarrierWithResources_count_afterStages_beforeStages_), resources, count, after, before); +} + +// method: sampleCountersInBuffer:atSampleIndex:withBarrier: +_MTL_INLINE void MTL::RenderCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier); +} diff --git a/vendor/metal-cpp/Metal/MTLRenderPass.hpp b/vendor/metal-cpp/Metal/MTLRenderPass.hpp new file mode 100644 index 000000000..087b4467c --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLRenderPass.hpp @@ -0,0 +1,786 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLRenderPass.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLRenderPass.hpp" + +namespace MTL +{ +struct ClearColor +{ + static ClearColor Make(double red, double green, double blue, double alpha); + + ClearColor() = default; + + ClearColor(double red, double green, double blue, double alpha); + + double red; + double green; + double blue; + double alpha; +} _MTL_PACKED; + +_MTL_ENUM(NS::UInteger, LoadAction) { + LoadActionDontCare = 0, + LoadActionLoad = 1, + LoadActionClear = 2, +}; + +_MTL_ENUM(NS::UInteger, StoreAction) { + StoreActionDontCare = 0, + StoreActionStore = 1, + StoreActionMultisampleResolve = 2, + StoreActionStoreAndMultisampleResolve = 3, + StoreActionUnknown = 4, + StoreActionCustomSampleDepthStore = 5, +}; + +_MTL_OPTIONS(NS::UInteger, StoreActionOptions) { + StoreActionOptionNone = 0, + StoreActionOptionValidMask = 1, + StoreActionOptionCustomSamplePositions = 1, +}; + +class RenderPassAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassAttachmentDescriptor* alloc(); + + class RenderPassAttachmentDescriptor* init(); + + class Texture* texture() const; + void setTexture(const class Texture* texture); + + NS::UInteger level() const; + void setLevel(NS::UInteger level); + + NS::UInteger slice() const; + void setSlice(NS::UInteger slice); + + NS::UInteger depthPlane() const; + void setDepthPlane(NS::UInteger depthPlane); + + class Texture* resolveTexture() const; + void setResolveTexture(const class Texture* resolveTexture); + + NS::UInteger resolveLevel() const; + void setResolveLevel(NS::UInteger resolveLevel); + + NS::UInteger resolveSlice() const; + void setResolveSlice(NS::UInteger resolveSlice); + + NS::UInteger resolveDepthPlane() const; + void setResolveDepthPlane(NS::UInteger resolveDepthPlane); + + MTL::LoadAction loadAction() const; + void setLoadAction(MTL::LoadAction loadAction); + + MTL::StoreAction storeAction() const; + void setStoreAction(MTL::StoreAction storeAction); + + MTL::StoreActionOptions storeActionOptions() const; + void setStoreActionOptions(MTL::StoreActionOptions storeActionOptions); +}; + +class RenderPassColorAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassColorAttachmentDescriptor* alloc(); + + class RenderPassColorAttachmentDescriptor* init(); + + MTL::ClearColor clearColor() const; + void setClearColor(MTL::ClearColor clearColor); +}; + +_MTL_ENUM(NS::UInteger, MultisampleDepthResolveFilter) { + MultisampleDepthResolveFilterSample0 = 0, + MultisampleDepthResolveFilterMin = 1, + MultisampleDepthResolveFilterMax = 2, +}; + +class RenderPassDepthAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassDepthAttachmentDescriptor* alloc(); + + class RenderPassDepthAttachmentDescriptor* init(); + + double clearDepth() const; + void setClearDepth(double clearDepth); + + MTL::MultisampleDepthResolveFilter depthResolveFilter() const; + void setDepthResolveFilter(MTL::MultisampleDepthResolveFilter depthResolveFilter); +}; + +_MTL_ENUM(NS::UInteger, MultisampleStencilResolveFilter) { + MultisampleStencilResolveFilterSample0 = 0, + MultisampleStencilResolveFilterDepthResolvedSample = 1, +}; + +class RenderPassStencilAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassStencilAttachmentDescriptor* alloc(); + + class RenderPassStencilAttachmentDescriptor* init(); + + uint32_t clearStencil() const; + void setClearStencil(uint32_t clearStencil); + + MTL::MultisampleStencilResolveFilter stencilResolveFilter() const; + void setStencilResolveFilter(MTL::MultisampleStencilResolveFilter stencilResolveFilter); +}; + +class RenderPassColorAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class RenderPassColorAttachmentDescriptorArray* alloc(); + + class RenderPassColorAttachmentDescriptorArray* init(); + + class RenderPassColorAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class RenderPassColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class RenderPassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPassSampleBufferAttachmentDescriptor* alloc(); + + class RenderPassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfVertexSampleIndex() const; + void setStartOfVertexSampleIndex(NS::UInteger startOfVertexSampleIndex); + + NS::UInteger endOfVertexSampleIndex() const; + void setEndOfVertexSampleIndex(NS::UInteger endOfVertexSampleIndex); + + NS::UInteger startOfFragmentSampleIndex() const; + void setStartOfFragmentSampleIndex(NS::UInteger startOfFragmentSampleIndex); + + NS::UInteger endOfFragmentSampleIndex() const; + void setEndOfFragmentSampleIndex(NS::UInteger endOfFragmentSampleIndex); +}; + +class RenderPassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class RenderPassSampleBufferAttachmentDescriptorArray* alloc(); + + class RenderPassSampleBufferAttachmentDescriptorArray* init(); + + class RenderPassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class RenderPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class RenderPassDescriptor : public NS::Copying +{ +public: + static class RenderPassDescriptor* alloc(); + + class RenderPassDescriptor* init(); + + static class RenderPassDescriptor* renderPassDescriptor(); + + class RenderPassColorAttachmentDescriptorArray* colorAttachments() const; + + class RenderPassDepthAttachmentDescriptor* depthAttachment() const; + void setDepthAttachment(const class RenderPassDepthAttachmentDescriptor* depthAttachment); + + class RenderPassStencilAttachmentDescriptor* stencilAttachment() const; + void setStencilAttachment(const class RenderPassStencilAttachmentDescriptor* stencilAttachment); + + class Buffer* visibilityResultBuffer() const; + void setVisibilityResultBuffer(const class Buffer* visibilityResultBuffer); + + NS::UInteger renderTargetArrayLength() const; + void setRenderTargetArrayLength(NS::UInteger renderTargetArrayLength); + + NS::UInteger imageblockSampleLength() const; + void setImageblockSampleLength(NS::UInteger imageblockSampleLength); + + NS::UInteger threadgroupMemoryLength() const; + void setThreadgroupMemoryLength(NS::UInteger threadgroupMemoryLength); + + NS::UInteger tileWidth() const; + void setTileWidth(NS::UInteger tileWidth); + + NS::UInteger tileHeight() const; + void setTileHeight(NS::UInteger tileHeight); + + NS::UInteger defaultRasterSampleCount() const; + void setDefaultRasterSampleCount(NS::UInteger defaultRasterSampleCount); + + NS::UInteger renderTargetWidth() const; + void setRenderTargetWidth(NS::UInteger renderTargetWidth); + + NS::UInteger renderTargetHeight() const; + void setRenderTargetHeight(NS::UInteger renderTargetHeight); + + void setSamplePositions(const MTL::SamplePosition* positions, NS::UInteger count); + + NS::UInteger getSamplePositions(MTL::SamplePosition* positions, NS::UInteger count); + + class RasterizationRateMap* rasterizationRateMap() const; + void setRasterizationRateMap(const class RasterizationRateMap* rasterizationRateMap); + + class RenderPassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +_MTL_INLINE MTL::ClearColor MTL::ClearColor::Make(double red, double green, double blue, double alpha) +{ + return ClearColor(red, green, blue, alpha); +} + +_MTL_INLINE MTL::ClearColor::ClearColor(double _red, double _green, double _blue, double _alpha) + : red(_red) + , green(_green) + , blue(_blue) + , alpha(_alpha) +{ +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassAttachmentDescriptor* MTL::RenderPassAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPassAttachmentDescriptor* MTL::RenderPassAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: texture +_MTL_INLINE MTL::Texture* MTL::RenderPassAttachmentDescriptor::texture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(texture)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setTexture(const MTL::Texture* texture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTexture_), texture); +} + +// property: level +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::level() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(level)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setLevel(NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLevel_), level); +} + +// property: slice +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::slice() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(slice)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setSlice(NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSlice_), slice); +} + +// property: depthPlane +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::depthPlane() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthPlane)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setDepthPlane(NS::UInteger depthPlane) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthPlane_), depthPlane); +} + +// property: resolveTexture +_MTL_INLINE MTL::Texture* MTL::RenderPassAttachmentDescriptor::resolveTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveTexture)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveTexture(const MTL::Texture* resolveTexture) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveTexture_), resolveTexture); +} + +// property: resolveLevel +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveLevel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveLevel)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveLevel(NS::UInteger resolveLevel) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveLevel_), resolveLevel); +} + +// property: resolveSlice +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveSlice() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveSlice)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveSlice(NS::UInteger resolveSlice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveSlice_), resolveSlice); +} + +// property: resolveDepthPlane +_MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveDepthPlane() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resolveDepthPlane)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveDepthPlane(NS::UInteger resolveDepthPlane) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResolveDepthPlane_), resolveDepthPlane); +} + +// property: loadAction +_MTL_INLINE MTL::LoadAction MTL::RenderPassAttachmentDescriptor::loadAction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(loadAction)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setLoadAction(MTL::LoadAction loadAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLoadAction_), loadAction); +} + +// property: storeAction +_MTL_INLINE MTL::StoreAction MTL::RenderPassAttachmentDescriptor::storeAction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storeAction)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setStoreAction(MTL::StoreAction storeAction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStoreAction_), storeAction); +} + +// property: storeActionOptions +_MTL_INLINE MTL::StoreActionOptions MTL::RenderPassAttachmentDescriptor::storeActionOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storeActionOptions)); +} + +_MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setStoreActionOptions(MTL::StoreActionOptions storeActionOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStoreActionOptions_), storeActionOptions); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassColorAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: clearColor +_MTL_INLINE MTL::ClearColor MTL::RenderPassColorAttachmentDescriptor::clearColor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(clearColor)); +} + +_MTL_INLINE void MTL::RenderPassColorAttachmentDescriptor::setClearColor(MTL::ClearColor clearColor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setClearColor_), clearColor); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDepthAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassDepthAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDepthAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: clearDepth +_MTL_INLINE double MTL::RenderPassDepthAttachmentDescriptor::clearDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(clearDepth)); +} + +_MTL_INLINE void MTL::RenderPassDepthAttachmentDescriptor::setClearDepth(double clearDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setClearDepth_), clearDepth); +} + +// property: depthResolveFilter +_MTL_INLINE MTL::MultisampleDepthResolveFilter MTL::RenderPassDepthAttachmentDescriptor::depthResolveFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthResolveFilter)); +} + +_MTL_INLINE void MTL::RenderPassDepthAttachmentDescriptor::setDepthResolveFilter(MTL::MultisampleDepthResolveFilter depthResolveFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthResolveFilter_), depthResolveFilter); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassStencilAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassStencilAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassStencilAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: clearStencil +_MTL_INLINE uint32_t MTL::RenderPassStencilAttachmentDescriptor::clearStencil() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(clearStencil)); +} + +_MTL_INLINE void MTL::RenderPassStencilAttachmentDescriptor::setClearStencil(uint32_t clearStencil) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setClearStencil_), clearStencil); +} + +// property: stencilResolveFilter +_MTL_INLINE MTL::MultisampleStencilResolveFilter MTL::RenderPassStencilAttachmentDescriptor::stencilResolveFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilResolveFilter)); +} + +_MTL_INLINE void MTL::RenderPassStencilAttachmentDescriptor::setStencilResolveFilter(MTL::MultisampleStencilResolveFilter stencilResolveFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilResolveFilter_), stencilResolveFilter); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassColorAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassColorAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassColorAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::RenderPassColorAttachmentDescriptorArray::setObject(const MTL::RenderPassColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassSampleBufferAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: sampleBuffer +_MTL_INLINE MTL::CounterSampleBuffer* MTL::RenderPassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +// property: startOfVertexSampleIndex +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::startOfVertexSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfVertexSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setStartOfVertexSampleIndex(NS::UInteger startOfVertexSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfVertexSampleIndex_), startOfVertexSampleIndex); +} + +// property: endOfVertexSampleIndex +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::endOfVertexSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfVertexSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setEndOfVertexSampleIndex(NS::UInteger endOfVertexSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfVertexSampleIndex_), endOfVertexSampleIndex); +} + +// property: startOfFragmentSampleIndex +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::startOfFragmentSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfFragmentSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setStartOfFragmentSampleIndex(NS::UInteger startOfFragmentSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfFragmentSampleIndex_), startOfFragmentSampleIndex); +} + +// property: endOfFragmentSampleIndex +_MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::endOfFragmentSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfFragmentSampleIndex)); +} + +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setEndOfFragmentSampleIndex(NS::UInteger endOfFragmentSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfFragmentSampleIndex_), endOfFragmentSampleIndex); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassSampleBufferAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptorArray::setObject(const MTL::RenderPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPassDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: renderPassDescriptor +_MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::renderPassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLRenderPassDescriptor), _MTL_PRIVATE_SEL(renderPassDescriptor)); +} + +// property: colorAttachments +_MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +// property: depthAttachment +_MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDescriptor::depthAttachment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthAttachment)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setDepthAttachment(const MTL::RenderPassDepthAttachmentDescriptor* depthAttachment) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthAttachment_), depthAttachment); +} + +// property: stencilAttachment +_MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassDescriptor::stencilAttachment() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilAttachment)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setStencilAttachment(const MTL::RenderPassStencilAttachmentDescriptor* stencilAttachment) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilAttachment_), stencilAttachment); +} + +// property: visibilityResultBuffer +_MTL_INLINE MTL::Buffer* MTL::RenderPassDescriptor::visibilityResultBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(visibilityResultBuffer)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setVisibilityResultBuffer(const MTL::Buffer* visibilityResultBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVisibilityResultBuffer_), visibilityResultBuffer); +} + +// property: renderTargetArrayLength +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetArrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderTargetArrayLength)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetArrayLength(NS::UInteger renderTargetArrayLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderTargetArrayLength_), renderTargetArrayLength); +} + +// property: imageblockSampleLength +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::imageblockSampleLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockSampleLength)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setImageblockSampleLength(NS::UInteger imageblockSampleLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setImageblockSampleLength_), imageblockSampleLength); +} + +// property: threadgroupMemoryLength +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::threadgroupMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupMemoryLength)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setThreadgroupMemoryLength(NS::UInteger threadgroupMemoryLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_), threadgroupMemoryLength); +} + +// property: tileWidth +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::tileWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileWidth)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setTileWidth(NS::UInteger tileWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileWidth_), tileWidth); +} + +// property: tileHeight +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::tileHeight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileHeight)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setTileHeight(NS::UInteger tileHeight) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileHeight_), tileHeight); +} + +// property: defaultRasterSampleCount +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::defaultRasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(defaultRasterSampleCount)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setDefaultRasterSampleCount(NS::UInteger defaultRasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDefaultRasterSampleCount_), defaultRasterSampleCount); +} + +// property: renderTargetWidth +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderTargetWidth)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetWidth(NS::UInteger renderTargetWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderTargetWidth_), renderTargetWidth); +} + +// property: renderTargetHeight +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetHeight() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(renderTargetHeight)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetHeight(NS::UInteger renderTargetHeight) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRenderTargetHeight_), renderTargetHeight); +} + +// method: setSamplePositions:count: +_MTL_INLINE void MTL::RenderPassDescriptor::setSamplePositions(const MTL::SamplePosition* positions, NS::UInteger count) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSamplePositions_count_), positions, count); +} + +// method: getSamplePositions:count: +_MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::getSamplePositions(MTL::SamplePosition* positions, NS::UInteger count) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(getSamplePositions_count_), positions, count); +} + +// property: rasterizationRateMap +_MTL_INLINE MTL::RasterizationRateMap* MTL::RenderPassDescriptor::rasterizationRateMap() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterizationRateMap)); +} + +_MTL_INLINE void MTL::RenderPassDescriptor::setRasterizationRateMap(const MTL::RasterizationRateMap* rasterizationRateMap) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterizationRateMap_), rasterizationRateMap); +} + +// property: sampleBufferAttachments +_MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} diff --git a/vendor/metal-cpp/Metal/MTLRenderPipeline.hpp b/vendor/metal-cpp/Metal/MTLRenderPipeline.hpp new file mode 100644 index 000000000..69cdb73d2 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLRenderPipeline.hpp @@ -0,0 +1,1598 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLRenderPipeline.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLPixelFormat.hpp" +#include "MTLRenderCommandEncoder.hpp" +#include "MTLRenderPipeline.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, BlendFactor) { + BlendFactorZero = 0, + BlendFactorOne = 1, + BlendFactorSourceColor = 2, + BlendFactorOneMinusSourceColor = 3, + BlendFactorSourceAlpha = 4, + BlendFactorOneMinusSourceAlpha = 5, + BlendFactorDestinationColor = 6, + BlendFactorOneMinusDestinationColor = 7, + BlendFactorDestinationAlpha = 8, + BlendFactorOneMinusDestinationAlpha = 9, + BlendFactorSourceAlphaSaturated = 10, + BlendFactorBlendColor = 11, + BlendFactorOneMinusBlendColor = 12, + BlendFactorBlendAlpha = 13, + BlendFactorOneMinusBlendAlpha = 14, + BlendFactorSource1Color = 15, + BlendFactorOneMinusSource1Color = 16, + BlendFactorSource1Alpha = 17, + BlendFactorOneMinusSource1Alpha = 18, +}; + +_MTL_ENUM(NS::UInteger, BlendOperation) { + BlendOperationAdd = 0, + BlendOperationSubtract = 1, + BlendOperationReverseSubtract = 2, + BlendOperationMin = 3, + BlendOperationMax = 4, +}; + +_MTL_OPTIONS(NS::UInteger, ColorWriteMask) { + ColorWriteMaskNone = 0, + ColorWriteMaskAlpha = 1, + ColorWriteMaskBlue = 2, + ColorWriteMaskGreen = 4, + ColorWriteMaskRed = 8, + ColorWriteMaskAll = 15, +}; + +_MTL_ENUM(NS::UInteger, PrimitiveTopologyClass) { + PrimitiveTopologyClassUnspecified = 0, + PrimitiveTopologyClassPoint = 1, + PrimitiveTopologyClassLine = 2, + PrimitiveTopologyClassTriangle = 3, +}; + +_MTL_ENUM(NS::UInteger, TessellationPartitionMode) { + TessellationPartitionModePow2 = 0, + TessellationPartitionModeInteger = 1, + TessellationPartitionModeFractionalOdd = 2, + TessellationPartitionModeFractionalEven = 3, +}; + +_MTL_ENUM(NS::UInteger, TessellationFactorStepFunction) { + TessellationFactorStepFunctionConstant = 0, + TessellationFactorStepFunctionPerPatch = 1, + TessellationFactorStepFunctionPerInstance = 2, + TessellationFactorStepFunctionPerPatchAndPerInstance = 3, +}; + +_MTL_ENUM(NS::UInteger, TessellationFactorFormat) { + TessellationFactorFormatHalf = 0, +}; + +_MTL_ENUM(NS::UInteger, TessellationControlPointIndexType) { + TessellationControlPointIndexTypeNone = 0, + TessellationControlPointIndexTypeUInt16 = 1, + TessellationControlPointIndexTypeUInt32 = 2, +}; + +class RenderPipelineColorAttachmentDescriptor : public NS::Copying +{ +public: + static class RenderPipelineColorAttachmentDescriptor* alloc(); + + class RenderPipelineColorAttachmentDescriptor* init(); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); + + bool blendingEnabled() const; + void setBlendingEnabled(bool blendingEnabled); + + MTL::BlendFactor sourceRGBBlendFactor() const; + void setSourceRGBBlendFactor(MTL::BlendFactor sourceRGBBlendFactor); + + MTL::BlendFactor destinationRGBBlendFactor() const; + void setDestinationRGBBlendFactor(MTL::BlendFactor destinationRGBBlendFactor); + + MTL::BlendOperation rgbBlendOperation() const; + void setRgbBlendOperation(MTL::BlendOperation rgbBlendOperation); + + MTL::BlendFactor sourceAlphaBlendFactor() const; + void setSourceAlphaBlendFactor(MTL::BlendFactor sourceAlphaBlendFactor); + + MTL::BlendFactor destinationAlphaBlendFactor() const; + void setDestinationAlphaBlendFactor(MTL::BlendFactor destinationAlphaBlendFactor); + + MTL::BlendOperation alphaBlendOperation() const; + void setAlphaBlendOperation(MTL::BlendOperation alphaBlendOperation); + + MTL::ColorWriteMask writeMask() const; + void setWriteMask(MTL::ColorWriteMask writeMask); +}; + +class RenderPipelineReflection : public NS::Referencing +{ +public: + static class RenderPipelineReflection* alloc(); + + class RenderPipelineReflection* init(); + + NS::Array* vertexBindings() const; + + NS::Array* fragmentBindings() const; + + NS::Array* tileBindings() const; + + NS::Array* objectBindings() const; + + NS::Array* meshBindings() const; + + NS::Array* vertexArguments() const; + + NS::Array* fragmentArguments() const; + + NS::Array* tileArguments() const; +}; + +class RenderPipelineDescriptor : public NS::Copying +{ +public: + static class RenderPipelineDescriptor* alloc(); + + class RenderPipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* vertexFunction() const; + void setVertexFunction(const class Function* vertexFunction); + + class Function* fragmentFunction() const; + void setFragmentFunction(const class Function* fragmentFunction); + + class VertexDescriptor* vertexDescriptor() const; + void setVertexDescriptor(const class VertexDescriptor* vertexDescriptor); + + NS::UInteger sampleCount() const; + void setSampleCount(NS::UInteger sampleCount); + + NS::UInteger rasterSampleCount() const; + void setRasterSampleCount(NS::UInteger rasterSampleCount); + + bool alphaToCoverageEnabled() const; + void setAlphaToCoverageEnabled(bool alphaToCoverageEnabled); + + bool alphaToOneEnabled() const; + void setAlphaToOneEnabled(bool alphaToOneEnabled); + + bool rasterizationEnabled() const; + void setRasterizationEnabled(bool rasterizationEnabled); + + NS::UInteger maxVertexAmplificationCount() const; + void setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount); + + class RenderPipelineColorAttachmentDescriptorArray* colorAttachments() const; + + MTL::PixelFormat depthAttachmentPixelFormat() const; + void setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat); + + MTL::PixelFormat stencilAttachmentPixelFormat() const; + void setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat); + + MTL::PrimitiveTopologyClass inputPrimitiveTopology() const; + void setInputPrimitiveTopology(MTL::PrimitiveTopologyClass inputPrimitiveTopology); + + MTL::TessellationPartitionMode tessellationPartitionMode() const; + void setTessellationPartitionMode(MTL::TessellationPartitionMode tessellationPartitionMode); + + NS::UInteger maxTessellationFactor() const; + void setMaxTessellationFactor(NS::UInteger maxTessellationFactor); + + bool tessellationFactorScaleEnabled() const; + void setTessellationFactorScaleEnabled(bool tessellationFactorScaleEnabled); + + MTL::TessellationFactorFormat tessellationFactorFormat() const; + void setTessellationFactorFormat(MTL::TessellationFactorFormat tessellationFactorFormat); + + MTL::TessellationControlPointIndexType tessellationControlPointIndexType() const; + void setTessellationControlPointIndexType(MTL::TessellationControlPointIndexType tessellationControlPointIndexType); + + MTL::TessellationFactorStepFunction tessellationFactorStepFunction() const; + void setTessellationFactorStepFunction(MTL::TessellationFactorStepFunction tessellationFactorStepFunction); + + MTL::Winding tessellationOutputWindingOrder() const; + void setTessellationOutputWindingOrder(MTL::Winding tessellationOutputWindingOrder); + + class PipelineBufferDescriptorArray* vertexBuffers() const; + + class PipelineBufferDescriptorArray* fragmentBuffers() const; + + bool supportIndirectCommandBuffers() const; + void setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + NS::Array* vertexPreloadedLibraries() const; + void setVertexPreloadedLibraries(const NS::Array* vertexPreloadedLibraries); + + NS::Array* fragmentPreloadedLibraries() const; + void setFragmentPreloadedLibraries(const NS::Array* fragmentPreloadedLibraries); + + class LinkedFunctions* vertexLinkedFunctions() const; + void setVertexLinkedFunctions(const class LinkedFunctions* vertexLinkedFunctions); + + class LinkedFunctions* fragmentLinkedFunctions() const; + void setFragmentLinkedFunctions(const class LinkedFunctions* fragmentLinkedFunctions); + + bool supportAddingVertexBinaryFunctions() const; + void setSupportAddingVertexBinaryFunctions(bool supportAddingVertexBinaryFunctions); + + bool supportAddingFragmentBinaryFunctions() const; + void setSupportAddingFragmentBinaryFunctions(bool supportAddingFragmentBinaryFunctions); + + NS::UInteger maxVertexCallStackDepth() const; + void setMaxVertexCallStackDepth(NS::UInteger maxVertexCallStackDepth); + + NS::UInteger maxFragmentCallStackDepth() const; + void setMaxFragmentCallStackDepth(NS::UInteger maxFragmentCallStackDepth); + + void reset(); +}; + +class RenderPipelineFunctionsDescriptor : public NS::Copying +{ +public: + static class RenderPipelineFunctionsDescriptor* alloc(); + + class RenderPipelineFunctionsDescriptor* init(); + + NS::Array* vertexAdditionalBinaryFunctions() const; + void setVertexAdditionalBinaryFunctions(const NS::Array* vertexAdditionalBinaryFunctions); + + NS::Array* fragmentAdditionalBinaryFunctions() const; + void setFragmentAdditionalBinaryFunctions(const NS::Array* fragmentAdditionalBinaryFunctions); + + NS::Array* tileAdditionalBinaryFunctions() const; + void setTileAdditionalBinaryFunctions(const NS::Array* tileAdditionalBinaryFunctions); +}; + +class RenderPipelineState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + + bool threadgroupSizeMatchesTileSize() const; + + NS::UInteger imageblockSampleLength() const; + + NS::UInteger imageblockMemoryLength(MTL::Size imageblockDimensions); + + bool supportIndirectCommandBuffers() const; + + NS::UInteger maxTotalThreadsPerObjectThreadgroup() const; + + NS::UInteger maxTotalThreadsPerMeshThreadgroup() const; + + NS::UInteger objectThreadExecutionWidth() const; + + NS::UInteger meshThreadExecutionWidth() const; + + NS::UInteger maxTotalThreadgroupsPerMeshGrid() const; + + MTL::ResourceID gpuResourceID() const; + + class FunctionHandle* functionHandle(const class Function* function, MTL::RenderStages stage); + + class VisibleFunctionTable* newVisibleFunctionTable(const class VisibleFunctionTableDescriptor* descriptor, MTL::RenderStages stage); + + class IntersectionFunctionTable* newIntersectionFunctionTable(const class IntersectionFunctionTableDescriptor* descriptor, MTL::RenderStages stage); + + class RenderPipelineState* newRenderPipelineState(const class RenderPipelineFunctionsDescriptor* additionalBinaryFunctions, NS::Error** error); +}; + +class RenderPipelineColorAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class RenderPipelineColorAttachmentDescriptorArray* alloc(); + + class RenderPipelineColorAttachmentDescriptorArray* init(); + + class RenderPipelineColorAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class RenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class TileRenderPipelineColorAttachmentDescriptor : public NS::Copying +{ +public: + static class TileRenderPipelineColorAttachmentDescriptor* alloc(); + + class TileRenderPipelineColorAttachmentDescriptor* init(); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); +}; + +class TileRenderPipelineColorAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class TileRenderPipelineColorAttachmentDescriptorArray* alloc(); + + class TileRenderPipelineColorAttachmentDescriptorArray* init(); + + class TileRenderPipelineColorAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class TileRenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class TileRenderPipelineDescriptor : public NS::Copying +{ +public: + static class TileRenderPipelineDescriptor* alloc(); + + class TileRenderPipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* tileFunction() const; + void setTileFunction(const class Function* tileFunction); + + NS::UInteger rasterSampleCount() const; + void setRasterSampleCount(NS::UInteger rasterSampleCount); + + class TileRenderPipelineColorAttachmentDescriptorArray* colorAttachments() const; + + bool threadgroupSizeMatchesTileSize() const; + void setThreadgroupSizeMatchesTileSize(bool threadgroupSizeMatchesTileSize); + + class PipelineBufferDescriptorArray* tileBuffers() const; + + NS::UInteger maxTotalThreadsPerThreadgroup() const; + void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup); + + NS::Array* binaryArchives() const; + void setBinaryArchives(const NS::Array* binaryArchives); + + NS::Array* preloadedLibraries() const; + void setPreloadedLibraries(const NS::Array* preloadedLibraries); + + class LinkedFunctions* linkedFunctions() const; + void setLinkedFunctions(const class LinkedFunctions* linkedFunctions); + + bool supportAddingBinaryFunctions() const; + void setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions); + + NS::UInteger maxCallStackDepth() const; + void setMaxCallStackDepth(NS::UInteger maxCallStackDepth); + + void reset(); +}; + +class MeshRenderPipelineDescriptor : public NS::Copying +{ +public: + static class MeshRenderPipelineDescriptor* alloc(); + + class MeshRenderPipelineDescriptor* init(); + + NS::String* label() const; + void setLabel(const NS::String* label); + + class Function* objectFunction() const; + void setObjectFunction(const class Function* objectFunction); + + class Function* meshFunction() const; + void setMeshFunction(const class Function* meshFunction); + + class Function* fragmentFunction() const; + void setFragmentFunction(const class Function* fragmentFunction); + + NS::UInteger maxTotalThreadsPerObjectThreadgroup() const; + void setMaxTotalThreadsPerObjectThreadgroup(NS::UInteger maxTotalThreadsPerObjectThreadgroup); + + NS::UInteger maxTotalThreadsPerMeshThreadgroup() const; + void setMaxTotalThreadsPerMeshThreadgroup(NS::UInteger maxTotalThreadsPerMeshThreadgroup); + + bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth() const; + void setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth); + + bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth() const; + void setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth); + + NS::UInteger payloadMemoryLength() const; + void setPayloadMemoryLength(NS::UInteger payloadMemoryLength); + + NS::UInteger maxTotalThreadgroupsPerMeshGrid() const; + void setMaxTotalThreadgroupsPerMeshGrid(NS::UInteger maxTotalThreadgroupsPerMeshGrid); + + class PipelineBufferDescriptorArray* objectBuffers() const; + + class PipelineBufferDescriptorArray* meshBuffers() const; + + class PipelineBufferDescriptorArray* fragmentBuffers() const; + + NS::UInteger rasterSampleCount() const; + void setRasterSampleCount(NS::UInteger rasterSampleCount); + + bool alphaToCoverageEnabled() const; + void setAlphaToCoverageEnabled(bool alphaToCoverageEnabled); + + bool alphaToOneEnabled() const; + void setAlphaToOneEnabled(bool alphaToOneEnabled); + + bool rasterizationEnabled() const; + void setRasterizationEnabled(bool rasterizationEnabled); + + NS::UInteger maxVertexAmplificationCount() const; + void setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount); + + class RenderPipelineColorAttachmentDescriptorArray* colorAttachments() const; + + MTL::PixelFormat depthAttachmentPixelFormat() const; + void setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat); + + MTL::PixelFormat stencilAttachmentPixelFormat() const; + void setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat); + + void reset(); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineColorAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: pixelFormat +_MTL_INLINE MTL::PixelFormat MTL::RenderPipelineColorAttachmentDescriptor::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat); +} + +// property: blendingEnabled +_MTL_INLINE bool MTL::RenderPipelineColorAttachmentDescriptor::blendingEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isBlendingEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setBlendingEnabled(bool blendingEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBlendingEnabled_), blendingEnabled); +} + +// property: sourceRGBBlendFactor +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::sourceRGBBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sourceRGBBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setSourceRGBBlendFactor(MTL::BlendFactor sourceRGBBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSourceRGBBlendFactor_), sourceRGBBlendFactor); +} + +// property: destinationRGBBlendFactor +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::destinationRGBBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(destinationRGBBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setDestinationRGBBlendFactor(MTL::BlendFactor destinationRGBBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDestinationRGBBlendFactor_), destinationRGBBlendFactor); +} + +// property: rgbBlendOperation +_MTL_INLINE MTL::BlendOperation MTL::RenderPipelineColorAttachmentDescriptor::rgbBlendOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rgbBlendOperation)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setRgbBlendOperation(MTL::BlendOperation rgbBlendOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRgbBlendOperation_), rgbBlendOperation); +} + +// property: sourceAlphaBlendFactor +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::sourceAlphaBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sourceAlphaBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setSourceAlphaBlendFactor(MTL::BlendFactor sourceAlphaBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSourceAlphaBlendFactor_), sourceAlphaBlendFactor); +} + +// property: destinationAlphaBlendFactor +_MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::destinationAlphaBlendFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(destinationAlphaBlendFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setDestinationAlphaBlendFactor(MTL::BlendFactor destinationAlphaBlendFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDestinationAlphaBlendFactor_), destinationAlphaBlendFactor); +} + +// property: alphaBlendOperation +_MTL_INLINE MTL::BlendOperation MTL::RenderPipelineColorAttachmentDescriptor::alphaBlendOperation() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(alphaBlendOperation)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setAlphaBlendOperation(MTL::BlendOperation alphaBlendOperation) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaBlendOperation_), alphaBlendOperation); +} + +// property: writeMask +_MTL_INLINE MTL::ColorWriteMask MTL::RenderPipelineColorAttachmentDescriptor::writeMask() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(writeMask)); +} + +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setWriteMask(MTL::ColorWriteMask writeMask) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setWriteMask_), writeMask); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPipelineReflection* MTL::RenderPipelineReflection::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineReflection)); +} + +// method: init +_MTL_INLINE MTL::RenderPipelineReflection* MTL::RenderPipelineReflection::init() +{ + return NS::Object::init(); +} + +// property: vertexBindings +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::vertexBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBindings)); +} + +// property: fragmentBindings +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::fragmentBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentBindings)); +} + +// property: tileBindings +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::tileBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileBindings)); +} + +// property: objectBindings +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::objectBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectBindings)); +} + +// property: meshBindings +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::meshBindings() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshBindings)); +} + +// property: vertexArguments +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::vertexArguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexArguments)); +} + +// property: fragmentArguments +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::fragmentArguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentArguments)); +} + +// property: tileArguments +_MTL_INLINE NS::Array* MTL::RenderPipelineReflection::tileArguments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileArguments)); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPipelineDescriptor* MTL::RenderPipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPipelineDescriptor* MTL::RenderPipelineDescriptor::init() +{ + return NS::Object::init(); +} + +// property: label +_MTL_INLINE NS::String* MTL::RenderPipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: vertexFunction +_MTL_INLINE MTL::Function* MTL::RenderPipelineDescriptor::vertexFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexFunction)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexFunction(const MTL::Function* vertexFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexFunction_), vertexFunction); +} + +// property: fragmentFunction +_MTL_INLINE MTL::Function* MTL::RenderPipelineDescriptor::fragmentFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentFunction)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentFunction(const MTL::Function* fragmentFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentFunction_), fragmentFunction); +} + +// property: vertexDescriptor +_MTL_INLINE MTL::VertexDescriptor* MTL::RenderPipelineDescriptor::vertexDescriptor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexDescriptor)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexDescriptor(const MTL::VertexDescriptor* vertexDescriptor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexDescriptor_), vertexDescriptor); +} + +// property: sampleCount +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSampleCount(NS::UInteger sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +// property: rasterSampleCount +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::rasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterSampleCount)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount); +} + +// property: alphaToCoverageEnabled +_MTL_INLINE bool MTL::RenderPipelineDescriptor::alphaToCoverageEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToCoverageEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setAlphaToCoverageEnabled(bool alphaToCoverageEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToCoverageEnabled_), alphaToCoverageEnabled); +} + +// property: alphaToOneEnabled +_MTL_INLINE bool MTL::RenderPipelineDescriptor::alphaToOneEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToOneEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setAlphaToOneEnabled(bool alphaToOneEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToOneEnabled_), alphaToOneEnabled); +} + +// property: rasterizationEnabled +_MTL_INLINE bool MTL::RenderPipelineDescriptor::rasterizationEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isRasterizationEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setRasterizationEnabled(bool rasterizationEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterizationEnabled_), rasterizationEnabled); +} + +// property: maxVertexAmplificationCount +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxVertexAmplificationCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexAmplificationCount)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexAmplificationCount_), maxVertexAmplificationCount); +} + +// property: colorAttachments +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +// property: depthAttachmentPixelFormat +_MTL_INLINE MTL::PixelFormat MTL::RenderPipelineDescriptor::depthAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthAttachmentPixelFormat_), depthAttachmentPixelFormat); +} + +// property: stencilAttachmentPixelFormat +_MTL_INLINE MTL::PixelFormat MTL::RenderPipelineDescriptor::stencilAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilAttachmentPixelFormat_), stencilAttachmentPixelFormat); +} + +// property: inputPrimitiveTopology +_MTL_INLINE MTL::PrimitiveTopologyClass MTL::RenderPipelineDescriptor::inputPrimitiveTopology() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(inputPrimitiveTopology)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setInputPrimitiveTopology(MTL::PrimitiveTopologyClass inputPrimitiveTopology) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setInputPrimitiveTopology_), inputPrimitiveTopology); +} + +// property: tessellationPartitionMode +_MTL_INLINE MTL::TessellationPartitionMode MTL::RenderPipelineDescriptor::tessellationPartitionMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationPartitionMode)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationPartitionMode(MTL::TessellationPartitionMode tessellationPartitionMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationPartitionMode_), tessellationPartitionMode); +} + +// property: maxTessellationFactor +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxTessellationFactor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTessellationFactor)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxTessellationFactor(NS::UInteger maxTessellationFactor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTessellationFactor_), maxTessellationFactor); +} + +// property: tessellationFactorScaleEnabled +_MTL_INLINE bool MTL::RenderPipelineDescriptor::tessellationFactorScaleEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isTessellationFactorScaleEnabled)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorScaleEnabled(bool tessellationFactorScaleEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorScaleEnabled_), tessellationFactorScaleEnabled); +} + +// property: tessellationFactorFormat +_MTL_INLINE MTL::TessellationFactorFormat MTL::RenderPipelineDescriptor::tessellationFactorFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationFactorFormat)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorFormat(MTL::TessellationFactorFormat tessellationFactorFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorFormat_), tessellationFactorFormat); +} + +// property: tessellationControlPointIndexType +_MTL_INLINE MTL::TessellationControlPointIndexType MTL::RenderPipelineDescriptor::tessellationControlPointIndexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationControlPointIndexType)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationControlPointIndexType(MTL::TessellationControlPointIndexType tessellationControlPointIndexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationControlPointIndexType_), tessellationControlPointIndexType); +} + +// property: tessellationFactorStepFunction +_MTL_INLINE MTL::TessellationFactorStepFunction MTL::RenderPipelineDescriptor::tessellationFactorStepFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationFactorStepFunction)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorStepFunction(MTL::TessellationFactorStepFunction tessellationFactorStepFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationFactorStepFunction_), tessellationFactorStepFunction); +} + +// property: tessellationOutputWindingOrder +_MTL_INLINE MTL::Winding MTL::RenderPipelineDescriptor::tessellationOutputWindingOrder() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tessellationOutputWindingOrder)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationOutputWindingOrder(MTL::Winding tessellationOutputWindingOrder) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTessellationOutputWindingOrder_), tessellationOutputWindingOrder); +} + +// property: vertexBuffers +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::RenderPipelineDescriptor::vertexBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexBuffers)); +} + +// property: fragmentBuffers +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::RenderPipelineDescriptor::fragmentBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentBuffers)); +} + +// property: supportIndirectCommandBuffers +_MTL_INLINE bool MTL::RenderPipelineDescriptor::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportIndirectCommandBuffers_), supportIndirectCommandBuffers); +} + +// property: binaryArchives +_MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +// property: vertexPreloadedLibraries +_MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::vertexPreloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexPreloadedLibraries)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexPreloadedLibraries(const NS::Array* vertexPreloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexPreloadedLibraries_), vertexPreloadedLibraries); +} + +// property: fragmentPreloadedLibraries +_MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::fragmentPreloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentPreloadedLibraries)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentPreloadedLibraries(const NS::Array* fragmentPreloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentPreloadedLibraries_), fragmentPreloadedLibraries); +} + +// property: vertexLinkedFunctions +_MTL_INLINE MTL::LinkedFunctions* MTL::RenderPipelineDescriptor::vertexLinkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexLinkedFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexLinkedFunctions(const MTL::LinkedFunctions* vertexLinkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexLinkedFunctions_), vertexLinkedFunctions); +} + +// property: fragmentLinkedFunctions +_MTL_INLINE MTL::LinkedFunctions* MTL::RenderPipelineDescriptor::fragmentLinkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentLinkedFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentLinkedFunctions(const MTL::LinkedFunctions* fragmentLinkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentLinkedFunctions_), fragmentLinkedFunctions); +} + +// property: supportAddingVertexBinaryFunctions +_MTL_INLINE bool MTL::RenderPipelineDescriptor::supportAddingVertexBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingVertexBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportAddingVertexBinaryFunctions(bool supportAddingVertexBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingVertexBinaryFunctions_), supportAddingVertexBinaryFunctions); +} + +// property: supportAddingFragmentBinaryFunctions +_MTL_INLINE bool MTL::RenderPipelineDescriptor::supportAddingFragmentBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingFragmentBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportAddingFragmentBinaryFunctions(bool supportAddingFragmentBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingFragmentBinaryFunctions_), supportAddingFragmentBinaryFunctions); +} + +// property: maxVertexCallStackDepth +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxVertexCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexCallStackDepth)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxVertexCallStackDepth(NS::UInteger maxVertexCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexCallStackDepth_), maxVertexCallStackDepth); +} + +// property: maxFragmentCallStackDepth +_MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxFragmentCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxFragmentCallStackDepth)); +} + +_MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxFragmentCallStackDepth(NS::UInteger maxFragmentCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxFragmentCallStackDepth_), maxFragmentCallStackDepth); +} + +// method: reset +_MTL_INLINE void MTL::RenderPipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPipelineFunctionsDescriptor* MTL::RenderPipelineFunctionsDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineFunctionsDescriptor)); +} + +// method: init +_MTL_INLINE MTL::RenderPipelineFunctionsDescriptor* MTL::RenderPipelineFunctionsDescriptor::init() +{ + return NS::Object::init(); +} + +// property: vertexAdditionalBinaryFunctions +_MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::vertexAdditionalBinaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(vertexAdditionalBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setVertexAdditionalBinaryFunctions(const NS::Array* vertexAdditionalBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexAdditionalBinaryFunctions_), vertexAdditionalBinaryFunctions); +} + +// property: fragmentAdditionalBinaryFunctions +_MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::fragmentAdditionalBinaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentAdditionalBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setFragmentAdditionalBinaryFunctions(const NS::Array* fragmentAdditionalBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentAdditionalBinaryFunctions_), fragmentAdditionalBinaryFunctions); +} + +// property: tileAdditionalBinaryFunctions +_MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::tileAdditionalBinaryFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileAdditionalBinaryFunctions)); +} + +_MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setTileAdditionalBinaryFunctions(const NS::Array* tileAdditionalBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileAdditionalBinaryFunctions_), tileAdditionalBinaryFunctions); +} + +// property: label +_MTL_INLINE NS::String* MTL::RenderPipelineState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::RenderPipelineState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: maxTotalThreadsPerThreadgroup +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +// property: threadgroupSizeMatchesTileSize +_MTL_INLINE bool MTL::RenderPipelineState::threadgroupSizeMatchesTileSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupSizeMatchesTileSize)); +} + +// property: imageblockSampleLength +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::imageblockSampleLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockSampleLength)); +} + +// method: imageblockMemoryLengthForDimensions: +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::imageblockMemoryLength(MTL::Size imageblockDimensions) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(imageblockMemoryLengthForDimensions_), imageblockDimensions); +} + +// property: supportIndirectCommandBuffers +_MTL_INLINE bool MTL::RenderPipelineState::supportIndirectCommandBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers)); +} + +// property: maxTotalThreadsPerObjectThreadgroup +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerObjectThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerObjectThreadgroup)); +} + +// property: maxTotalThreadsPerMeshThreadgroup +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerMeshThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerMeshThreadgroup)); +} + +// property: objectThreadExecutionWidth +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::objectThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectThreadExecutionWidth)); +} + +// property: meshThreadExecutionWidth +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::meshThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshThreadExecutionWidth)); +} + +// property: maxTotalThreadgroupsPerMeshGrid +_MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadgroupsPerMeshGrid() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadgroupsPerMeshGrid)); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::RenderPipelineState::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +// method: functionHandleWithFunction:stage: +_MTL_INLINE MTL::FunctionHandle* MTL::RenderPipelineState::functionHandle(const MTL::Function* function, MTL::RenderStages stage) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionHandleWithFunction_stage_), function, stage); +} + +// method: newVisibleFunctionTableWithDescriptor:stage: +_MTL_INLINE MTL::VisibleFunctionTable* MTL::RenderPipelineState::newVisibleFunctionTable(const MTL::VisibleFunctionTableDescriptor* descriptor, MTL::RenderStages stage) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newVisibleFunctionTableWithDescriptor_stage_), descriptor, stage); +} + +// method: newIntersectionFunctionTableWithDescriptor:stage: +_MTL_INLINE MTL::IntersectionFunctionTable* MTL::RenderPipelineState::newIntersectionFunctionTable(const MTL::IntersectionFunctionTableDescriptor* descriptor, MTL::RenderStages stage) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIntersectionFunctionTableWithDescriptor_stage_), descriptor, stage); +} + +// method: newRenderPipelineStateWithAdditionalBinaryFunctions:error: +_MTL_INLINE MTL::RenderPipelineState* MTL::RenderPipelineState::newRenderPipelineState(const MTL::RenderPipelineFunctionsDescriptor* additionalBinaryFunctions, NS::Error** error) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithAdditionalBinaryFunctions_error_), additionalBinaryFunctions, error); +} + +// static method: alloc +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineColorAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLRenderPipelineColorAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineColorAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptorArray::setObject(const MTL::RenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTileRenderPipelineColorAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: pixelFormat +_MTL_INLINE MTL::PixelFormat MTL::TileRenderPipelineColorAttachmentDescriptor::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +_MTL_INLINE void MTL::TileRenderPipelineColorAttachmentDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat); +} + +// static method: alloc +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineColorAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTileRenderPipelineColorAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineColorAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::TileRenderPipelineColorAttachmentDescriptorArray::setObject(const MTL::TileRenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::TileRenderPipelineDescriptor* MTL::TileRenderPipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTileRenderPipelineDescriptor)); +} + +// method: init +_MTL_INLINE MTL::TileRenderPipelineDescriptor* MTL::TileRenderPipelineDescriptor::init() +{ + return NS::Object::init(); +} + +// property: label +_MTL_INLINE NS::String* MTL::TileRenderPipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: tileFunction +_MTL_INLINE MTL::Function* MTL::TileRenderPipelineDescriptor::tileFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileFunction)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setTileFunction(const MTL::Function* tileFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTileFunction_), tileFunction); +} + +// property: rasterSampleCount +_MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::rasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterSampleCount)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount); +} + +// property: colorAttachments +_MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +// property: threadgroupSizeMatchesTileSize +_MTL_INLINE bool MTL::TileRenderPipelineDescriptor::threadgroupSizeMatchesTileSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(threadgroupSizeMatchesTileSize)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setThreadgroupSizeMatchesTileSize(bool threadgroupSizeMatchesTileSize) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setThreadgroupSizeMatchesTileSize_), threadgroupSizeMatchesTileSize); +} + +// property: tileBuffers +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::TileRenderPipelineDescriptor::tileBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tileBuffers)); +} + +// property: maxTotalThreadsPerThreadgroup +_MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::maxTotalThreadsPerThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup); +} + +// property: binaryArchives +_MTL_INLINE NS::Array* MTL::TileRenderPipelineDescriptor::binaryArchives() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(binaryArchives)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives); +} + +// property: preloadedLibraries +_MTL_INLINE NS::Array* MTL::TileRenderPipelineDescriptor::preloadedLibraries() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(preloadedLibraries)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setPreloadedLibraries(const NS::Array* preloadedLibraries) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPreloadedLibraries_), preloadedLibraries); +} + +// property: linkedFunctions +_MTL_INLINE MTL::LinkedFunctions* MTL::TileRenderPipelineDescriptor::linkedFunctions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(linkedFunctions)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setLinkedFunctions(const MTL::LinkedFunctions* linkedFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLinkedFunctions_), linkedFunctions); +} + +// property: supportAddingBinaryFunctions +_MTL_INLINE bool MTL::TileRenderPipelineDescriptor::supportAddingBinaryFunctions() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportAddingBinaryFunctions)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportAddingBinaryFunctions_), supportAddingBinaryFunctions); +} + +// property: maxCallStackDepth +_MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::maxCallStackDepth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxCallStackDepth)); +} + +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::setMaxCallStackDepth(NS::UInteger maxCallStackDepth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxCallStackDepth_), maxCallStackDepth); +} + +// method: reset +_MTL_INLINE void MTL::TileRenderPipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} + +// static method: alloc +_MTL_INLINE MTL::MeshRenderPipelineDescriptor* MTL::MeshRenderPipelineDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLMeshRenderPipelineDescriptor)); +} + +// method: init +_MTL_INLINE MTL::MeshRenderPipelineDescriptor* MTL::MeshRenderPipelineDescriptor::init() +{ + return NS::Object::init(); +} + +// property: label +_MTL_INLINE NS::String* MTL::MeshRenderPipelineDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: objectFunction +_MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::objectFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectFunction)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectFunction(const MTL::Function* objectFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectFunction_), objectFunction); +} + +// property: meshFunction +_MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::meshFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshFunction)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshFunction(const MTL::Function* meshFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshFunction_), meshFunction); +} + +// property: fragmentFunction +_MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::fragmentFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentFunction)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setFragmentFunction(const MTL::Function* fragmentFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentFunction_), fragmentFunction); +} + +// property: maxTotalThreadsPerObjectThreadgroup +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadsPerObjectThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerObjectThreadgroup)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadsPerObjectThreadgroup(NS::UInteger maxTotalThreadsPerObjectThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerObjectThreadgroup_), maxTotalThreadsPerObjectThreadgroup); +} + +// property: maxTotalThreadsPerMeshThreadgroup +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadsPerMeshThreadgroup() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerMeshThreadgroup)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadsPerMeshThreadgroup(NS::UInteger maxTotalThreadsPerMeshThreadgroup) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerMeshThreadgroup_), maxTotalThreadsPerMeshThreadgroup); +} + +// property: objectThreadgroupSizeIsMultipleOfThreadExecutionWidth +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::objectThreadgroupSizeIsMultipleOfThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectThreadgroupSizeIsMultipleOfThreadExecutionWidth)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth_), objectThreadgroupSizeIsMultipleOfThreadExecutionWidth); +} + +// property: meshThreadgroupSizeIsMultipleOfThreadExecutionWidth +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::meshThreadgroupSizeIsMultipleOfThreadExecutionWidth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshThreadgroupSizeIsMultipleOfThreadExecutionWidth)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth_), meshThreadgroupSizeIsMultipleOfThreadExecutionWidth); +} + +// property: payloadMemoryLength +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::payloadMemoryLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(payloadMemoryLength)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setPayloadMemoryLength(NS::UInteger payloadMemoryLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPayloadMemoryLength_), payloadMemoryLength); +} + +// property: maxTotalThreadgroupsPerMeshGrid +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadgroupsPerMeshGrid() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxTotalThreadgroupsPerMeshGrid)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadgroupsPerMeshGrid(NS::UInteger maxTotalThreadgroupsPerMeshGrid) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxTotalThreadgroupsPerMeshGrid_), maxTotalThreadgroupsPerMeshGrid); +} + +// property: objectBuffers +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::objectBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectBuffers)); +} + +// property: meshBuffers +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::meshBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshBuffers)); +} + +// property: fragmentBuffers +_MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::fragmentBuffers() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentBuffers)); +} + +// property: rasterSampleCount +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::rasterSampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rasterSampleCount)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount); +} + +// property: alphaToCoverageEnabled +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::alphaToCoverageEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToCoverageEnabled)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setAlphaToCoverageEnabled(bool alphaToCoverageEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToCoverageEnabled_), alphaToCoverageEnabled); +} + +// property: alphaToOneEnabled +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::alphaToOneEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAlphaToOneEnabled)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setAlphaToOneEnabled(bool alphaToOneEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAlphaToOneEnabled_), alphaToOneEnabled); +} + +// property: rasterizationEnabled +_MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::rasterizationEnabled() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isRasterizationEnabled)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setRasterizationEnabled(bool rasterizationEnabled) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRasterizationEnabled_), rasterizationEnabled); +} + +// property: maxVertexAmplificationCount +_MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxVertexAmplificationCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxVertexAmplificationCount)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxVertexAmplificationCount_), maxVertexAmplificationCount); +} + +// property: colorAttachments +_MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::MeshRenderPipelineDescriptor::colorAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(colorAttachments)); +} + +// property: depthAttachmentPixelFormat +_MTL_INLINE MTL::PixelFormat MTL::MeshRenderPipelineDescriptor::depthAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depthAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepthAttachmentPixelFormat_), depthAttachmentPixelFormat); +} + +// property: stencilAttachmentPixelFormat +_MTL_INLINE MTL::PixelFormat MTL::MeshRenderPipelineDescriptor::stencilAttachmentPixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stencilAttachmentPixelFormat)); +} + +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStencilAttachmentPixelFormat_), stencilAttachmentPixelFormat); +} + +// method: reset +_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} diff --git a/vendor/metal-cpp/Metal/MTLResource.hpp b/vendor/metal-cpp/Metal/MTLResource.hpp new file mode 100644 index 000000000..69c57d38d --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLResource.hpp @@ -0,0 +1,178 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLResource.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLResource.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, PurgeableState) { + PurgeableStateKeepCurrent = 1, + PurgeableStateNonVolatile = 2, + PurgeableStateVolatile = 3, + PurgeableStateEmpty = 4, +}; + +_MTL_ENUM(NS::UInteger, CPUCacheMode) { + CPUCacheModeDefaultCache = 0, + CPUCacheModeWriteCombined = 1, +}; + +_MTL_ENUM(NS::UInteger, StorageMode) { + StorageModeShared = 0, + StorageModeManaged = 1, + StorageModePrivate = 2, + StorageModeMemoryless = 3, +}; + +_MTL_ENUM(NS::UInteger, HazardTrackingMode) { + HazardTrackingModeDefault = 0, + HazardTrackingModeUntracked = 1, + HazardTrackingModeTracked = 2, +}; + +_MTL_OPTIONS(NS::UInteger, ResourceOptions) { + ResourceStorageModeShared = 0, + ResourceHazardTrackingModeDefault = 0, + ResourceCPUCacheModeDefaultCache = 0, + ResourceOptionCPUCacheModeDefault = 0, + ResourceCPUCacheModeWriteCombined = 1, + ResourceOptionCPUCacheModeWriteCombined = 1, + ResourceStorageModeManaged = 16, + ResourceStorageModePrivate = 32, + ResourceStorageModeMemoryless = 48, + ResourceHazardTrackingModeUntracked = 256, + ResourceHazardTrackingModeTracked = 512, +}; + +class Resource : public NS::Referencing +{ +public: + NS::String* label() const; + void setLabel(const NS::String* label); + + class Device* device() const; + + MTL::CPUCacheMode cpuCacheMode() const; + + MTL::StorageMode storageMode() const; + + MTL::HazardTrackingMode hazardTrackingMode() const; + + MTL::ResourceOptions resourceOptions() const; + + MTL::PurgeableState setPurgeableState(MTL::PurgeableState state); + + class Heap* heap() const; + + NS::UInteger heapOffset() const; + + NS::UInteger allocatedSize() const; + + void makeAliasable(); + + bool isAliasable(); +}; + +} + +// property: label +_MTL_INLINE NS::String* MTL::Resource::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::Resource::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::Resource::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: cpuCacheMode +_MTL_INLINE MTL::CPUCacheMode MTL::Resource::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +// property: storageMode +_MTL_INLINE MTL::StorageMode MTL::Resource::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +// property: hazardTrackingMode +_MTL_INLINE MTL::HazardTrackingMode MTL::Resource::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +// property: resourceOptions +_MTL_INLINE MTL::ResourceOptions MTL::Resource::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +// method: setPurgeableState: +_MTL_INLINE MTL::PurgeableState MTL::Resource::setPurgeableState(MTL::PurgeableState state) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(setPurgeableState_), state); +} + +// property: heap +_MTL_INLINE MTL::Heap* MTL::Resource::heap() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heap)); +} + +// property: heapOffset +_MTL_INLINE NS::UInteger MTL::Resource::heapOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(heapOffset)); +} + +// property: allocatedSize +_MTL_INLINE NS::UInteger MTL::Resource::allocatedSize() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allocatedSize)); +} + +// method: makeAliasable +_MTL_INLINE void MTL::Resource::makeAliasable() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(makeAliasable)); +} + +// method: isAliasable +_MTL_INLINE bool MTL::Resource::isAliasable() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isAliasable)); +} diff --git a/vendor/metal-cpp/Metal/MTLResourceStateCommandEncoder.hpp b/vendor/metal-cpp/Metal/MTLResourceStateCommandEncoder.hpp new file mode 100644 index 000000000..cf54f387d --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLResourceStateCommandEncoder.hpp @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLResourceStateCommandEncoder.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLCommandEncoder.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, SparseTextureMappingMode) { + SparseTextureMappingModeMap = 0, + SparseTextureMappingModeUnmap = 1, +}; + +struct MapIndirectArguments +{ + uint32_t regionOriginX; + uint32_t regionOriginY; + uint32_t regionOriginZ; + uint32_t regionSizeWidth; + uint32_t regionSizeHeight; + uint32_t regionSizeDepth; + uint32_t mipMapLevel; + uint32_t sliceId; +} _MTL_PACKED; + +class ResourceStateCommandEncoder : public NS::Referencing +{ +public: + void updateTextureMappings(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions); + + void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice); + + void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset); + + void updateFence(const class Fence* fence); + + void waitForFence(const class Fence* fence); + + void moveTextureMappingsFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin); +}; + +} + +// method: updateTextureMappings:mode:regions:mipLevels:slices:numRegions: +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMappings(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateTextureMappings_mode_regions_mipLevels_slices_numRegions_), texture, mode, regions, mipLevels, slices, numRegions); +} + +// method: updateTextureMapping:mode:region:mipLevel:slice: +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_region_mipLevel_slice_), texture, mode, region, mipLevel, slice); +} + +// method: updateTextureMapping:mode:indirectBuffer:indirectBufferOffset: +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_indirectBuffer_indirectBufferOffset_), texture, mode, indirectBuffer, indirectBufferOffset); +} + +// method: updateFence: +_MTL_INLINE void MTL::ResourceStateCommandEncoder::updateFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(updateFence_), fence); +} + +// method: waitForFence: +_MTL_INLINE void MTL::ResourceStateCommandEncoder::waitForFence(const MTL::Fence* fence) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(waitForFence_), fence); +} + +// method: moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin: +_MTL_INLINE void MTL::ResourceStateCommandEncoder::moveTextureMappingsFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(moveTextureMappingsFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin); +} diff --git a/vendor/metal-cpp/Metal/MTLResourceStatePass.hpp b/vendor/metal-cpp/Metal/MTLResourceStatePass.hpp new file mode 100644 index 000000000..3c759b1a5 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLResourceStatePass.hpp @@ -0,0 +1,165 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLResourceStatePass.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +namespace MTL +{ +class ResourceStatePassSampleBufferAttachmentDescriptor : public NS::Copying +{ +public: + static class ResourceStatePassSampleBufferAttachmentDescriptor* alloc(); + + class ResourceStatePassSampleBufferAttachmentDescriptor* init(); + + class CounterSampleBuffer* sampleBuffer() const; + void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer); + + NS::UInteger startOfEncoderSampleIndex() const; + void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex); + + NS::UInteger endOfEncoderSampleIndex() const; + void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex); +}; + +class ResourceStatePassSampleBufferAttachmentDescriptorArray : public NS::Referencing +{ +public: + static class ResourceStatePassSampleBufferAttachmentDescriptorArray* alloc(); + + class ResourceStatePassSampleBufferAttachmentDescriptorArray* init(); + + class ResourceStatePassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex); + + void setObject(const class ResourceStatePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex); +}; + +class ResourceStatePassDescriptor : public NS::Copying +{ +public: + static class ResourceStatePassDescriptor* alloc(); + + class ResourceStatePassDescriptor* init(); + + static class ResourceStatePassDescriptor* resourceStatePassDescriptor(); + + class ResourceStatePassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptor)); +} + +// method: init +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::init() +{ + return NS::Object::init(); +} + +// property: sampleBuffer +_MTL_INLINE MTL::CounterSampleBuffer* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::sampleBuffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBuffer)); +} + +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer); +} + +// property: startOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::ResourceStatePassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex); +} + +// property: endOfEncoderSampleIndex +_MTL_INLINE NS::UInteger MTL::ResourceStatePassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex)); +} + +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex); +} + +// static method: alloc +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::setObject(const MTL::ResourceStatePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex); +} + +// static method: alloc +_MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLResourceStatePassDescriptor)); +} + +// method: init +_MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: resourceStatePassDescriptor +_MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::resourceStatePassDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLResourceStatePassDescriptor), _MTL_PRIVATE_SEL(resourceStatePassDescriptor)); +} + +// property: sampleBufferAttachments +_MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassDescriptor::sampleBufferAttachments() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleBufferAttachments)); +} diff --git a/vendor/metal-cpp/Metal/MTLSampler.hpp b/vendor/metal-cpp/Metal/MTLSampler.hpp new file mode 100644 index 000000000..b086744a6 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLSampler.hpp @@ -0,0 +1,319 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLSampler.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLDepthStencil.hpp" +#include "MTLSampler.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, SamplerMinMagFilter) { + SamplerMinMagFilterNearest = 0, + SamplerMinMagFilterLinear = 1, +}; + +_MTL_ENUM(NS::UInteger, SamplerMipFilter) { + SamplerMipFilterNotMipmapped = 0, + SamplerMipFilterNearest = 1, + SamplerMipFilterLinear = 2, +}; + +_MTL_ENUM(NS::UInteger, SamplerAddressMode) { + SamplerAddressModeClampToEdge = 0, + SamplerAddressModeMirrorClampToEdge = 1, + SamplerAddressModeRepeat = 2, + SamplerAddressModeMirrorRepeat = 3, + SamplerAddressModeClampToZero = 4, + SamplerAddressModeClampToBorderColor = 5, +}; + +_MTL_ENUM(NS::UInteger, SamplerBorderColor) { + SamplerBorderColorTransparentBlack = 0, + SamplerBorderColorOpaqueBlack = 1, + SamplerBorderColorOpaqueWhite = 2, +}; + +class SamplerDescriptor : public NS::Copying +{ +public: + static class SamplerDescriptor* alloc(); + + class SamplerDescriptor* init(); + + MTL::SamplerMinMagFilter minFilter() const; + void setMinFilter(MTL::SamplerMinMagFilter minFilter); + + MTL::SamplerMinMagFilter magFilter() const; + void setMagFilter(MTL::SamplerMinMagFilter magFilter); + + MTL::SamplerMipFilter mipFilter() const; + void setMipFilter(MTL::SamplerMipFilter mipFilter); + + NS::UInteger maxAnisotropy() const; + void setMaxAnisotropy(NS::UInteger maxAnisotropy); + + MTL::SamplerAddressMode sAddressMode() const; + void setSAddressMode(MTL::SamplerAddressMode sAddressMode); + + MTL::SamplerAddressMode tAddressMode() const; + void setTAddressMode(MTL::SamplerAddressMode tAddressMode); + + MTL::SamplerAddressMode rAddressMode() const; + void setRAddressMode(MTL::SamplerAddressMode rAddressMode); + + MTL::SamplerBorderColor borderColor() const; + void setBorderColor(MTL::SamplerBorderColor borderColor); + + bool normalizedCoordinates() const; + void setNormalizedCoordinates(bool normalizedCoordinates); + + float lodMinClamp() const; + void setLodMinClamp(float lodMinClamp); + + float lodMaxClamp() const; + void setLodMaxClamp(float lodMaxClamp); + + bool lodAverage() const; + void setLodAverage(bool lodAverage); + + MTL::CompareFunction compareFunction() const; + void setCompareFunction(MTL::CompareFunction compareFunction); + + bool supportArgumentBuffers() const; + void setSupportArgumentBuffers(bool supportArgumentBuffers); + + NS::String* label() const; + void setLabel(const NS::String* label); +}; + +class SamplerState : public NS::Referencing +{ +public: + NS::String* label() const; + + class Device* device() const; + + MTL::ResourceID gpuResourceID() const; +}; + +} + +// static method: alloc +_MTL_INLINE MTL::SamplerDescriptor* MTL::SamplerDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSamplerDescriptor)); +} + +// method: init +_MTL_INLINE MTL::SamplerDescriptor* MTL::SamplerDescriptor::init() +{ + return NS::Object::init(); +} + +// property: minFilter +_MTL_INLINE MTL::SamplerMinMagFilter MTL::SamplerDescriptor::minFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(minFilter)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMinFilter(MTL::SamplerMinMagFilter minFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMinFilter_), minFilter); +} + +// property: magFilter +_MTL_INLINE MTL::SamplerMinMagFilter MTL::SamplerDescriptor::magFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(magFilter)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMagFilter(MTL::SamplerMinMagFilter magFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMagFilter_), magFilter); +} + +// property: mipFilter +_MTL_INLINE MTL::SamplerMipFilter MTL::SamplerDescriptor::mipFilter() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mipFilter)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMipFilter(MTL::SamplerMipFilter mipFilter) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMipFilter_), mipFilter); +} + +// property: maxAnisotropy +_MTL_INLINE NS::UInteger MTL::SamplerDescriptor::maxAnisotropy() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxAnisotropy)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setMaxAnisotropy(NS::UInteger maxAnisotropy) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxAnisotropy_), maxAnisotropy); +} + +// property: sAddressMode +_MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::sAddressMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sAddressMode)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setSAddressMode(MTL::SamplerAddressMode sAddressMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSAddressMode_), sAddressMode); +} + +// property: tAddressMode +_MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::tAddressMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tAddressMode)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setTAddressMode(MTL::SamplerAddressMode tAddressMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTAddressMode_), tAddressMode); +} + +// property: rAddressMode +_MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::rAddressMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rAddressMode)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setRAddressMode(MTL::SamplerAddressMode rAddressMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setRAddressMode_), rAddressMode); +} + +// property: borderColor +_MTL_INLINE MTL::SamplerBorderColor MTL::SamplerDescriptor::borderColor() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(borderColor)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setBorderColor(MTL::SamplerBorderColor borderColor) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBorderColor_), borderColor); +} + +// property: normalizedCoordinates +_MTL_INLINE bool MTL::SamplerDescriptor::normalizedCoordinates() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(normalizedCoordinates)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setNormalizedCoordinates(bool normalizedCoordinates) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setNormalizedCoordinates_), normalizedCoordinates); +} + +// property: lodMinClamp +_MTL_INLINE float MTL::SamplerDescriptor::lodMinClamp() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(lodMinClamp)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLodMinClamp(float lodMinClamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLodMinClamp_), lodMinClamp); +} + +// property: lodMaxClamp +_MTL_INLINE float MTL::SamplerDescriptor::lodMaxClamp() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(lodMaxClamp)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLodMaxClamp(float lodMaxClamp) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLodMaxClamp_), lodMaxClamp); +} + +// property: lodAverage +_MTL_INLINE bool MTL::SamplerDescriptor::lodAverage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(lodAverage)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLodAverage(bool lodAverage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLodAverage_), lodAverage); +} + +// property: compareFunction +_MTL_INLINE MTL::CompareFunction MTL::SamplerDescriptor::compareFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compareFunction)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setCompareFunction(MTL::CompareFunction compareFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCompareFunction_), compareFunction); +} + +// property: supportArgumentBuffers +_MTL_INLINE bool MTL::SamplerDescriptor::supportArgumentBuffers() const +{ + return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportArgumentBuffers)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setSupportArgumentBuffers(bool supportArgumentBuffers) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportArgumentBuffers_), supportArgumentBuffers); +} + +// property: label +_MTL_INLINE NS::String* MTL::SamplerDescriptor::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +_MTL_INLINE void MTL::SamplerDescriptor::setLabel(const NS::String* label) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); +} + +// property: label +_MTL_INLINE NS::String* MTL::SamplerState::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::SamplerState::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::SamplerState::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} diff --git a/vendor/metal-cpp/Metal/MTLStageInputOutputDescriptor.hpp b/vendor/metal-cpp/Metal/MTLStageInputOutputDescriptor.hpp new file mode 100644 index 000000000..e75abf374 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLStageInputOutputDescriptor.hpp @@ -0,0 +1,381 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLStageInputOutputDescriptor.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLStageInputOutputDescriptor.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, AttributeFormat) { + AttributeFormatInvalid = 0, + AttributeFormatUChar2 = 1, + AttributeFormatUChar3 = 2, + AttributeFormatUChar4 = 3, + AttributeFormatChar2 = 4, + AttributeFormatChar3 = 5, + AttributeFormatChar4 = 6, + AttributeFormatUChar2Normalized = 7, + AttributeFormatUChar3Normalized = 8, + AttributeFormatUChar4Normalized = 9, + AttributeFormatChar2Normalized = 10, + AttributeFormatChar3Normalized = 11, + AttributeFormatChar4Normalized = 12, + AttributeFormatUShort2 = 13, + AttributeFormatUShort3 = 14, + AttributeFormatUShort4 = 15, + AttributeFormatShort2 = 16, + AttributeFormatShort3 = 17, + AttributeFormatShort4 = 18, + AttributeFormatUShort2Normalized = 19, + AttributeFormatUShort3Normalized = 20, + AttributeFormatUShort4Normalized = 21, + AttributeFormatShort2Normalized = 22, + AttributeFormatShort3Normalized = 23, + AttributeFormatShort4Normalized = 24, + AttributeFormatHalf2 = 25, + AttributeFormatHalf3 = 26, + AttributeFormatHalf4 = 27, + AttributeFormatFloat = 28, + AttributeFormatFloat2 = 29, + AttributeFormatFloat3 = 30, + AttributeFormatFloat4 = 31, + AttributeFormatInt = 32, + AttributeFormatInt2 = 33, + AttributeFormatInt3 = 34, + AttributeFormatInt4 = 35, + AttributeFormatUInt = 36, + AttributeFormatUInt2 = 37, + AttributeFormatUInt3 = 38, + AttributeFormatUInt4 = 39, + AttributeFormatInt1010102Normalized = 40, + AttributeFormatUInt1010102Normalized = 41, + AttributeFormatUChar4Normalized_BGRA = 42, + AttributeFormatUChar = 45, + AttributeFormatChar = 46, + AttributeFormatUCharNormalized = 47, + AttributeFormatCharNormalized = 48, + AttributeFormatUShort = 49, + AttributeFormatShort = 50, + AttributeFormatUShortNormalized = 51, + AttributeFormatShortNormalized = 52, + AttributeFormatHalf = 53, +}; + +_MTL_ENUM(NS::UInteger, IndexType) { + IndexTypeUInt16 = 0, + IndexTypeUInt32 = 1, +}; + +_MTL_ENUM(NS::UInteger, StepFunction) { + StepFunctionConstant = 0, + StepFunctionPerVertex = 1, + StepFunctionPerInstance = 2, + StepFunctionPerPatch = 3, + StepFunctionPerPatchControlPoint = 4, + StepFunctionThreadPositionInGridX = 5, + StepFunctionThreadPositionInGridY = 6, + StepFunctionThreadPositionInGridXIndexed = 7, + StepFunctionThreadPositionInGridYIndexed = 8, +}; + +class BufferLayoutDescriptor : public NS::Copying +{ +public: + static class BufferLayoutDescriptor* alloc(); + + class BufferLayoutDescriptor* init(); + + NS::UInteger stride() const; + void setStride(NS::UInteger stride); + + MTL::StepFunction stepFunction() const; + void setStepFunction(MTL::StepFunction stepFunction); + + NS::UInteger stepRate() const; + void setStepRate(NS::UInteger stepRate); +}; + +class BufferLayoutDescriptorArray : public NS::Referencing +{ +public: + static class BufferLayoutDescriptorArray* alloc(); + + class BufferLayoutDescriptorArray* init(); + + class BufferLayoutDescriptor* object(NS::UInteger index); + + void setObject(const class BufferLayoutDescriptor* bufferDesc, NS::UInteger index); +}; + +class AttributeDescriptor : public NS::Copying +{ +public: + static class AttributeDescriptor* alloc(); + + class AttributeDescriptor* init(); + + MTL::AttributeFormat format() const; + void setFormat(MTL::AttributeFormat format); + + NS::UInteger offset() const; + void setOffset(NS::UInteger offset); + + NS::UInteger bufferIndex() const; + void setBufferIndex(NS::UInteger bufferIndex); +}; + +class AttributeDescriptorArray : public NS::Referencing +{ +public: + static class AttributeDescriptorArray* alloc(); + + class AttributeDescriptorArray* init(); + + class AttributeDescriptor* object(NS::UInteger index); + + void setObject(const class AttributeDescriptor* attributeDesc, NS::UInteger index); +}; + +class StageInputOutputDescriptor : public NS::Copying +{ +public: + static class StageInputOutputDescriptor* alloc(); + + class StageInputOutputDescriptor* init(); + + static class StageInputOutputDescriptor* stageInputOutputDescriptor(); + + class BufferLayoutDescriptorArray* layouts() const; + + class AttributeDescriptorArray* attributes() const; + + MTL::IndexType indexType() const; + void setIndexType(MTL::IndexType indexType); + + NS::UInteger indexBufferIndex() const; + void setIndexBufferIndex(NS::UInteger indexBufferIndex); + + void reset(); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBufferLayoutDescriptor)); +} + +// method: init +_MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptor::init() +{ + return NS::Object::init(); +} + +// property: stride +_MTL_INLINE NS::UInteger MTL::BufferLayoutDescriptor::stride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stride)); +} + +_MTL_INLINE void MTL::BufferLayoutDescriptor::setStride(NS::UInteger stride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStride_), stride); +} + +// property: stepFunction +_MTL_INLINE MTL::StepFunction MTL::BufferLayoutDescriptor::stepFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepFunction)); +} + +_MTL_INLINE void MTL::BufferLayoutDescriptor::setStepFunction(MTL::StepFunction stepFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepFunction_), stepFunction); +} + +// property: stepRate +_MTL_INLINE NS::UInteger MTL::BufferLayoutDescriptor::stepRate() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepRate)); +} + +_MTL_INLINE void MTL::BufferLayoutDescriptor::setStepRate(NS::UInteger stepRate) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepRate_), stepRate); +} + +// static method: alloc +_MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::BufferLayoutDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLBufferLayoutDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::BufferLayoutDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::BufferLayoutDescriptorArray::setObject(const MTL::BufferLayoutDescriptor* bufferDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), bufferDesc, index); +} + +// static method: alloc +_MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAttributeDescriptor)); +} + +// method: init +_MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptor::init() +{ + return NS::Object::init(); +} + +// property: format +_MTL_INLINE MTL::AttributeFormat MTL::AttributeDescriptor::format() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(format)); +} + +_MTL_INLINE void MTL::AttributeDescriptor::setFormat(MTL::AttributeFormat format) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFormat_), format); +} + +// property: offset +_MTL_INLINE NS::UInteger MTL::AttributeDescriptor::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +_MTL_INLINE void MTL::AttributeDescriptor::setOffset(NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOffset_), offset); +} + +// property: bufferIndex +_MTL_INLINE NS::UInteger MTL::AttributeDescriptor::bufferIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferIndex)); +} + +_MTL_INLINE void MTL::AttributeDescriptor::setBufferIndex(NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferIndex_), bufferIndex); +} + +// static method: alloc +_MTL_INLINE MTL::AttributeDescriptorArray* MTL::AttributeDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAttributeDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::AttributeDescriptorArray* MTL::AttributeDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::AttributeDescriptorArray::setObject(const MTL::AttributeDescriptor* attributeDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attributeDesc, index); +} + +// static method: alloc +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLStageInputOutputDescriptor)); +} + +// method: init +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: stageInputOutputDescriptor +_MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::stageInputOutputDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLStageInputOutputDescriptor), _MTL_PRIVATE_SEL(stageInputOutputDescriptor)); +} + +// property: layouts +_MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::StageInputOutputDescriptor::layouts() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layouts)); +} + +// property: attributes +_MTL_INLINE MTL::AttributeDescriptorArray* MTL::StageInputOutputDescriptor::attributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributes)); +} + +// property: indexType +_MTL_INLINE MTL::IndexType MTL::StageInputOutputDescriptor::indexType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); +} + +_MTL_INLINE void MTL::StageInputOutputDescriptor::setIndexType(MTL::IndexType indexType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); +} + +// property: indexBufferIndex +_MTL_INLINE NS::UInteger MTL::StageInputOutputDescriptor::indexBufferIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferIndex)); +} + +_MTL_INLINE void MTL::StageInputOutputDescriptor::setIndexBufferIndex(NS::UInteger indexBufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferIndex_), indexBufferIndex); +} + +// method: reset +_MTL_INLINE void MTL::StageInputOutputDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} diff --git a/vendor/metal-cpp/Metal/MTLTexture.hpp b/vendor/metal-cpp/Metal/MTLTexture.hpp new file mode 100644 index 000000000..8d18c736b --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLTexture.hpp @@ -0,0 +1,684 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLTexture.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLPixelFormat.hpp" +#include "MTLResource.hpp" +#include "MTLTexture.hpp" +#include "MTLTypes.hpp" +#include + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, TextureType) { + TextureType1D = 0, + TextureType1DArray = 1, + TextureType2D = 2, + TextureType2DArray = 3, + TextureType2DMultisample = 4, + TextureTypeCube = 5, + TextureTypeCubeArray = 6, + TextureType3D = 7, + TextureType2DMultisampleArray = 8, + TextureTypeTextureBuffer = 9, +}; + +_MTL_ENUM(uint8_t, TextureSwizzle) { + TextureSwizzleZero = 0, + TextureSwizzleOne = 1, + TextureSwizzleRed = 2, + TextureSwizzleGreen = 3, + TextureSwizzleBlue = 4, + TextureSwizzleAlpha = 5, +}; + +struct TextureSwizzleChannels +{ + MTL::TextureSwizzle red; + MTL::TextureSwizzle green; + MTL::TextureSwizzle blue; + MTL::TextureSwizzle alpha; +} _MTL_PACKED; + +class SharedTextureHandle : public NS::SecureCoding +{ +public: + static class SharedTextureHandle* alloc(); + + class SharedTextureHandle* init(); + + class Device* device() const; + + NS::String* label() const; +}; + +_MTL_OPTIONS(NS::UInteger, TextureUsage) { + TextureUsageUnknown = 0, + TextureUsageShaderRead = 1, + TextureUsageShaderWrite = 2, + TextureUsageRenderTarget = 4, + TextureUsagePixelFormatView = 16, +}; + +_MTL_ENUM(NS::Integer, TextureCompressionType) { + TextureCompressionTypeLossless = 0, + TextureCompressionTypeLossy = 1, +}; + +class TextureDescriptor : public NS::Copying +{ +public: + static class TextureDescriptor* alloc(); + + class TextureDescriptor* init(); + + static class TextureDescriptor* texture2DDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, NS::UInteger height, bool mipmapped); + + static class TextureDescriptor* textureCubeDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger size, bool mipmapped); + + static class TextureDescriptor* textureBufferDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, MTL::ResourceOptions resourceOptions, MTL::TextureUsage usage); + + MTL::TextureType textureType() const; + void setTextureType(MTL::TextureType textureType); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); + + NS::UInteger width() const; + void setWidth(NS::UInteger width); + + NS::UInteger height() const; + void setHeight(NS::UInteger height); + + NS::UInteger depth() const; + void setDepth(NS::UInteger depth); + + NS::UInteger mipmapLevelCount() const; + void setMipmapLevelCount(NS::UInteger mipmapLevelCount); + + NS::UInteger sampleCount() const; + void setSampleCount(NS::UInteger sampleCount); + + NS::UInteger arrayLength() const; + void setArrayLength(NS::UInteger arrayLength); + + MTL::ResourceOptions resourceOptions() const; + void setResourceOptions(MTL::ResourceOptions resourceOptions); + + MTL::CPUCacheMode cpuCacheMode() const; + void setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode); + + MTL::StorageMode storageMode() const; + void setStorageMode(MTL::StorageMode storageMode); + + MTL::HazardTrackingMode hazardTrackingMode() const; + void setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode); + + MTL::TextureUsage usage() const; + void setUsage(MTL::TextureUsage usage); + + bool allowGPUOptimizedContents() const; + void setAllowGPUOptimizedContents(bool allowGPUOptimizedContents); + + MTL::TextureCompressionType compressionType() const; + void setCompressionType(MTL::TextureCompressionType compressionType); + + MTL::TextureSwizzleChannels swizzle() const; + void setSwizzle(MTL::TextureSwizzleChannels swizzle); +}; + +class Texture : public NS::Referencing +{ +public: + class Resource* rootResource() const; + + class Texture* parentTexture() const; + + NS::UInteger parentRelativeLevel() const; + + NS::UInteger parentRelativeSlice() const; + + class Buffer* buffer() const; + + NS::UInteger bufferOffset() const; + + NS::UInteger bufferBytesPerRow() const; + + IOSurfaceRef iosurface() const; + + NS::UInteger iosurfacePlane() const; + + MTL::TextureType textureType() const; + + MTL::PixelFormat pixelFormat() const; + + NS::UInteger width() const; + + NS::UInteger height() const; + + NS::UInteger depth() const; + + NS::UInteger mipmapLevelCount() const; + + NS::UInteger sampleCount() const; + + NS::UInteger arrayLength() const; + + MTL::TextureUsage usage() const; + + bool shareable() const; + + bool framebufferOnly() const; + + NS::UInteger firstMipmapInTail() const; + + NS::UInteger tailSizeInBytes() const; + + bool isSparse() const; + + bool allowGPUOptimizedContents() const; + + MTL::TextureCompressionType compressionType() const; + + MTL::ResourceID gpuResourceID() const; + + void getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage, MTL::Region region, NS::UInteger level, NS::UInteger slice); + + void replaceRegion(MTL::Region region, NS::UInteger level, NS::UInteger slice, const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage); + + void getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, MTL::Region region, NS::UInteger level); + + void replaceRegion(MTL::Region region, NS::UInteger level, const void* pixelBytes, NS::UInteger bytesPerRow); + + class Texture* newTextureView(MTL::PixelFormat pixelFormat); + + class Texture* newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange); + + class SharedTextureHandle* newSharedTextureHandle(); + + class Texture* remoteStorageTexture() const; + + class Texture* newRemoteTextureViewForDevice(const class Device* device); + + MTL::TextureSwizzleChannels swizzle() const; + + class Texture* newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange, MTL::TextureSwizzleChannels swizzle); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::SharedTextureHandle* MTL::SharedTextureHandle::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLSharedTextureHandle)); +} + +// method: init +_MTL_INLINE MTL::SharedTextureHandle* MTL::SharedTextureHandle::init() +{ + return NS::Object::init(); +} + +// property: device +_MTL_INLINE MTL::Device* MTL::SharedTextureHandle::device() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); +} + +// property: label +_MTL_INLINE NS::String* MTL::SharedTextureHandle::label() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); +} + +// static method: alloc +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLTextureDescriptor)); +} + +// method: init +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: texture2DDescriptorWithPixelFormat:width:height:mipmapped: +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::texture2DDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, NS::UInteger height, bool mipmapped) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(texture2DDescriptorWithPixelFormat_width_height_mipmapped_), pixelFormat, width, height, mipmapped); +} + +// static method: textureCubeDescriptorWithPixelFormat:size:mipmapped: +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::textureCubeDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger size, bool mipmapped) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(textureCubeDescriptorWithPixelFormat_size_mipmapped_), pixelFormat, size, mipmapped); +} + +// static method: textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage: +_MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::textureBufferDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, MTL::ResourceOptions resourceOptions, MTL::TextureUsage usage) +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(textureBufferDescriptorWithPixelFormat_width_resourceOptions_usage_), pixelFormat, width, resourceOptions, usage); +} + +// property: textureType +_MTL_INLINE MTL::TextureType MTL::TextureDescriptor::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setTextureType(MTL::TextureType textureType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setTextureType_), textureType); +} + +// property: pixelFormat +_MTL_INLINE MTL::PixelFormat MTL::TextureDescriptor::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat); +} + +// property: width +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::width() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(width)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setWidth(NS::UInteger width) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setWidth_), width); +} + +// property: height +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::height() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(height)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setHeight(NS::UInteger height) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setHeight_), height); +} + +// property: depth +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::depth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depth)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setDepth(NS::UInteger depth) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setDepth_), depth); +} + +// property: mipmapLevelCount +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::mipmapLevelCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mipmapLevelCount)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setMipmapLevelCount(NS::UInteger mipmapLevelCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setMipmapLevelCount_), mipmapLevelCount); +} + +// property: sampleCount +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setSampleCount(NS::UInteger sampleCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount); +} + +// property: arrayLength +_MTL_INLINE NS::UInteger MTL::TextureDescriptor::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setArrayLength(NS::UInteger arrayLength) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setArrayLength_), arrayLength); +} + +// property: resourceOptions +_MTL_INLINE MTL::ResourceOptions MTL::TextureDescriptor::resourceOptions() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(resourceOptions)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setResourceOptions(MTL::ResourceOptions resourceOptions) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setResourceOptions_), resourceOptions); +} + +// property: cpuCacheMode +_MTL_INLINE MTL::CPUCacheMode MTL::TextureDescriptor::cpuCacheMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(cpuCacheMode)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCpuCacheMode_), cpuCacheMode); +} + +// property: storageMode +_MTL_INLINE MTL::StorageMode MTL::TextureDescriptor::storageMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(storageMode)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setStorageMode(MTL::StorageMode storageMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode); +} + +// property: hazardTrackingMode +_MTL_INLINE MTL::HazardTrackingMode MTL::TextureDescriptor::hazardTrackingMode() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(hazardTrackingMode)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setHazardTrackingMode_), hazardTrackingMode); +} + +// property: usage +_MTL_INLINE MTL::TextureUsage MTL::TextureDescriptor::usage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usage)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setUsage(MTL::TextureUsage usage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setUsage_), usage); +} + +// property: allowGPUOptimizedContents +_MTL_INLINE bool MTL::TextureDescriptor::allowGPUOptimizedContents() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowGPUOptimizedContents)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setAllowGPUOptimizedContents(bool allowGPUOptimizedContents) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setAllowGPUOptimizedContents_), allowGPUOptimizedContents); +} + +// property: compressionType +_MTL_INLINE MTL::TextureCompressionType MTL::TextureDescriptor::compressionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compressionType)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setCompressionType(MTL::TextureCompressionType compressionType) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setCompressionType_), compressionType); +} + +// property: swizzle +_MTL_INLINE MTL::TextureSwizzleChannels MTL::TextureDescriptor::swizzle() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(swizzle)); +} + +_MTL_INLINE void MTL::TextureDescriptor::setSwizzle(MTL::TextureSwizzleChannels swizzle) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setSwizzle_), swizzle); +} + +// property: rootResource +_MTL_INLINE MTL::Resource* MTL::Texture::rootResource() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(rootResource)); +} + +// property: parentTexture +_MTL_INLINE MTL::Texture* MTL::Texture::parentTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parentTexture)); +} + +// property: parentRelativeLevel +_MTL_INLINE NS::UInteger MTL::Texture::parentRelativeLevel() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parentRelativeLevel)); +} + +// property: parentRelativeSlice +_MTL_INLINE NS::UInteger MTL::Texture::parentRelativeSlice() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(parentRelativeSlice)); +} + +// property: buffer +_MTL_INLINE MTL::Buffer* MTL::Texture::buffer() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(buffer)); +} + +// property: bufferOffset +_MTL_INLINE NS::UInteger MTL::Texture::bufferOffset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferOffset)); +} + +// property: bufferBytesPerRow +_MTL_INLINE NS::UInteger MTL::Texture::bufferBytesPerRow() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferBytesPerRow)); +} + +// property: iosurface +_MTL_INLINE IOSurfaceRef MTL::Texture::iosurface() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(iosurface)); +} + +// property: iosurfacePlane +_MTL_INLINE NS::UInteger MTL::Texture::iosurfacePlane() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(iosurfacePlane)); +} + +// property: textureType +_MTL_INLINE MTL::TextureType MTL::Texture::textureType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(textureType)); +} + +// property: pixelFormat +_MTL_INLINE MTL::PixelFormat MTL::Texture::pixelFormat() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(pixelFormat)); +} + +// property: width +_MTL_INLINE NS::UInteger MTL::Texture::width() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(width)); +} + +// property: height +_MTL_INLINE NS::UInteger MTL::Texture::height() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(height)); +} + +// property: depth +_MTL_INLINE NS::UInteger MTL::Texture::depth() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(depth)); +} + +// property: mipmapLevelCount +_MTL_INLINE NS::UInteger MTL::Texture::mipmapLevelCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(mipmapLevelCount)); +} + +// property: sampleCount +_MTL_INLINE NS::UInteger MTL::Texture::sampleCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(sampleCount)); +} + +// property: arrayLength +_MTL_INLINE NS::UInteger MTL::Texture::arrayLength() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(arrayLength)); +} + +// property: usage +_MTL_INLINE MTL::TextureUsage MTL::Texture::usage() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(usage)); +} + +// property: shareable +_MTL_INLINE bool MTL::Texture::shareable() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isShareable)); +} + +// property: framebufferOnly +_MTL_INLINE bool MTL::Texture::framebufferOnly() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isFramebufferOnly)); +} + +// property: firstMipmapInTail +_MTL_INLINE NS::UInteger MTL::Texture::firstMipmapInTail() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(firstMipmapInTail)); +} + +// property: tailSizeInBytes +_MTL_INLINE NS::UInteger MTL::Texture::tailSizeInBytes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(tailSizeInBytes)); +} + +// property: isSparse +_MTL_INLINE bool MTL::Texture::isSparse() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(isSparse)); +} + +// property: allowGPUOptimizedContents +_MTL_INLINE bool MTL::Texture::allowGPUOptimizedContents() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(allowGPUOptimizedContents)); +} + +// property: compressionType +_MTL_INLINE MTL::TextureCompressionType MTL::Texture::compressionType() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(compressionType)); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::Texture::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +// method: getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice: +_MTL_INLINE void MTL::Texture::getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage, MTL::Region region, NS::UInteger level, NS::UInteger slice) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getBytes_bytesPerRow_bytesPerImage_fromRegion_mipmapLevel_slice_), pixelBytes, bytesPerRow, bytesPerImage, region, level, slice); +} + +// method: replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage: +_MTL_INLINE void MTL::Texture::replaceRegion(MTL::Region region, NS::UInteger level, NS::UInteger slice, const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(replaceRegion_mipmapLevel_slice_withBytes_bytesPerRow_bytesPerImage_), region, level, slice, pixelBytes, bytesPerRow, bytesPerImage); +} + +// method: getBytes:bytesPerRow:fromRegion:mipmapLevel: +_MTL_INLINE void MTL::Texture::getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, MTL::Region region, NS::UInteger level) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(getBytes_bytesPerRow_fromRegion_mipmapLevel_), pixelBytes, bytesPerRow, region, level); +} + +// method: replaceRegion:mipmapLevel:withBytes:bytesPerRow: +_MTL_INLINE void MTL::Texture::replaceRegion(MTL::Region region, NS::UInteger level, const void* pixelBytes, NS::UInteger bytesPerRow) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(replaceRegion_mipmapLevel_withBytes_bytesPerRow_), region, level, pixelBytes, bytesPerRow); +} + +// method: newTextureViewWithPixelFormat: +_MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_), pixelFormat); +} + +// method: newTextureViewWithPixelFormat:textureType:levels:slices: +_MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_), pixelFormat, textureType, levelRange, sliceRange); +} + +// method: newSharedTextureHandle +_MTL_INLINE MTL::SharedTextureHandle* MTL::Texture::newSharedTextureHandle() +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newSharedTextureHandle)); +} + +// property: remoteStorageTexture +_MTL_INLINE MTL::Texture* MTL::Texture::remoteStorageTexture() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(remoteStorageTexture)); +} + +// method: newRemoteTextureViewForDevice: +_MTL_INLINE MTL::Texture* MTL::Texture::newRemoteTextureViewForDevice(const MTL::Device* device) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newRemoteTextureViewForDevice_), device); +} + +// property: swizzle +_MTL_INLINE MTL::TextureSwizzleChannels MTL::Texture::swizzle() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(swizzle)); +} + +// method: newTextureViewWithPixelFormat:textureType:levels:slices:swizzle: +_MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange, MTL::TextureSwizzleChannels swizzle) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_swizzle_), pixelFormat, textureType, levelRange, sliceRange, swizzle); +} diff --git a/vendor/metal-cpp/Metal/MTLTypes.hpp b/vendor/metal-cpp/Metal/MTLTypes.hpp new file mode 100644 index 000000000..09a81840c --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLTypes.hpp @@ -0,0 +1,168 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLTypes.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLTypes.hpp" + +namespace MTL +{ +struct Origin +{ + Origin() = default; + + Origin(NS::UInteger x, NS::UInteger y, NS::UInteger z); + + static Origin Make(NS::UInteger x, NS::UInteger y, NS::UInteger z); + + NS::UInteger x; + NS::UInteger y; + NS::UInteger z; +} _MTL_PACKED; + +struct Size +{ + Size() = default; + + Size(NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + static Size Make(NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + NS::UInteger width; + NS::UInteger height; + NS::UInteger depth; +} _MTL_PACKED; + +struct Region +{ + Region() = default; + + Region(NS::UInteger x, NS::UInteger width); + + Region(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height); + + Region(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + static Region Make1D(NS::UInteger x, NS::UInteger width); + + static Region Make2D(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height); + + static Region Make3D(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth); + + MTL::Origin origin; + MTL::Size size; +} _MTL_PACKED; + +struct SamplePosition; + +using Coordinate2D = SamplePosition; + +struct SamplePosition +{ + SamplePosition() = default; + + SamplePosition(float _x, float _y); + + static SamplePosition Make(float x, float y); + + float x; + float y; +} _MTL_PACKED; + +struct ResourceID +{ + uint64_t _impl; +} _MTL_PACKED; + +} + +_MTL_INLINE MTL::Origin::Origin(NS::UInteger _x, NS::UInteger _y, NS::UInteger _z) + : x(_x) + , y(_y) + , z(_z) +{ +} + +_MTL_INLINE MTL::Origin MTL::Origin::Make(NS::UInteger x, NS::UInteger y, NS::UInteger z) +{ + return Origin(x, y, z); +} + +_MTL_INLINE MTL::Size::Size(NS::UInteger _width, NS::UInteger _height, NS::UInteger _depth) + : width(_width) + , height(_height) + , depth(_depth) +{ +} + +_MTL_INLINE MTL::Size MTL::Size::Make(NS::UInteger width, NS::UInteger height, NS::UInteger depth) +{ + return Size(width, height, depth); +} + +_MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger width) + : origin(x, 0, 0) + , size(width, 1, 1) +{ +} + +_MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height) + : origin(x, y, 0) + , size(width, height, 1) +{ +} + +_MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth) + : origin(x, y, z) + , size(width, height, depth) +{ +} + +_MTL_INLINE MTL::Region MTL::Region::Make1D(NS::UInteger x, NS::UInteger width) +{ + return Region(x, width); +} + +_MTL_INLINE MTL::Region MTL::Region::Make2D(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height) +{ + return Region(x, y, width, height); +} + +_MTL_INLINE MTL::Region MTL::Region::Make3D(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth) +{ + return Region(x, y, z, width, height, depth); +} + +_MTL_INLINE MTL::SamplePosition::SamplePosition(float _x, float _y) + : x(_x) + , y(_y) +{ +} + +_MTL_INLINE MTL::SamplePosition MTL::SamplePosition::Make(float x, float y) +{ + return SamplePosition(x, y); +} diff --git a/vendor/metal-cpp/Metal/MTLVersion.hpp b/vendor/metal-cpp/Metal/MTLVersion.hpp new file mode 100644 index 000000000..bb03684d9 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLVersion.hpp @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLVersion.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#define METALCPP_VERSION_MAJOR 306 +#define METALCPP_VERSION_MINOR 5 +#define METALCPP_VERSION_PATCH 16 + +#define METALCPP_SUPPORTS_VERSION(major, minor, patch) \ + ((major < METALCPP_VERSION_MAJOR) || \ + (major == METALCPP_VERSION_MAJOR && minor < METALCPP_VERSION_MINOR) || \ + (major == METALCPP_VERSION_MAJOR && minor == METALCPP_VERSION_MINOR && patch <= METALCPP_VERSION_PATCH)) diff --git a/vendor/metal-cpp/Metal/MTLVertexDescriptor.hpp b/vendor/metal-cpp/Metal/MTLVertexDescriptor.hpp new file mode 100644 index 000000000..80bdc4e03 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLVertexDescriptor.hpp @@ -0,0 +1,344 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLVertexDescriptor.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLVertexDescriptor.hpp" + +namespace MTL +{ +_MTL_ENUM(NS::UInteger, VertexFormat) { + VertexFormatInvalid = 0, + VertexFormatUChar2 = 1, + VertexFormatUChar3 = 2, + VertexFormatUChar4 = 3, + VertexFormatChar2 = 4, + VertexFormatChar3 = 5, + VertexFormatChar4 = 6, + VertexFormatUChar2Normalized = 7, + VertexFormatUChar3Normalized = 8, + VertexFormatUChar4Normalized = 9, + VertexFormatChar2Normalized = 10, + VertexFormatChar3Normalized = 11, + VertexFormatChar4Normalized = 12, + VertexFormatUShort2 = 13, + VertexFormatUShort3 = 14, + VertexFormatUShort4 = 15, + VertexFormatShort2 = 16, + VertexFormatShort3 = 17, + VertexFormatShort4 = 18, + VertexFormatUShort2Normalized = 19, + VertexFormatUShort3Normalized = 20, + VertexFormatUShort4Normalized = 21, + VertexFormatShort2Normalized = 22, + VertexFormatShort3Normalized = 23, + VertexFormatShort4Normalized = 24, + VertexFormatHalf2 = 25, + VertexFormatHalf3 = 26, + VertexFormatHalf4 = 27, + VertexFormatFloat = 28, + VertexFormatFloat2 = 29, + VertexFormatFloat3 = 30, + VertexFormatFloat4 = 31, + VertexFormatInt = 32, + VertexFormatInt2 = 33, + VertexFormatInt3 = 34, + VertexFormatInt4 = 35, + VertexFormatUInt = 36, + VertexFormatUInt2 = 37, + VertexFormatUInt3 = 38, + VertexFormatUInt4 = 39, + VertexFormatInt1010102Normalized = 40, + VertexFormatUInt1010102Normalized = 41, + VertexFormatUChar4Normalized_BGRA = 42, + VertexFormatUChar = 45, + VertexFormatChar = 46, + VertexFormatUCharNormalized = 47, + VertexFormatCharNormalized = 48, + VertexFormatUShort = 49, + VertexFormatShort = 50, + VertexFormatUShortNormalized = 51, + VertexFormatShortNormalized = 52, + VertexFormatHalf = 53, +}; + +_MTL_ENUM(NS::UInteger, VertexStepFunction) { + VertexStepFunctionConstant = 0, + VertexStepFunctionPerVertex = 1, + VertexStepFunctionPerInstance = 2, + VertexStepFunctionPerPatch = 3, + VertexStepFunctionPerPatchControlPoint = 4, +}; + +class VertexBufferLayoutDescriptor : public NS::Copying +{ +public: + static class VertexBufferLayoutDescriptor* alloc(); + + class VertexBufferLayoutDescriptor* init(); + + NS::UInteger stride() const; + void setStride(NS::UInteger stride); + + MTL::VertexStepFunction stepFunction() const; + void setStepFunction(MTL::VertexStepFunction stepFunction); + + NS::UInteger stepRate() const; + void setStepRate(NS::UInteger stepRate); +}; + +class VertexBufferLayoutDescriptorArray : public NS::Referencing +{ +public: + static class VertexBufferLayoutDescriptorArray* alloc(); + + class VertexBufferLayoutDescriptorArray* init(); + + class VertexBufferLayoutDescriptor* object(NS::UInteger index); + + void setObject(const class VertexBufferLayoutDescriptor* bufferDesc, NS::UInteger index); +}; + +class VertexAttributeDescriptor : public NS::Copying +{ +public: + static class VertexAttributeDescriptor* alloc(); + + class VertexAttributeDescriptor* init(); + + MTL::VertexFormat format() const; + void setFormat(MTL::VertexFormat format); + + NS::UInteger offset() const; + void setOffset(NS::UInteger offset); + + NS::UInteger bufferIndex() const; + void setBufferIndex(NS::UInteger bufferIndex); +}; + +class VertexAttributeDescriptorArray : public NS::Referencing +{ +public: + static class VertexAttributeDescriptorArray* alloc(); + + class VertexAttributeDescriptorArray* init(); + + class VertexAttributeDescriptor* object(NS::UInteger index); + + void setObject(const class VertexAttributeDescriptor* attributeDesc, NS::UInteger index); +}; + +class VertexDescriptor : public NS::Copying +{ +public: + static class VertexDescriptor* alloc(); + + class VertexDescriptor* init(); + + static class VertexDescriptor* vertexDescriptor(); + + class VertexBufferLayoutDescriptorArray* layouts() const; + + class VertexAttributeDescriptorArray* attributes() const; + + void reset(); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexBufferLayoutDescriptor)); +} + +// method: init +_MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptor::init() +{ + return NS::Object::init(); +} + +// property: stride +_MTL_INLINE NS::UInteger MTL::VertexBufferLayoutDescriptor::stride() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stride)); +} + +_MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStride(NS::UInteger stride) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStride_), stride); +} + +// property: stepFunction +_MTL_INLINE MTL::VertexStepFunction MTL::VertexBufferLayoutDescriptor::stepFunction() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepFunction)); +} + +_MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStepFunction(MTL::VertexStepFunction stepFunction) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepFunction_), stepFunction); +} + +// property: stepRate +_MTL_INLINE NS::UInteger MTL::VertexBufferLayoutDescriptor::stepRate() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(stepRate)); +} + +_MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStepRate(NS::UInteger stepRate) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setStepRate_), stepRate); +} + +// static method: alloc +_MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexBufferLayoutDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexBufferLayoutDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexBufferLayoutDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::VertexBufferLayoutDescriptorArray::setObject(const MTL::VertexBufferLayoutDescriptor* bufferDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), bufferDesc, index); +} + +// static method: alloc +_MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexAttributeDescriptor)); +} + +// method: init +_MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptor::init() +{ + return NS::Object::init(); +} + +// property: format +_MTL_INLINE MTL::VertexFormat MTL::VertexAttributeDescriptor::format() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(format)); +} + +_MTL_INLINE void MTL::VertexAttributeDescriptor::setFormat(MTL::VertexFormat format) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFormat_), format); +} + +// property: offset +_MTL_INLINE NS::UInteger MTL::VertexAttributeDescriptor::offset() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(offset)); +} + +_MTL_INLINE void MTL::VertexAttributeDescriptor::setOffset(NS::UInteger offset) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setOffset_), offset); +} + +// property: bufferIndex +_MTL_INLINE NS::UInteger MTL::VertexAttributeDescriptor::bufferIndex() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(bufferIndex)); +} + +_MTL_INLINE void MTL::VertexAttributeDescriptor::setBufferIndex(NS::UInteger bufferIndex) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferIndex_), bufferIndex); +} + +// static method: alloc +_MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexAttributeDescriptorArray::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexAttributeDescriptorArray)); +} + +// method: init +_MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexAttributeDescriptorArray::init() +{ + return NS::Object::init(); +} + +// method: objectAtIndexedSubscript: +_MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptorArray::object(NS::UInteger index) +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index); +} + +// method: setObject:atIndexedSubscript: +_MTL_INLINE void MTL::VertexAttributeDescriptorArray::setObject(const MTL::VertexAttributeDescriptor* attributeDesc, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attributeDesc, index); +} + +// static method: alloc +_MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVertexDescriptor)); +} + +// method: init +_MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: vertexDescriptor +_MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::vertexDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLVertexDescriptor), _MTL_PRIVATE_SEL(vertexDescriptor)); +} + +// property: layouts +_MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexDescriptor::layouts() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(layouts)); +} + +// property: attributes +_MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexDescriptor::attributes() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(attributes)); +} + +// method: reset +_MTL_INLINE void MTL::VertexDescriptor::reset() +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); +} diff --git a/vendor/metal-cpp/Metal/MTLVisibleFunctionTable.hpp b/vendor/metal-cpp/Metal/MTLVisibleFunctionTable.hpp new file mode 100644 index 000000000..88e8fb1e9 --- /dev/null +++ b/vendor/metal-cpp/Metal/MTLVisibleFunctionTable.hpp @@ -0,0 +1,104 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/MTLVisibleFunctionTable.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +#include "MTLDefines.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLPrivate.hpp" + +#include + +#include "MTLResource.hpp" +#include "MTLTypes.hpp" + +namespace MTL +{ +class VisibleFunctionTableDescriptor : public NS::Copying +{ +public: + static class VisibleFunctionTableDescriptor* alloc(); + + class VisibleFunctionTableDescriptor* init(); + + static class VisibleFunctionTableDescriptor* visibleFunctionTableDescriptor(); + + NS::UInteger functionCount() const; + void setFunctionCount(NS::UInteger functionCount); +}; + +class VisibleFunctionTable : public NS::Referencing +{ +public: + MTL::ResourceID gpuResourceID() const; + + void setFunction(const class FunctionHandle* function, NS::UInteger index); + + void setFunctions(const class FunctionHandle* const functions[], NS::Range range); +}; + +} + +// static method: alloc +_MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::alloc() +{ + return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLVisibleFunctionTableDescriptor)); +} + +// method: init +_MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::init() +{ + return NS::Object::init(); +} + +// static method: visibleFunctionTableDescriptor +_MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::visibleFunctionTableDescriptor() +{ + return Object::sendMessage(_MTL_PRIVATE_CLS(MTLVisibleFunctionTableDescriptor), _MTL_PRIVATE_SEL(visibleFunctionTableDescriptor)); +} + +// property: functionCount +_MTL_INLINE NS::UInteger MTL::VisibleFunctionTableDescriptor::functionCount() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionCount)); +} + +_MTL_INLINE void MTL::VisibleFunctionTableDescriptor::setFunctionCount(NS::UInteger functionCount) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctionCount_), functionCount); +} + +// property: gpuResourceID +_MTL_INLINE MTL::ResourceID MTL::VisibleFunctionTable::gpuResourceID() const +{ + return Object::sendMessage(this, _MTL_PRIVATE_SEL(gpuResourceID)); +} + +// method: setFunction:atIndex: +_MTL_INLINE void MTL::VisibleFunctionTable::setFunction(const MTL::FunctionHandle* function, NS::UInteger index) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunction_atIndex_), function, index); +} + +// method: setFunctions:withRange: +_MTL_INLINE void MTL::VisibleFunctionTable::setFunctions(const MTL::FunctionHandle* const functions[], NS::Range range) +{ + Object::sendMessage(this, _MTL_PRIVATE_SEL(setFunctions_withRange_), functions, range); +} diff --git a/vendor/metal-cpp/Metal/Metal.hpp b/vendor/metal-cpp/Metal/Metal.hpp new file mode 100644 index 000000000..6ea7adf3a --- /dev/null +++ b/vendor/metal-cpp/Metal/Metal.hpp @@ -0,0 +1,84 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// Metal/Metal.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "MTLAccelerationStructure.hpp" +#include "MTLAccelerationStructureCommandEncoder.hpp" +#include "MTLAccelerationStructureTypes.hpp" +#include "MTLArgument.hpp" +#include "MTLArgumentEncoder.hpp" +#include "MTLBinaryArchive.hpp" +#include "MTLBlitCommandEncoder.hpp" +#include "MTLBlitPass.hpp" +#include "MTLBuffer.hpp" +#include "MTLCaptureManager.hpp" +#include "MTLCaptureScope.hpp" +#include "MTLCommandBuffer.hpp" +#include "MTLCommandEncoder.hpp" +#include "MTLCommandQueue.hpp" +#include "MTLComputeCommandEncoder.hpp" +#include "MTLComputePass.hpp" +#include "MTLComputePipeline.hpp" +#include "MTLCounters.hpp" +#include "MTLDefines.hpp" +#include "MTLDepthStencil.hpp" +#include "MTLDevice.hpp" +#include "MTLDrawable.hpp" +#include "MTLDynamicLibrary.hpp" +#include "MTLEvent.hpp" +#include "MTLFence.hpp" +#include "MTLFunctionConstantValues.hpp" +#include "MTLFunctionDescriptor.hpp" +#include "MTLFunctionHandle.hpp" +#include "MTLFunctionLog.hpp" +#include "MTLFunctionStitching.hpp" +#include "MTLHeaderBridge.hpp" +#include "MTLHeap.hpp" +#include "MTLIndirectCommandBuffer.hpp" +#include "MTLIndirectCommandEncoder.hpp" +#include "MTLIntersectionFunctionTable.hpp" +#include "MTLIOCommandBuffer.hpp" +#include "MTLIOCommandQueue.hpp" +#include "MTLIOCompressor.hpp" +#include "MTLLibrary.hpp" +#include "MTLLinkedFunctions.hpp" +#include "MTLParallelRenderCommandEncoder.hpp" +#include "MTLPipeline.hpp" +#include "MTLPixelFormat.hpp" +#include "MTLPrivate.hpp" +#include "MTLRasterizationRate.hpp" +#include "MTLRenderCommandEncoder.hpp" +#include "MTLRenderPass.hpp" +#include "MTLRenderPipeline.hpp" +#include "MTLResource.hpp" +#include "MTLResourceStateCommandEncoder.hpp" +#include "MTLResourceStatePass.hpp" +#include "MTLSampler.hpp" +#include "MTLStageInputOutputDescriptor.hpp" +#include "MTLTexture.hpp" +#include "MTLTypes.hpp" +#include "MTLVertexDescriptor.hpp" +#include "MTLVisibleFunctionTable.hpp" +#include "MTLVersion.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/QuartzCore/CADefines.hpp b/vendor/metal-cpp/QuartzCore/CADefines.hpp new file mode 100644 index 000000000..83f3d8fc0 --- /dev/null +++ b/vendor/metal-cpp/QuartzCore/CADefines.hpp @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// QuartzCore/CADefines.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "../Foundation/NSDefines.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#define _CA_EXPORT _NS_EXPORT +#define _CA_EXTERN _NS_EXTERN +#define _CA_INLINE _NS_INLINE +#define _CA_PACKED _NS_PACKED + +#define _CA_CONST(type, name) _NS_CONST(type, name) +#define _CA_ENUM(type, name) _NS_ENUM(type, name) +#define _CA_OPTIONS(type, name) _NS_OPTIONS(type, name) + +#define _CA_VALIDATE_SIZE(ns, name) _NS_VALIDATE_SIZE(ns, name) +#define _CA_VALIDATE_ENUM(ns, name) _NS_VALIDATE_ENUM(ns, name) + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/QuartzCore/CAMetalDrawable.hpp b/vendor/metal-cpp/QuartzCore/CAMetalDrawable.hpp new file mode 100644 index 000000000..99a3872a4 --- /dev/null +++ b/vendor/metal-cpp/QuartzCore/CAMetalDrawable.hpp @@ -0,0 +1,57 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// QuartzCore/CAMetalDrawable.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "../Metal/MTLDrawable.hpp" +#include "../Metal/MTLTexture.hpp" + +#include "CADefines.hpp" +#include "CAPrivate.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace CA +{ +class MetalDrawable : public NS::Referencing +{ +public: + class MetalLayer* layer() const; + MTL::Texture* texture() const; +}; +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE CA::MetalLayer* CA::MetalDrawable::layer() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(layer)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE MTL::Texture* CA::MetalDrawable::texture() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(texture)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/QuartzCore/CAMetalLayer.hpp b/vendor/metal-cpp/QuartzCore/CAMetalLayer.hpp new file mode 100644 index 000000000..904e21888 --- /dev/null +++ b/vendor/metal-cpp/QuartzCore/CAMetalLayer.hpp @@ -0,0 +1,131 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// QuartzCore/CAMetalDrawable.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "../Metal/MTLPixelFormat.hpp" +#include "../Metal/MTLTexture.hpp" +#include + +#include "CADefines.hpp" +#include "CAMetalDrawable.hpp" +#include "CAPrivate.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace CA +{ + +class MetalLayer : public NS::Referencing +{ +public: + static class MetalLayer* layer(); + + MTL::Device* device() const; + void setDevice(MTL::Device* device); + + MTL::PixelFormat pixelFormat() const; + void setPixelFormat(MTL::PixelFormat pixelFormat); + + bool framebufferOnly() const; + void setFramebufferOnly(bool framebufferOnly); + + CGSize drawableSize() const; + void setDrawableSize(CGSize drawableSize); + + class MetalDrawable* nextDrawable(); +}; +} // namespace CA + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +_CA_INLINE CA::MetalLayer* CA::MetalLayer::layer() +{ + return Object::sendMessage(_CA_PRIVATE_CLS(CAMetalLayer), _CA_PRIVATE_SEL(layer)); +} +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE MTL::Device* CA::MetalLayer::device() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(device)); +} +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE void CA::MetalLayer::setDevice(MTL::Device* device) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setDevice_), device); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE MTL::PixelFormat CA::MetalLayer::pixelFormat() const +{ + return Object::sendMessage(this, + _CA_PRIVATE_SEL(pixelFormat)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE void CA::MetalLayer::setPixelFormat(MTL::PixelFormat pixelFormat) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setPixelFormat_), + pixelFormat); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE bool CA::MetalLayer::framebufferOnly() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(framebufferOnly)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE void CA::MetalLayer::setFramebufferOnly(bool framebufferOnly) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setFramebufferOnly_), + framebufferOnly); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE CGSize CA::MetalLayer::drawableSize() const +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(drawableSize)); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE void CA::MetalLayer::setDrawableSize(CGSize drawableSize) +{ + return Object::sendMessage(this, _CA_PRIVATE_SEL(setDrawableSize_), + drawableSize); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +_CA_INLINE CA::MetalDrawable* CA::MetalLayer::nextDrawable() +{ + return Object::sendMessage(this, + _CA_PRIVATE_SEL(nextDrawable)); +} diff --git a/vendor/metal-cpp/QuartzCore/CAPrivate.hpp b/vendor/metal-cpp/QuartzCore/CAPrivate.hpp new file mode 100644 index 000000000..701ee0820 --- /dev/null +++ b/vendor/metal-cpp/QuartzCore/CAPrivate.hpp @@ -0,0 +1,132 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// QuartzCore/CAPrivate.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "CADefines.hpp" + +#include + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#define _CA_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol) +#define _CA_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor) + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#if defined(CA_PRIVATE_IMPLEMENTATION) + +#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN +#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("hidden"))) +#else +#define _CA_PRIVATE_VISIBILITY __attribute__((visibility("default"))) +#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN + +#define _CA_PRIVATE_IMPORT __attribute__((weak_import)) + +#ifdef __OBJC__ +#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol)) +#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol)) +#else +#define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol) +#define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol) +#endif // __OBJC__ + +#define _CA_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) +#define _CA_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) +#define _CA_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _CA_PRIVATE_VISIBILITY = sel_registerName(symbol) +#define _CA_PRIVATE_DEF_STR(type, symbol) \ + _CA_EXTERN type const CA##symbol _CA_PRIVATE_IMPORT; \ + type const CA::symbol = (nullptr != &CA##symbol) ? CA##symbol : nullptr + +#else + +#define _CA_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol +#define _CA_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol +#define _CA_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor +#define _CA_PRIVATE_DEF_STR(type, symbol) extern type const CA::symbol + +#endif // CA_PRIVATE_IMPLEMENTATION + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace CA +{ +namespace Private +{ + namespace Class + { + _CA_PRIVATE_DEF_CLS(CAMetalLayer); + } // Class +} // Private +} // CA + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace CA +{ +namespace Private +{ + namespace Protocol + { + + _CA_PRIVATE_DEF_PRO(CAMetalDrawable); + + } // Protocol +} // Private +} // CA + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +namespace CA +{ +namespace Private +{ + namespace Selector + { + _CA_PRIVATE_DEF_SEL(device, + "device"); + _CA_PRIVATE_DEF_SEL(drawableSize, + "drawableSize"); + _CA_PRIVATE_DEF_SEL(framebufferOnly, + "framebufferOnly"); + _CA_PRIVATE_DEF_SEL(layer, + "layer"); + _CA_PRIVATE_DEF_SEL(nextDrawable, + "nextDrawable"); + _CA_PRIVATE_DEF_SEL(pixelFormat, + "pixelFormat"); + _CA_PRIVATE_DEF_SEL(setDevice_, + "setDevice:"); + _CA_PRIVATE_DEF_SEL(setDrawableSize_, + "setDrawableSize:"); + _CA_PRIVATE_DEF_SEL(setFramebufferOnly_, + "setFramebufferOnly:"); + _CA_PRIVATE_DEF_SEL(setPixelFormat_, + "setPixelFormat:"); + _CA_PRIVATE_DEF_SEL(texture, + "texture"); + } // Class +} // Private +} // CA + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/QuartzCore/QuartzCore.hpp b/vendor/metal-cpp/QuartzCore/QuartzCore.hpp new file mode 100644 index 000000000..beb57b615 --- /dev/null +++ b/vendor/metal-cpp/QuartzCore/QuartzCore.hpp @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------------------------------------------------------------------------------------- +// +// QuartzCore/QuartzCore.hpp +// +// Copyright 2020-2023 Apple 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. +// +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#pragma once + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +#include "CAMetalDrawable.hpp" +#include "CAMetalLayer.hpp" + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/vendor/metal-cpp/README.md b/vendor/metal-cpp/README.md new file mode 100644 index 000000000..eb4215c60 --- /dev/null +++ b/vendor/metal-cpp/README.md @@ -0,0 +1,310 @@ +## About + +**metal-cpp** is a low overhead and header only C++ interface for Metal that helps developers add Metal functionality to graphics applications that are written in C++ (such as game engines). **metal-cpp** removes the need to create a shim and allows developers to call Metal functions directly from anywhere in their existing C++ code. + + +## Highlights + +- Drop in C++ alternative interface to the Metal Objective-C headers. +- Direct mapping of all Metal Objective-C classes, constants and enums to C++ in the MTL C++ namespace. +- No measurable overhead compared to calling Metal Objective-C headers, due to inlining of C++ function calls. +- No usage of wrapper containers that require additional allocations. +- Requires C++17 due to the usage of `constexpr` in `NS::Object`. +- Identical header files and function/constant/enum availability for iOS, macOS and tvOS. +- Backwards compatibility: All `bool MTL::Device::supports...()` functions check if their required selectors exist and automatically return `false` if not. +- String (`ErrorDomain`) constants are weak linked and automatically set to `nullptr` if not available. + +## Memory Allocation Policy + +**metal-cpp** follows the object allocation policies of Cocoa, Cocoa Touch, and CoreFoundation. Understanding these rules is especially important when using metal-cpp, as C++ objects are not eligible for automatic reference counting (ARC). + +**metal-cpp** objects are reference counted. To help convey and manage object lifecycles, the following conventions are observed: + +1. *You own any object returned by methods whose name begins with* `alloc` *,* `new` *,* `copy` *,* `mutableCopy` *, or* `Create`. The method returns these objects with `retainCount` equals to `1`. +2. *You can take ownership of an object by calling its* ```retain()``` *method*. A received object is normally guaranteed to remain valid within the method it was received in. You use `retain` in two situations: (1) In the implementation of an accessor method (a setter) or to take ownership of an object; and (2) To prevent an object from being deallocated as a side-effect of some other operation. +3. *When you no longer need it, you must relinquish ownership of an object you own*. You relinquish ownership by calling its `release()` or `autorelease()` method. +4. *You must not relinquish ownership of an object you do not own*. + +When an object's `retainCount` reaches `0`, the object is immediately deallocated. It is illegal to call methods on a deallocated object and it may lead to an application crash. + +### AutoreleasePools and Objects + +Several methods that create temporary objects in **metal-cpp** add them to an `AutoreleasePool` to help manage their lifetimes. In these situations, after **metal-cpp** creates the object, it adds it to an `AutoreleasePool`, which will release its objects when you release (or drain) it. + +By adding temporary objects to an AutoreleasePool, you do not need to explicitly call `release()` to deallocate them. Instead, you can rely on the `AutoreleasePool` to implicitly manage those lifetimes. + +If you create an object with a method that does not begin with `alloc`, `new`, `copy`, `mutableCopy`, or `Create`, the creating method adds the object to an autorelease pool. + +The typical scope of an `AutoreleasePool` is one frame of rendering for the main thread of the program. When the thread returns control to the RunLoop (an object responsible for receiving input and events from the windowing system), the pool is *drained*, releasing its objects. + +You can create and manage additional `AutoreleasePool`s at smaller scopes to reduce your program's working set, and you are required to do so for any additional threads your program creates. + +If an object's lifecycle needs to be extended beyond the scope of an `AutoreleasePool` instance, you can claim ownership of it by calling its `retain()` method before the pool is drained. In these cases, you are responsible for making the appropriate `release()` call on the object after you no longer need it. + +You can find a more-detailed introduction to the memory management rules here: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html, and here: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html + +For more details about the application's RunLoop, please find its documentation here: https://developer.apple.com/documentation/foundation/nsrunloop + +### Use and debug AutoreleasePools + +When you create an autoreleased object and there is no enclosing `AutoreleasePool`, the object is leaked. + +To prevent this, you normally create an `AutoreleasePool` in your program's `main` function, and in the entry function for every thread you create. You may also create additional `AutoreleasePool`s to avoid growing your program's high memory watermark when you create several autoreleased objects, such as when rendering. + +Use the Environment Variable `OBJC_DEBUG_MISSING_POOLS=YES` to print a runtime warning when an autoreleased object is leaked because no enclosing `AutoreleasePool` is available for its thread. + +You can also run `leaks --autoreleasePools` on a memgraph file or a process ID (macOS only) to view a listing of your program's `AutoreleasePool`s and all objects they contain. + +### NS::SharedPtr + +The **metal-cpp** headers include an optional `NS::SharedPtr<>` (shared pointer) template that can help you manually manage memory in your apps. + +Shared pointers in **metal-cpp** are different from `std::shared_ptr<>` in that they implement specific optimizations for its memory model. For example, **metal-cpp**'s shared pointers avoid the overhead of the standard library's version by leveraging the reference counting implementation of the `NS::Object` type. + +#### Note + +The **metal-cpp** shared pointer’s destructor method always calls the `release()` method of the pointer that it wraps. + +You can create an `NS::SharedPtr<>` by calling the metal-cpp's factory method that's appropriate for your application's intent: + +* You can **transfer** ownership of a pointer to a new shared pointer instance by calling the `NS::TransferPtr()` factory function, which is the correct function for Resource Acquisition is Initialization (RAII) implementations because it doesn't increase the pointee's retain count. + +* You can **share** ownership of a pointer with another entity by calling the `NS::RetainPtr()` factory function. This function can also extend an object's lifecycle beyond an `AutoreleasePool` instance's scope because it creates a strong reference to the pointee and increases its retain count. + +Usage of `NS::SharedPtr<>` is optional. + +### nullptr + +Similar to Objective-C, it is legal to call any method, including `retain()` and `release()`, on `nullptr` "objects". While calling methods on `nullptr` still does incur in function call overhead, the effective result is equivalent of a NOP. + +Conversely, do not assume that because calling a method on a pointer did not result in a crash, that the pointed-to object is valid. + +## Adding metal-cpp to a Project + +Simply include `Metal/Metal.hpp`. To ensure that the selector and class symbols are linked, add to one of your cpp files: + +```cpp +#define NS_PRIVATE_IMPLEMENTATION +#define MTL_PRIVATE_IMPLEMENTATION + +#include "Metal/Metal.hpp" +``` + +If you want to use the QuartzCore wrapper, add: + +```cpp +#define CA_PRIVATE_IMPLEMENTATION + +#include "QuartzCore/QuartzCore.hpp" +``` + +## Generating a Single Header File + +Purely optional: You can generate a single header file that contains all **metal-cpp** headers via: + +```shell +./SingleHeader/MakeSingleHeader.py Foundation/Foundation.hpp QuartzCore/QuartzCore.hpp Metal/Metal.hpp +``` + +By default the generator script writes its output to `./SingleHeader/Metal.hpp`. Use the `-o` option to customize output filename. + +## Global Symbol Visibility + +metal-cpp marks all its symbols with `default` visibility. Define the macro: `METALCPP_SYMBOL_VISIBILITY_HIDDEN` to override this behavior and hide its symbols. + +## Examples + +#### Creating the device + +###### Objective-C (with automatic reference counting) + +```objc +id< MTLDevice > device = MTLCreateSystemDefaultDevice(); + +// ... +``` + +###### Objective-C + +```objc +id< MTLDevice > device = MTLCreateSystemDefaultDevice(); + +// ... + +[device release]; +``` + +###### C++ + +```cpp +MTL::Device* pDevice = MTL::CreateSystemDefaultDevice(); + +// ... + +pDevice->release(); +``` + +###### C++ (using NS::SharedPtr) + +```cpp +NS::SharedPtr< MTL::Device > pDevice = NS::TransferPtr( MTL::CreateSystemDefaultDevice() ); + +// ... +``` + +#### Metal function calls map directly to C++ + +###### Objective-C (with automatic reference counting) + +```objc +MTLSamplerDescriptor* samplerDescriptor = [[MTLSamplerDescriptor alloc] init]; + +[samplerDescriptor setSAddressMode: MTLSamplerAddressModeRepeat]; +[samplerDescriptor setTAddressMode: MTLSamplerAddressModeRepeat]; +[samplerDescriptor setRAddressMode: MTLSamplerAddressModeRepeat]; +[samplerDescriptor setMagFilter: MTLSamplerMinMagFilterLinear]; +[samplerDescriptor setMinFilter: MTLSamplerMinMagFilterLinear]; +[samplerDescriptor setMipFilter: MTLSamplerMipFilterLinear]; +[samplerDescriptor setSupportArgumentBuffers: YES]; + +id< MTLSamplerState > samplerState = [device newSamplerStateWithDescriptor:samplerDescriptor]; +``` + +###### Objective-C + +```objc +MTLSamplerDescriptor* samplerDescriptor = [[MTLSamplerDescriptor alloc] init]; + +[samplerDescriptor setSAddressMode: MTLSamplerAddressModeRepeat]; +[samplerDescriptor setTAddressMode: MTLSamplerAddressModeRepeat]; +[samplerDescriptor setRAddressMode: MTLSamplerAddressModeRepeat]; +[samplerDescriptor setMagFilter: MTLSamplerMinMagFilterLinear]; +[samplerDescriptor setMinFilter: MTLSamplerMinMagFilterLinear]; +[samplerDescriptor setMipFilter: MTLSamplerMipFilterLinear]; +[samplerDescriptor setSupportArgumentBuffers: YES]; + +id< MTLSamplerState > samplerState = [device newSamplerStateWithDescriptor:samplerDescriptor]; + +[samplerDescriptor release]; + +// ... + +[samplerState release]; +``` + +###### C++ + +```cpp +MTL::SamplerDescriptor* pSamplerDescriptor = MTL::SamplerDescriptor::alloc()->init(); + +pSamplerDescriptor->setSAddressMode( MTL::SamplerAddressModeRepeat ); +pSamplerDescriptor->setTAddressMode( MTL::SamplerAddressModeRepeat ); +pSamplerDescriptor->setRAddressMode( MTL::SamplerAddressModeRepeat ); +pSamplerDescriptor->setMagFilter( MTL::SamplerMinMagFilterLinear ); +pSamplerDescriptor->setMinFilter( MTL::SamplerMinMagFilterLinear ); +pSamplerDescriptor->setMipFilter( MTL::SamplerMipFilterLinear ); +pSamplerDescriptor->setSupportArgumentBuffers( true ); + +MTL::SamplerState* pSamplerState = pDevice->newSamplerState( pSamplerDescriptor ); + +pSamplerDescriptor->release(); + +// ... + +pSamplerState->release(); +``` + +###### C++ (using NS::SharedPtr) + +```cpp +NS::SharedPtr< MTL::SamplerDescriptor > pSamplerDescriptor = NS::TransferPtr( MTL::SamplerDescriptor::alloc()->init() ); + +pSamplerDescriptor->setSAddressMode( MTL::SamplerAddressModeRepeat ); +pSamplerDescriptor->setTAddressMode( MTL::SamplerAddressModeRepeat ); +pSamplerDescriptor->setRAddressMode( MTL::SamplerAddressModeRepeat ); +pSamplerDescriptor->setMagFilter( MTL::SamplerMinMagFilterLinear ); +pSamplerDescriptor->setMinFilter( MTL::SamplerMinMagFilterLinear ); +pSamplerDescriptor->setMipFilter( MTL::SamplerMipFilterLinear ); +pSamplerDescriptor->setSupportArgumentBuffers( true ); + +NS::SharedPtr< MTL::SamplerState > pSamplerState( pDevice->newSamplerState( pSamplerDescriptor ) ); +``` + +#### A subset of bindings for Foundation classes is provided for seamless integration + +###### Objective-C (with automatic reference counting) + +```objc +NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; +NSString* string = [NSString stringWithCString: "Hello World" encoding: NSASCIIStringEncoding]; + +printf( "string = \"%s\"\n", [string cStringUsingEncoding: NSASCIIStringEncoding] ); +``` + +###### Objective-C + +```objc +NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; +NSString* string = [NSString stringWithCString: "Hello World" encoding: NSASCIIStringEncoding]; + +printf( "string = \"%s\"\n", [string cStringUsingEncoding: NSASCIIStringEncoding] ); + +[pool release]; +``` + +###### C++ + +```cpp +NS::AutoreleasePool* pPool = NS::AutoreleasePool::alloc()->init(); +NS::String* pString = NS::String::string( "Hello World", NS::ASCIIStringEncoding ); + +printf( "pString = \"%s\"\n", pString->cString( NS::ASCIIStringEncoding ) ); + +pPool->release(); +``` + +###### C++ (using NS::SharedPtr) + +```cpp +NS::SharedPtr< NS::AutoreleasePool > pPool = NS::TransferPtr( NS::AutoreleasePool::alloc()->init() ); +NS::String* pString = NS::String::string( "Hello World", NS::ASCIIStringEncoding ); + +printf( "pString = \"%s\"\n", pString->cString( NS::ASCIIStringEncoding ) ); +``` + +#### Containers + +Use the CoreFoundation framework to create `NS::Array` and `NS::Dictionary` instances. + +```cpp +MTL::AccelerationStructureTriangleGeometryDescriptor* pGeoDescriptor = MTL::AccelerationStructureTriangleGeometryDescriptor::alloc()->init(); +CFTypeRef descriptors[] = { ( CFTypeRef )( pGeoDescriptor ) }; +NS::Array* pGeoDescriptors = ( NS::Array* )( CFArrayCreate( kCFAllocatorDefault, descriptors, SIZEOF_ARRAY( descriptors), &kCFTypeArrayCallBacks ) ); + +// ... + +pGeoDescriptors->release(); +``` + +Containers, such as `NS::Array` and `NS::Dictionary`, retain the objects they hold and release them when the container is deallocated. + +#### Accessing the Metal Drawable + +```cpp +#import + +// ... + +CA::MetalLayer* pMetalLayer = /* layer associated with the view */; +CA::MetalDrawable* pMetalDrawable = pMetalLayer->nextDrawable(); + +// ... +``` + +## Changelog + +| Version | Changes | +|-|-| +| macOS 13.3, iOS 16.4 | Add all APIs in macOS 13.3 and iOS 16.4. | +| macOS 13, iOS 16| Add all APIs for macOS 13 and iOS 16.
New optional `NS::SharedPtr` type to assist with memory management.
New convenience function to create a `CA::MetalLayer`.
New `MTLSTR(str)` macro allows faster string creation from literals.
Fix a problem with the signature of functions that take an array of pointers as input.
Fix a problem with the signature of the `setGroups()` function in `MTL::LinkedFunctions`.| +| macOS 12, iOS 15 | Initial release. | \ No newline at end of file diff --git a/vendor/metal-cpp/SingleHeader/MakeSingleHeader.py b/vendor/metal-cpp/SingleHeader/MakeSingleHeader.py new file mode 100755 index 000000000..520cb8898 --- /dev/null +++ b/vendor/metal-cpp/SingleHeader/MakeSingleHeader.py @@ -0,0 +1,271 @@ +#!/usr/bin/env python3 + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- +# +# SingleHeader/MakeSingleHeader.py +# +# Copyright 2020-2023 Apple 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. +# +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +import argparse +import datetime +import logging +import os +import re +import subprocess +import sys + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +class HeaderPrefix( object ): + __template = ( '//\n' + '// {file}\n' + '//\n' + '// {meta_data}\n' + '//\n' + '// Copyright 2020-2023 Apple Inc.\n' + '//\n' + '// Licensed under the Apache License, Version 2.0 (the "License");\n' + '// you may not use this file except in compliance with the License.\n' + '// You may obtain a copy of the License at\n' + '//\n' + '// http://www.apache.org/licenses/LICENSE-2.0\n' + '//\n' + '// Unless required by applicable law or agreed to in writing, software\n' + '// distributed under the License is distributed on an "AS IS" BASIS,\n' + '// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' + '// See the License for the specific language governing permissions and\n' + '// limitations under the License.\n' + '//\n' + '\n' ) + + __template_commit = 'Autogenerated from commit {commit}.' + __template_date = 'Autogenerated on %B %d, %Y.' + + def __init__( self, file ): + self.__file = file + + def __str__( self ): + return self.__template.format( file = self.__file, meta_data = self.__meta_data_string() ) + + def __get_commit_hash( self ): + git_commit_hash = None + + try: + git_dir = os.path.dirname( os.path.realpath( __file__ ) ) + proc = subprocess.Popen( [ 'git', 'rev-parse', 'HEAD' ], cwd = git_dir, stdout = subprocess.PIPE, stderr = subprocess.PIPE ) + git_commit_hash = proc.stdout.read().decode( 'utf-8', 'replace' ).strip() + except: + logging.error( 'Failed to determine git commit hash!' ) + pass + + return git_commit_hash + + def __get_commit_string( self ): + meta_data = None + git_commit_hash = self.__get_commit_hash() + + if git_commit_hash: + meta_data = self.__template_commit.format( commit = git_commit_hash ) + + return meta_data + + def __get_date_string( self ): + today = datetime.date.today() + + return today.strftime( self.__template_date ) + + def __meta_data_string( self ): + meta_data = self.__get_commit_string() + + if not meta_data: + meta_data = self.__get_date_string() + + return meta_data + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +class SingleHeader( object ): + __pragma_once = '#pragma once\n\n' + + def __init__( self ): + self.__header_paths = list() + + def __str__( self ): + return self.process() + + def append( self, header_path ): + self.__header_paths.append( header_path ) + + def process( self ): + out_header = self.__pragma_once + + self.__included_headers = set() + self.__base_path = list() + + for header_path in self.__header_paths: + out_header += self.__process_header( header_path ) + + return self.__strip_empty_lines( out_header ) + + def __read_header( self, path ): + path = os.path.realpath( path ) + + try: + f = open( path, 'r' ) + except: + raise RuntimeError( 'Failed to open file \"' + path + '\" for read!' ) + + return f.read() + + def __strip_pragma_once( self, header ): + return re.sub( '\\s*#pragma once\s*\\/\\/-*\\n', '', header ) + + def __strip_comments( self, header ): + return re.sub( '^//.*\\n', '', header, flags = re.MULTILINE ) + + def __strip_empty_lines( self, header ): + return re.sub( '\\n\\n+', '\\n\\n', header, flags = re.MULTILINE ) + + def __substitute_include_directive( self, match ): + header_path = match.group( 'HEADER_PATH' ) + + logging.info( '\tSubstituting \"' + header_path + '\"...' ) + + return self.__process_header( os.path.join( self.__base_path[-1], header_path ) ) + + def __process_include_directives( self, header ): + return re.sub( '^\\s*#include\\s\\"(?P\\S*)\\"', self.__substitute_include_directive, header, flags = re.MULTILINE ) + + def __process_foundation_directives( self, header ): + if header.find("#include ") != -1: + logging.info( '\tSubstituting ...' ) + return header.replace("#include ", self.__process_header( os.path.join( self.__base_path[-1], "../Foundation/Foundation.hpp" ) ) ) + return header + + + def __process_header( self, header_path ): + out_header = '' + + header_path = os.path.realpath( header_path ) + + if not header_path in self.__included_headers: + logging.info( 'Processing \"' + header_path + '\"...' ) + + self.__base_path.append( os.path.dirname( header_path ) ) + self.__included_headers.add( header_path ) + + out_header = self.__read_header( header_path ) + out_header = self.__strip_pragma_once( out_header ) + out_header = self.__strip_comments( out_header ) + out_header = self.__process_include_directives( out_header ) + out_header = self.__process_foundation_directives( out_header ) + + self.__base_path.pop() + else: + logging.info( '\tSkipping \"' + header_path + '\"...' ) + + return out_header + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +def create_argument_parser(): + parser = argparse.ArgumentParser() + base_path = os.path.dirname( os.path.realpath( __file__ ) ) + output_path = os.path.join( base_path, 'Metal.hpp' ) + + parser.add_argument( '-o', '--output', dest = 'output_path', metavar = 'PATH', default = output_path, help = 'Output path for the single header file.' ) + parser.add_argument( '-v', '--verbose', action = 'store_true', help = 'Show verbose output.' ) + parser.add_argument( dest = 'header_paths', metavar = 'HEADER_FILE', nargs='+', help = 'Input header file.' ) + + return parser + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +def parse_arguments(): + parser = create_argument_parser() + args = parser.parse_args() + + if args.verbose: + logging.getLogger().setLevel( logging.INFO ) + else: + logging.getLogger().setLevel( logging.ERROR ) + + return args + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +def make_header( args ): + prefix = HeaderPrefix( os.path.basename( args.output_path ) ) + header = SingleHeader() + + for header_path in args.header_paths: + header.append( header_path ) + + return str( prefix ) + str( header ) + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +def make_dir( path ): + try: + if not os.path.exists( path ): + os.makedirs( path ) + except os.error: + pass + except: + raise + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +def write_header( args, content ): + path = os.path.realpath( args.output_path ) + + logging.info( 'Writing \"' + path + '\"...' ) + + make_dir( os.path.dirname( path ) ) + + try: + f = open( path, 'w' ) + except: + raise RuntimeError( 'Failed to open file \"' + path + '\" for write!' ) + + f.write( content ) + +#-------------------------------------------------------------------------------------------------------------------------------------------------------------- + +if __name__ == '__main__': + result = -1 + + try: + if sys.getdefaultencoding().lower() == 'ascii': + reload( sys ) + sys.setdefaultencoding( 'utf-8' ) + + args = parse_arguments() + header = make_header( args ) + + write_header( args, header ) + + result = 0 + + except ( KeyboardInterrupt, SystemExit ): + pass + except: + raise + + sys.exit( result ) + +#--------------------------------------------------------------------------------------------------------------------------------------------------------------