From 1fdbcd5ebe0a99a561f318920d71bdc9af999abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furby=E2=84=A2?= Date: Thu, 21 May 2026 13:20:55 -0600 Subject: [PATCH 1/7] Remove custom Apple framework shims in favor of official SDKs * Remove custom bundled Apple, Metal, Foundation, AppKit, and UIKit C++ modules and migrate fully to the official Apple SDKs. * Restore MaterialX and ImGui Metal/Apple integration code closer to their upstream implementations to reduce local divergence and improve maintainability and portability. --- Sources/Apple/Apple.cpp | 42 - .../Apple/include/Foundation/Foundation.hpp | 48 - Sources/Apple/include/Foundation/NSArray.hpp | 115 - .../include/Foundation/NSAutoreleasePool.hpp | 83 - Sources/Apple/include/Foundation/NSBundle.hpp | 374 --- Sources/Apple/include/Foundation/NSData.hpp | 54 - Sources/Apple/include/Foundation/NSDate.hpp | 53 - .../Apple/include/Foundation/NSDefines.hpp | 45 - .../Apple/include/Foundation/NSDictionary.hpp | 128 - .../Apple/include/Foundation/NSEnumerator.hpp | 78 - Sources/Apple/include/Foundation/NSError.hpp | 173 -- .../Apple/include/Foundation/NSInterop.hpp | 258 -- Sources/Apple/include/Foundation/NSLock.hpp | 118 - .../include/Foundation/NSNotification.hpp | 110 - Sources/Apple/include/Foundation/NSNumber.hpp | 501 ---- .../include/Foundation/NSObjCRuntime.hpp | 43 - Sources/Apple/include/Foundation/NSObject.hpp | 302 -- .../Apple/include/Foundation/NSPrivate.hpp | 507 ---- .../include/Foundation/NSProcessInfo.hpp | 354 --- Sources/Apple/include/Foundation/NSRange.hpp | 83 - Sources/Apple/include/Foundation/NSSet.hpp | 87 - .../Apple/include/Foundation/NSSharedPtr.hpp | 311 --- Sources/Apple/include/Foundation/NSString.hpp | 254 -- Sources/Apple/include/Foundation/NSTypes.hpp | 51 - Sources/Apple/include/Foundation/NSURL.hpp | 90 - .../Metal/MTLAccelerationStructure.hpp | 1826 ------------ ...MTLAccelerationStructureCommandEncoder.hpp | 290 -- .../Metal/MTLAccelerationStructureTypes.hpp | 169 -- Sources/Apple/include/Metal/MTLArgument.hpp | 848 ------ .../include/Metal/MTLArgumentEncoder.hpp | 244 -- .../Apple/include/Metal/MTLBinaryArchive.hpp | 139 - .../include/Metal/MTLBlitCommandEncoder.hpp | 246 -- Sources/Apple/include/Metal/MTLBlitPass.hpp | 165 -- Sources/Apple/include/Metal/MTLBuffer.hpp | 109 - .../Apple/include/Metal/MTLCaptureManager.hpp | 220 -- .../Apple/include/Metal/MTLCaptureScope.hpp | 92 - .../Apple/include/Metal/MTLCommandBuffer.hpp | 474 ---- .../Apple/include/Metal/MTLCommandEncoder.hpp | 101 - .../Apple/include/Metal/MTLCommandQueue.hpp | 89 - .../Metal/MTLComputeCommandEncoder.hpp | 362 --- .../Apple/include/Metal/MTLComputePass.hpp | 181 -- .../include/Metal/MTLComputePipeline.hpp | 373 --- Sources/Apple/include/Metal/MTLCounters.hpp | 258 -- Sources/Apple/include/Metal/MTLDefines.hpp | 41 - .../Apple/include/Metal/MTLDepthStencil.hpp | 269 -- Sources/Apple/include/Metal/MTLDevice.hpp | 1444 ---------- Sources/Apple/include/Metal/MTLDrawable.hpp | 99 - .../Apple/include/Metal/MTLDynamicLibrary.hpp | 82 - Sources/Apple/include/Metal/MTLEvent.hpp | 159 -- Sources/Apple/include/Metal/MTLFence.hpp | 57 - .../Metal/MTLFunctionConstantValues.hpp | 85 - .../include/Metal/MTLFunctionDescriptor.hpp | 157 -- .../Apple/include/Metal/MTLFunctionHandle.hpp | 61 - .../Apple/include/Metal/MTLFunctionLog.hpp | 114 - .../include/Metal/MTLFunctionStitching.hpp | 307 --- .../Apple/include/Metal/MTLHeaderBridge.hpp | 2436 ----------------- Sources/Apple/include/Metal/MTLHeap.hpp | 329 --- .../include/Metal/MTLIOCommandBuffer.hpp | 200 -- .../Apple/include/Metal/MTLIOCommandQueue.hpp | 225 -- .../Apple/include/Metal/MTLIOCompressor.hpp | 94 - .../Metal/MTLIndirectCommandBuffer.hpp | 240 -- .../Metal/MTLIndirectCommandEncoder.hpp | 203 -- .../Metal/MTLIntersectionFunctionTable.hpp | 181 -- Sources/Apple/include/Metal/MTLLibrary.hpp | 691 ----- .../include/Metal/MTLLinkedFunctions.hpp | 115 - .../Metal/MTLParallelRenderCommandEncoder.hpp | 94 - Sources/Apple/include/Metal/MTLPipeline.hpp | 109 - .../Apple/include/Metal/MTLPixelFormat.hpp | 173 -- Sources/Apple/include/Metal/MTLPrivate.hpp | 156 -- .../include/Metal/MTLRasterizationRate.hpp | 386 --- .../include/Metal/MTLRenderCommandEncoder.hpp | 1177 -------- Sources/Apple/include/Metal/MTLRenderPass.hpp | 786 ------ .../Apple/include/Metal/MTLRenderPipeline.hpp | 1640 ----------- Sources/Apple/include/Metal/MTLResource.hpp | 178 -- .../Metal/MTLResourceStateCommandEncoder.hpp | 103 - .../include/Metal/MTLResourceStatePass.hpp | 165 -- Sources/Apple/include/Metal/MTLSampler.hpp | 319 --- .../Metal/MTLStageInputOutputDescriptor.hpp | 383 --- Sources/Apple/include/Metal/MTLTexture.hpp | 685 ----- Sources/Apple/include/Metal/MTLTypes.hpp | 168 -- Sources/Apple/include/Metal/MTLVersion.hpp | 32 - .../include/Metal/MTLVertexDescriptor.hpp | 349 --- .../include/Metal/MTLVisibleFunctionTable.hpp | 104 - Sources/Apple/include/Metal/Metal.hpp | 84 - .../Apple/include/MetalFX/MTLFXDefines.hpp | 41 - .../Apple/include/MetalFX/MTLFXPrivate.hpp | 281 -- .../include/MetalFX/MTLFXSpatialScaler.hpp | 372 --- .../include/MetalFX/MTLFXTemporalScaler.hpp | 660 ----- Sources/Apple/include/MetalFX/MetalFX.hpp | 28 - Sources/Apple/include/OpenGL/NSGLContext.hpp | 197 -- Sources/Apple/include/OpenGL/NSGLDefines.hpp | 51 - .../Apple/include/OpenGL/NSGLPixelFormat.hpp | 147 - Sources/Apple/include/OpenGL/NSGLPrivate.hpp | 206 -- Sources/Apple/include/OpenGL/OpenGL.hpp | 40 - .../Apple/include/QuartzCore/CADefines.hpp | 41 - .../include/QuartzCore/CAMetalDrawable.hpp | 57 - .../Apple/include/QuartzCore/CAMetalLayer.hpp | 131 - .../Apple/include/QuartzCore/CAPrivate.hpp | 132 - .../Apple/include/QuartzCore/QuartzCore.hpp | 28 - ...talFramebuffer.cpp => MetalFramebuffer.mm} | 62 +- .../{MetalState.cpp => MetalState.mm} | 82 +- ...tureHandler.cpp => MetalTextureHandler.mm} | 174 +- .../{MslMaterial.cpp => MslMaterial.mm} | 4 +- ...teObject.cpp => MslPipelineStateObject.mm} | 320 +-- .../{MslRenderer.cpp => MslRenderer.mm} | 60 +- .../{TextureBaker.cpp => TextureBaker.mm} | 0 106 files changed, 351 insertions(+), 27891 deletions(-) delete mode 100644 Sources/Apple/Apple.cpp delete mode 100644 Sources/Apple/include/Foundation/Foundation.hpp delete mode 100644 Sources/Apple/include/Foundation/NSArray.hpp delete mode 100644 Sources/Apple/include/Foundation/NSAutoreleasePool.hpp delete mode 100644 Sources/Apple/include/Foundation/NSBundle.hpp delete mode 100644 Sources/Apple/include/Foundation/NSData.hpp delete mode 100644 Sources/Apple/include/Foundation/NSDate.hpp delete mode 100644 Sources/Apple/include/Foundation/NSDefines.hpp delete mode 100644 Sources/Apple/include/Foundation/NSDictionary.hpp delete mode 100644 Sources/Apple/include/Foundation/NSEnumerator.hpp delete mode 100644 Sources/Apple/include/Foundation/NSError.hpp delete mode 100644 Sources/Apple/include/Foundation/NSInterop.hpp delete mode 100644 Sources/Apple/include/Foundation/NSLock.hpp delete mode 100644 Sources/Apple/include/Foundation/NSNotification.hpp delete mode 100644 Sources/Apple/include/Foundation/NSNumber.hpp delete mode 100644 Sources/Apple/include/Foundation/NSObjCRuntime.hpp delete mode 100644 Sources/Apple/include/Foundation/NSObject.hpp delete mode 100644 Sources/Apple/include/Foundation/NSPrivate.hpp delete mode 100644 Sources/Apple/include/Foundation/NSProcessInfo.hpp delete mode 100644 Sources/Apple/include/Foundation/NSRange.hpp delete mode 100644 Sources/Apple/include/Foundation/NSSet.hpp delete mode 100644 Sources/Apple/include/Foundation/NSSharedPtr.hpp delete mode 100644 Sources/Apple/include/Foundation/NSString.hpp delete mode 100644 Sources/Apple/include/Foundation/NSTypes.hpp delete mode 100644 Sources/Apple/include/Foundation/NSURL.hpp delete mode 100644 Sources/Apple/include/Metal/MTLAccelerationStructure.hpp delete mode 100644 Sources/Apple/include/Metal/MTLAccelerationStructureCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLAccelerationStructureTypes.hpp delete mode 100644 Sources/Apple/include/Metal/MTLArgument.hpp delete mode 100644 Sources/Apple/include/Metal/MTLArgumentEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLBinaryArchive.hpp delete mode 100644 Sources/Apple/include/Metal/MTLBlitCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLBlitPass.hpp delete mode 100644 Sources/Apple/include/Metal/MTLBuffer.hpp delete mode 100644 Sources/Apple/include/Metal/MTLCaptureManager.hpp delete mode 100644 Sources/Apple/include/Metal/MTLCaptureScope.hpp delete mode 100644 Sources/Apple/include/Metal/MTLCommandBuffer.hpp delete mode 100644 Sources/Apple/include/Metal/MTLCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLCommandQueue.hpp delete mode 100644 Sources/Apple/include/Metal/MTLComputeCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLComputePass.hpp delete mode 100644 Sources/Apple/include/Metal/MTLComputePipeline.hpp delete mode 100644 Sources/Apple/include/Metal/MTLCounters.hpp delete mode 100644 Sources/Apple/include/Metal/MTLDefines.hpp delete mode 100644 Sources/Apple/include/Metal/MTLDepthStencil.hpp delete mode 100644 Sources/Apple/include/Metal/MTLDevice.hpp delete mode 100644 Sources/Apple/include/Metal/MTLDrawable.hpp delete mode 100644 Sources/Apple/include/Metal/MTLDynamicLibrary.hpp delete mode 100644 Sources/Apple/include/Metal/MTLEvent.hpp delete mode 100644 Sources/Apple/include/Metal/MTLFence.hpp delete mode 100644 Sources/Apple/include/Metal/MTLFunctionConstantValues.hpp delete mode 100644 Sources/Apple/include/Metal/MTLFunctionDescriptor.hpp delete mode 100644 Sources/Apple/include/Metal/MTLFunctionHandle.hpp delete mode 100644 Sources/Apple/include/Metal/MTLFunctionLog.hpp delete mode 100644 Sources/Apple/include/Metal/MTLFunctionStitching.hpp delete mode 100644 Sources/Apple/include/Metal/MTLHeaderBridge.hpp delete mode 100644 Sources/Apple/include/Metal/MTLHeap.hpp delete mode 100644 Sources/Apple/include/Metal/MTLIOCommandBuffer.hpp delete mode 100644 Sources/Apple/include/Metal/MTLIOCommandQueue.hpp delete mode 100644 Sources/Apple/include/Metal/MTLIOCompressor.hpp delete mode 100644 Sources/Apple/include/Metal/MTLIndirectCommandBuffer.hpp delete mode 100644 Sources/Apple/include/Metal/MTLIndirectCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLIntersectionFunctionTable.hpp delete mode 100644 Sources/Apple/include/Metal/MTLLibrary.hpp delete mode 100644 Sources/Apple/include/Metal/MTLLinkedFunctions.hpp delete mode 100644 Sources/Apple/include/Metal/MTLParallelRenderCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLPipeline.hpp delete mode 100644 Sources/Apple/include/Metal/MTLPixelFormat.hpp delete mode 100644 Sources/Apple/include/Metal/MTLPrivate.hpp delete mode 100644 Sources/Apple/include/Metal/MTLRasterizationRate.hpp delete mode 100644 Sources/Apple/include/Metal/MTLRenderCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLRenderPass.hpp delete mode 100644 Sources/Apple/include/Metal/MTLRenderPipeline.hpp delete mode 100644 Sources/Apple/include/Metal/MTLResource.hpp delete mode 100644 Sources/Apple/include/Metal/MTLResourceStateCommandEncoder.hpp delete mode 100644 Sources/Apple/include/Metal/MTLResourceStatePass.hpp delete mode 100644 Sources/Apple/include/Metal/MTLSampler.hpp delete mode 100644 Sources/Apple/include/Metal/MTLStageInputOutputDescriptor.hpp delete mode 100644 Sources/Apple/include/Metal/MTLTexture.hpp delete mode 100644 Sources/Apple/include/Metal/MTLTypes.hpp delete mode 100644 Sources/Apple/include/Metal/MTLVersion.hpp delete mode 100644 Sources/Apple/include/Metal/MTLVertexDescriptor.hpp delete mode 100644 Sources/Apple/include/Metal/MTLVisibleFunctionTable.hpp delete mode 100644 Sources/Apple/include/Metal/Metal.hpp delete mode 100644 Sources/Apple/include/MetalFX/MTLFXDefines.hpp delete mode 100644 Sources/Apple/include/MetalFX/MTLFXPrivate.hpp delete mode 100644 Sources/Apple/include/MetalFX/MTLFXSpatialScaler.hpp delete mode 100644 Sources/Apple/include/MetalFX/MTLFXTemporalScaler.hpp delete mode 100644 Sources/Apple/include/MetalFX/MetalFX.hpp delete mode 100644 Sources/Apple/include/OpenGL/NSGLContext.hpp delete mode 100644 Sources/Apple/include/OpenGL/NSGLDefines.hpp delete mode 100644 Sources/Apple/include/OpenGL/NSGLPixelFormat.hpp delete mode 100644 Sources/Apple/include/OpenGL/NSGLPrivate.hpp delete mode 100644 Sources/Apple/include/OpenGL/OpenGL.hpp delete mode 100644 Sources/Apple/include/QuartzCore/CADefines.hpp delete mode 100644 Sources/Apple/include/QuartzCore/CAMetalDrawable.hpp delete mode 100644 Sources/Apple/include/QuartzCore/CAMetalLayer.hpp delete mode 100644 Sources/Apple/include/QuartzCore/CAPrivate.hpp delete mode 100644 Sources/Apple/include/QuartzCore/QuartzCore.hpp rename Sources/MaterialX/source/MaterialXRenderMsl/{MetalFramebuffer.cpp => MetalFramebuffer.mm} (65%) rename Sources/MaterialX/source/MaterialXRenderMsl/{MetalState.cpp => MetalState.mm} (78%) rename Sources/MaterialX/source/MaterialXRenderMsl/{MetalTextureHandler.cpp => MetalTextureHandler.mm} (70%) rename Sources/MaterialX/source/MaterialXRenderMsl/{MslMaterial.cpp => MslMaterial.mm} (98%) rename Sources/MaterialX/source/MaterialXRenderMsl/{MslPipelineStateObject.cpp => MslPipelineStateObject.mm} (86%) rename Sources/MaterialX/source/MaterialXRenderMsl/{MslRenderer.cpp => MslRenderer.mm} (77%) rename Sources/MaterialX/source/MaterialXRenderMsl/{TextureBaker.cpp => TextureBaker.mm} (100%) diff --git a/Sources/Apple/Apple.cpp b/Sources/Apple/Apple.cpp deleted file mode 100644 index 97760498..00000000 --- a/Sources/Apple/Apple.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* ---------------------------------------------------------------- - * :: : M E T A V E R S E : :: - * ---------------------------------------------------------------- - * This software is Licensed under the terms of the Apache License, - * version 2.0 (the "Apache License") with the following additional - * modification; you may not use this file except within compliance - * of the Apache License and the following modification made to it. - * Section 6. Trademarks. is deleted and replaced with: - * - * Trademarks. This License does not grant permission to use any of - * its trade names, trademarks, service marks, or the product names - * of this Licensor or its affiliates, except as required to comply - * with Section 4(c.) of this License, and to reproduce the content - * of the NOTICE file. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an - * implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the Apache License for more details. - * - * You should have received a copy for this software license of the - * Apache License along with this program; or, if not, please write - * to the Free Software Foundation Inc., with the following address - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) 2024 Wabi Foundation. All Rights Reserved. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ---------------------------------------------------------------- */ - -/* generates the cxx implementation for apple cxx headers. */ -#define NS_PRIVATE_IMPLEMENTATION -#define CA_PRIVATE_IMPLEMENTATION -#define MTL_PRIVATE_IMPLEMENTATION -#define MTLFX_PRIVATE_IMPLEMENTATION -#define NSGL_PRIVATE_IMPLEMENTATION - -#include -#include -#include -#include -#include diff --git a/Sources/Apple/include/Foundation/Foundation.hpp b/Sources/Apple/include/Foundation/Foundation.hpp deleted file mode 100644 index 37e4d5dd..00000000 --- a/Sources/Apple/include/Foundation/Foundation.hpp +++ /dev/null @@ -1,48 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 "NSInterop.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/Sources/Apple/include/Foundation/NSArray.hpp b/Sources/Apple/include/Foundation/NSArray.hpp deleted file mode 100644 index 7ccdb804..00000000 --- a/Sources/Apple/include/Foundation/NSArray.hpp +++ /dev/null @@ -1,115 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSAutoreleasePool.hpp b/Sources/Apple/include/Foundation/NSAutoreleasePool.hpp deleted file mode 100644 index 3008590d..00000000 --- a/Sources/Apple/include/Foundation/NSAutoreleasePool.hpp +++ /dev/null @@ -1,83 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSBundle.hpp b/Sources/Apple/include/Foundation/NSBundle.hpp deleted file mode 100644 index 323d93f3..00000000 --- a/Sources/Apple/include/Foundation/NSBundle.hpp +++ /dev/null @@ -1,374 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSData.hpp b/Sources/Apple/include/Foundation/NSData.hpp deleted file mode 100644 index ddfa6dd0..00000000 --- a/Sources/Apple/include/Foundation/NSData.hpp +++ /dev/null @@ -1,54 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSDate.hpp b/Sources/Apple/include/Foundation/NSDate.hpp deleted file mode 100644 index 61f10a95..00000000 --- a/Sources/Apple/include/Foundation/NSDate.hpp +++ /dev/null @@ -1,53 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSDefines.hpp b/Sources/Apple/include/Foundation/NSDefines.hpp deleted file mode 100644 index a042be63..00000000 --- a/Sources/Apple/include/Foundation/NSDefines.hpp +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSDictionary.hpp b/Sources/Apple/include/Foundation/NSDictionary.hpp deleted file mode 100644 index 078cd5c8..00000000 --- a/Sources/Apple/include/Foundation/NSDictionary.hpp +++ /dev/null @@ -1,128 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSEnumerator.hpp b/Sources/Apple/include/Foundation/NSEnumerator.hpp deleted file mode 100644 index eed19dba..00000000 --- a/Sources/Apple/include/Foundation/NSEnumerator.hpp +++ /dev/null @@ -1,78 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSError.hpp b/Sources/Apple/include/Foundation/NSError.hpp deleted file mode 100644 index f19ff861..00000000 --- a/Sources/Apple/include/Foundation/NSError.hpp +++ /dev/null @@ -1,173 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSInterop.hpp b/Sources/Apple/include/Foundation/NSInterop.hpp deleted file mode 100644 index 71d2d162..00000000 --- a/Sources/Apple/include/Foundation/NSInterop.hpp +++ /dev/null @@ -1,258 +0,0 @@ -/* ---------------------------------------------------------------- - * :: : M E T A V E R S E : :: - * ---------------------------------------------------------------- - * This software is Licensed under the terms of the Apache License, - * version 2.0 (the "Apache License") with the following additional - * modification; you may not use this file except within compliance - * of the Apache License and the following modification made to it. - * Section 6. Trademarks. is deleted and replaced with: - * - * Trademarks. This License does not grant permission to use any of - * its trade names, trademarks, service marks, or the product names - * of this Licensor or its affiliates, except as required to comply - * with Section 4(c.) of this License, and to reproduce the content - * of the NOTICE file. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an - * implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the Apache License for more details. - * - * You should have received a copy for this software license of the - * Apache License along with this program; or, if not, please write - * to the Free Software Foundation Inc., with the following address - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) 2024 Wabi Foundation. All Rights Reserved. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ---------------------------------------------------------------- - * Portions of this file derive from an original work of Apple Inc. - * from the swift/bridging file. - * - * This source file is apart of the Swift.org open source project & - * under the terms of the Apache License version 2.0 with a Runtime - * Library Exception modification. - * - * See more license information here: https://swift.org/LICENSE.txt - * - * See the list of Swift project authors by visiting this resource: - * https://swift.org/CONTRIBUTORS.txt - * - * Copyright (C) 2017 Apple Inc. and the Swift project authors. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ----------------------------------------------------------------- */ - -#pragma once - -/* ----------------------------------------------------------------- */ - -/** - * @brief - * This file provides common utilities and annotations that are - * useful for C++ codebases that interoperate with Swift. - */ - -/* ----------------------------------------------------------------- */ - -#ifdef __APPLE__ -# if __has_include() -# include -# endif /* __has_include() */ -#endif /* __APPLE__ */ - -/** ---------- - * - * Carefully define the swift cxx interop macros, by first checking - * if they have already been defined by the Swift compiler, if not, - * then we define them ourselves. - * ---------- */ - -#if defined(__has_attribute) && !defined(_CXX_INTEROP_HAS_ATTRIBUTE) -#define _CXX_INTEROP_HAS_ATTRIBUTE(x) __has_attribute(x) -#elif !defined(_CXX_INTEROP_HAS_ATTRIBUTE) -#define _CXX_INTEROP_HAS_ATTRIBUTE(x) 0 -#endif - -#if _CXX_INTEROP_HAS_ATTRIBUTE(swift_attr) - -#if !defined(SWIFT_SELF_CONTAINED) -/// Specifies that a C++ `class` or `struct` owns and controls the lifetime of all -/// of the objects it references. Such type should not reference any objects whose -/// lifetime is controlled externally. This annotation allows Swift to import methods -/// that return a `class` or `struct` type that is annotated with this macro. -#define SWIFT_SELF_CONTAINED __attribute__((swift_attr("import_owned"))) -#endif /* SWIFT_SELF_CONTAINED */ - -#if !defined(SWIFT_RETURNS_INDEPENDENT_VALUE) -/// Specifies that a C++ method returns a value that is presumed to contain -/// objects whose lifetime is not dependent on `this` or other parameters passed -/// to the method. -#define SWIFT_RETURNS_INDEPENDENT_VALUE __attribute__((swift_attr("import_unsafe"))) -#endif /* SWIFT_RETURNS_INDEPENDENT_VALUE */ - -#if !defined(_CXX_INTEROP_STRINGIFY) -#define _CXX_INTEROP_STRINGIFY(_x) #_x -#endif /* _CXX_INTEROP_STRINGIFY */ - -#if !defined(SWIFT_SHARED_REFERENCE) -/// Specifies that a C++ `class` or `struct` is reference-counted using -/// the given `retain` and `release` functions. This annotation lets Swift import -/// such a type as reference counted type in Swift, taking advantage of Swift's -/// automatic reference counting. -/// -/// This example shows how to use this macro to let Swift know that -/// a non-copyable reference counted C++ class can be imported as a reference counted type in Swift: -/// ```c++ -/// class SWIFT_SHARED_REFERENCE(retainSharedObject, releaseSharedObject) -/// SharedObject : NonCopyable, IntrusiveReferenceCounted { -/// public: -/// static SharedObject* create(); -/// void doSomething(); -/// }; -/// -/// void retainSharedObject(SharedObject *); -/// void releaseSharedObject(SharedObject *); -/// ``` -/// -/// Then, the Swift programmer would be able to use it in the following manner: -/// -/// ```swift -/// let object = SharedObject.create() -/// object.doSomething() -/// // The Swift compiler will release object here. -/// ``` -#define SWIFT_SHARED_REFERENCE(_retain, _release) \ - __attribute__((swift_attr("import_reference"))) \ - __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:_retain)))) \ - __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:_release)))) -#endif /* SWIFT_SHARED_REFERENCE */ - -#if !defined(SWIFT_IMMORTAL_REFERENCE) -/// Specifies that a C++ `class` or `struct` is a reference type whose lifetime -/// is presumed to be immortal, i.e. the reference to such object is presumed to -/// always be valid. This annotation lets Swift import such a type as a reference -/// type in Swift. -//// -/// This example shows how to use this macro to let Swift know that -/// a non-copyable singleton C++ class can be imported as a reference type in Swift: -/// ```c++ -/// class SWIFT_IMMORTAL_REFERENCE -/// LoggerSingleton : NonCopyable { -/// public: -/// static LoggerSingleton &getInstance(); -/// void log(int x); -/// }; -/// ``` -/// -/// Then, the Swift programmer would be able to use it in the following manner: -/// -/// ```swift -/// let logger = LoggerSingleton.getInstance() -/// logger.log(123) -/// ``` -#define SWIFT_IMMORTAL_REFERENCE \ - __attribute__((swift_attr("import_reference"))) \ - __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:immortal)))) \ - __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:immortal)))) -#endif /* SWIFT_IMMORTAL_REFERENCE */ - -#if !defined(SWIFT_UNSAFE_REFERENCE) -/// Specifies that a C++ `class` or `struct` is a reference type whose lifetime -/// is not managed automatically. The programmer must validate that any reference -/// to such object is valid themselves. This annotation lets Swift import such a type as a reference type in Swift. -#define SWIFT_UNSAFE_REFERENCE \ - __attribute__((swift_attr("import_reference"))) \ - __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:immortal)))) \ - __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:immortal)))) -#endif /* SWIFT_UNSAFE_REFERENCE */ - -#if !defined(SWIFT_NAME) -/// Specifies a name that will be used in Swift for this declaration instead of its original name. -#define SWIFT_NAME(_name) __attribute__((swift_name(#_name))) -#endif /* SWIFT_NAME */ - -#if !defined(SWIFT_CONFORMS_TO_PROTOCOL) -/// Specifies that a specific C++ `class` or `struct` conforms to a -/// a specific Swift protocol. -/// -/// This example shows how to use this macro to conform a class template to a Swift protocol: -/// ``` -/// template -/// class SWIFT_CONFORMS_TO_PROTOCOL(SwiftModule.ProtocolName) -/// CustomClass {}; -/// ``` -#define SWIFT_CONFORMS_TO_PROTOCOL(_moduleName_protocolName) \ - __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(conforms_to:_moduleName_protocolName)))) -#endif /* SWIFT_CONFORMS_TO_PROTOCOL */ - -#if !defined(SWIFT_COMPUTED_PROPERTY) -/// Specifies that a specific C++ method should be imported as a computed -/// property. If this macro is specified on a getter, a getter will be -/// synthesized. If this macro is specified on a setter, both a getter and -/// setter will be synthesized. -/// -/// For example: -/// ``` -/// int getX() SWIFT_COMPUTED_PROPERTY; -/// ``` -/// Will be imported as `var x: CInt {...}`. -#define SWIFT_COMPUTED_PROPERTY \ - __attribute__((swift_attr("import_computed_property"))) -#endif /* SWIFT_COMPUTED_PROPERTY */ - -#if !defined(SWIFT_MUTATING) -/// Specifies that a specific **constant** C++ member function should be imported as -/// `mutating` Swift method. This annotation should be added to constant C++ member functions -/// that mutate `mutable` fields in a C++ object, to let Swift know that this function is still mutating -/// and thus that it should become a `mutating` method in Swift. -#define SWIFT_MUTATING \ - __attribute__((swift_attr("mutating"))) -#endif /* SWIFT_MUTATING */ - -#else /* !_CXX_INTEROP_HAS_ATTRIBUTE */ - -// Empty defines for compilers that don't support `attribute(swift_attr)`. - -#if !defined(SWIFT_SELF_CONTAINED) -#define SWIFT_SELF_CONTAINED -#endif // SWIFT_SELF_CONTAINED - -#if !defined(SWIFT_RETURNS_INDEPENDENT_VALUE) -#define SWIFT_RETURNS_INDEPENDENT_VALUE -#endif // SWIFT_RETURNS_INDEPENDENT_VALUE - -#if !defined(SWIFT_SHARED_REFERENCE) -#define SWIFT_SHARED_REFERENCE(_retain, _release) -#endif // SWIFT_SHARED_REFERENCE - -#if !defined(SWIFT_IMMORTAL_REFERENCE) -#define SWIFT_IMMORTAL_REFERENCE -#endif // SWIFT_IMMORTAL_REFERENCE - -#if !defined(SWIFT_UNSAFE_REFERENCE) -#define SWIFT_UNSAFE_REFERENCE -#endif // SWIFT_UNSAFE_REFERENCE - -#if !defined(SWIFT_NAME) -#define SWIFT_NAME(_name) -#endif // SWIFT_NAME - -#if !defined(SWIFT_CONFORMS_TO_PROTOCOL) -#define SWIFT_CONFORMS_TO_PROTOCOL(_moduleName_protocolName) -#endif // SWIFT_CONFORMS_TO_PROTOCOL - -#if !defined(SWIFT_COMPUTED_PROPERTY) -#define SWIFT_COMPUTED_PROPERTY -#endif // SWIFT_COMPUTED_PROPERTY - -#if !defined(SWIFT_MUTATING) -#define SWIFT_MUTATING -#endif // SWIFT_MUTATING - -#endif /* !_CXX_INTEROP_HAS_ATTRIBUTE */ - -#if defined(_CXX_INTEROP_HAS_ATTRIBUTE) -#undef _CXX_INTEROP_HAS_ATTRIBUTE -#endif /* _CXX_INTEROP_HAS_ATTRIBUTE */ diff --git a/Sources/Apple/include/Foundation/NSLock.hpp b/Sources/Apple/include/Foundation/NSLock.hpp deleted file mode 100644 index ca371fba..00000000 --- a/Sources/Apple/include/Foundation/NSLock.hpp +++ /dev/null @@ -1,118 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSNotification.hpp b/Sources/Apple/include/Foundation/NSNotification.hpp deleted file mode 100644 index 49cf2d4a..00000000 --- a/Sources/Apple/include/Foundation/NSNotification.hpp +++ /dev/null @@ -1,110 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSNumber.hpp b/Sources/Apple/include/Foundation/NSNumber.hpp deleted file mode 100644 index 13c78024..00000000 --- a/Sources/Apple/include/Foundation/NSNumber.hpp +++ /dev/null @@ -1,501 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSObjCRuntime.hpp b/Sources/Apple/include/Foundation/NSObjCRuntime.hpp deleted file mode 100644 index a3860e94..00000000 --- a/Sources/Apple/include/Foundation/NSObjCRuntime.hpp +++ /dev/null @@ -1,43 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSObject.hpp b/Sources/Apple/include/Foundation/NSObject.hpp deleted file mode 100644 index 957071bc..00000000 --- a/Sources/Apple/include/Foundation/NSObject.hpp +++ /dev/null @@ -1,302 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSPrivate.hpp b/Sources/Apple/include/Foundation/NSPrivate.hpp deleted file mode 100644 index af5ffb14..00000000 --- a/Sources/Apple/include/Foundation/NSPrivate.hpp +++ /dev/null @@ -1,507 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSProcessInfo.hpp b/Sources/Apple/include/Foundation/NSProcessInfo.hpp deleted file mode 100644 index 565b5993..00000000 --- a/Sources/Apple/include/Foundation/NSProcessInfo.hpp +++ /dev/null @@ -1,354 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSRange.hpp b/Sources/Apple/include/Foundation/NSRange.hpp deleted file mode 100644 index 2c5beb5b..00000000 --- a/Sources/Apple/include/Foundation/NSRange.hpp +++ /dev/null @@ -1,83 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSSet.hpp b/Sources/Apple/include/Foundation/NSSet.hpp deleted file mode 100644 index a4eb0d64..00000000 --- a/Sources/Apple/include/Foundation/NSSet.hpp +++ /dev/null @@ -1,87 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSSharedPtr.hpp b/Sources/Apple/include/Foundation/NSSharedPtr.hpp deleted file mode 100644 index 09e8855e..00000000 --- a/Sources/Apple/include/Foundation/NSSharedPtr.hpp +++ /dev/null @@ -1,311 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSString.hpp b/Sources/Apple/include/Foundation/NSString.hpp deleted file mode 100644 index 07692239..00000000 --- a/Sources/Apple/include/Foundation/NSString.hpp +++ /dev/null @@ -1,254 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 "NSInterop.hpp" -#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; - } SWIFT_IMMORTAL_REFERENCE; - -/// 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/Sources/Apple/include/Foundation/NSTypes.hpp b/Sources/Apple/include/Foundation/NSTypes.hpp deleted file mode 100644 index 5f098f67..00000000 --- a/Sources/Apple/include/Foundation/NSTypes.hpp +++ /dev/null @@ -1,51 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Foundation/NSURL.hpp b/Sources/Apple/include/Foundation/NSURL.hpp deleted file mode 100644 index a7bc3e6e..00000000 --- a/Sources/Apple/include/Foundation/NSURL.hpp +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLAccelerationStructure.hpp b/Sources/Apple/include/Metal/MTLAccelerationStructure.hpp deleted file mode 100644 index cb30db71..00000000 --- a/Sources/Apple/include/Metal/MTLAccelerationStructure.hpp +++ /dev/null @@ -1,1826 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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(); -}; - -_MTL_ENUM(NS::Integer, CurveType) { - CurveTypeRound = 0, - CurveTypeFlat = 1, -}; - -_MTL_ENUM(NS::Integer, CurveBasis) { - CurveBasisBSpline = 0, - CurveBasisCatmullRom = 1, - CurveBasisLinear = 2, - CurveBasisBezier = 3, -}; - -_MTL_ENUM(NS::Integer, CurveEndCaps) { - CurveEndCapsNone = 0, - CurveEndCapsDisk = 1, - CurveEndCapsSphere = 2, -}; - -class AccelerationStructureCurveGeometryDescriptor : public NS::Copying -{ -public: - static class AccelerationStructureCurveGeometryDescriptor* alloc(); - - class AccelerationStructureCurveGeometryDescriptor* init(); - - class Buffer* controlPointBuffer() const; - void setControlPointBuffer(const class Buffer* controlPointBuffer); - - NS::UInteger controlPointBufferOffset() const; - void setControlPointBufferOffset(NS::UInteger controlPointBufferOffset); - - NS::UInteger controlPointCount() const; - void setControlPointCount(NS::UInteger controlPointCount); - - NS::UInteger controlPointStride() const; - void setControlPointStride(NS::UInteger controlPointStride); - - MTL::AttributeFormat controlPointFormat() const; - void setControlPointFormat(MTL::AttributeFormat controlPointFormat); - - class Buffer* radiusBuffer() const; - void setRadiusBuffer(const class Buffer* radiusBuffer); - - NS::UInteger radiusBufferOffset() const; - void setRadiusBufferOffset(NS::UInteger radiusBufferOffset); - - MTL::AttributeFormat radiusFormat() const; - void setRadiusFormat(MTL::AttributeFormat radiusFormat); - - NS::UInteger radiusStride() const; - void setRadiusStride(NS::UInteger radiusStride); - - 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 segmentCount() const; - void setSegmentCount(NS::UInteger segmentCount); - - NS::UInteger segmentControlPointCount() const; - void setSegmentControlPointCount(NS::UInteger segmentControlPointCount); - - MTL::CurveType curveType() const; - void setCurveType(MTL::CurveType curveType); - - MTL::CurveBasis curveBasis() const; - void setCurveBasis(MTL::CurveBasis curveBasis); - - MTL::CurveEndCaps curveEndCaps() const; - void setCurveEndCaps(MTL::CurveEndCaps curveEndCaps); - - static MTL::AccelerationStructureCurveGeometryDescriptor* descriptor(); -}; - -class AccelerationStructureMotionCurveGeometryDescriptor : public NS::Copying -{ -public: - static class AccelerationStructureMotionCurveGeometryDescriptor* alloc(); - - class AccelerationStructureMotionCurveGeometryDescriptor* init(); - - NS::Array* controlPointBuffers() const; - void setControlPointBuffers(const NS::Array* controlPointBuffers); - - NS::UInteger controlPointCount() const; - void setControlPointCount(NS::UInteger controlPointCount); - - NS::UInteger controlPointStride() const; - void setControlPointStride(NS::UInteger controlPointStride); - - MTL::AttributeFormat controlPointFormat() const; - void setControlPointFormat(MTL::AttributeFormat controlPointFormat); - - NS::Array* radiusBuffers() const; - void setRadiusBuffers(const NS::Array* radiusBuffers); - - MTL::AttributeFormat radiusFormat() const; - void setRadiusFormat(MTL::AttributeFormat radiusFormat); - - NS::UInteger radiusStride() const; - void setRadiusStride(NS::UInteger radiusStride); - - 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 segmentCount() const; - void setSegmentCount(NS::UInteger segmentCount); - - NS::UInteger segmentControlPointCount() const; - void setSegmentControlPointCount(NS::UInteger segmentControlPointCount); - - MTL::CurveType curveType() const; - void setCurveType(MTL::CurveType curveType); - - MTL::CurveBasis curveBasis() const; - void setCurveBasis(MTL::CurveBasis curveBasis); - - MTL::CurveEndCaps curveEndCaps() const; - void setCurveEndCaps(MTL::CurveEndCaps curveEndCaps); - - static MTL::AccelerationStructureMotionCurveGeometryDescriptor* 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, - AccelerationStructureInstanceDescriptorTypeIndirect = 3, - AccelerationStructureInstanceDescriptorTypeIndirectMotion = 4, -}; - -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; - -struct IndirectAccelerationStructureInstanceDescriptor -{ - MTL::PackedFloat4x3 transformationMatrix; - MTL::AccelerationStructureInstanceOptions options; - uint32_t mask; - uint32_t intersectionFunctionTableOffset; - uint32_t userID; - MTL::ResourceID accelerationStructureID; -} _MTL_PACKED; - -struct IndirectAccelerationStructureMotionInstanceDescriptor -{ - MTL::AccelerationStructureInstanceOptions options; - uint32_t mask; - uint32_t intersectionFunctionTableOffset; - uint32_t userID; - MTL::ResourceID accelerationStructureID; - 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 IndirectInstanceAccelerationStructureDescriptor : public NS::Copying -{ -public: - static class IndirectInstanceAccelerationStructureDescriptor* alloc(); - - class IndirectInstanceAccelerationStructureDescriptor* 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 maxInstanceCount() const; - void setMaxInstanceCount(NS::UInteger maxInstanceCount); - - class Buffer* instanceCountBuffer() const; - void setInstanceCountBuffer(const class Buffer* instanceCountBuffer); - - NS::UInteger instanceCountBufferOffset() const; - void setInstanceCountBufferOffset(NS::UInteger instanceCountBufferOffset); - - 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 maxMotionTransformCount() const; - void setMaxMotionTransformCount(NS::UInteger maxMotionTransformCount); - - class Buffer* motionTransformCountBuffer() const; - void setMotionTransformCountBuffer(const class Buffer* motionTransformCountBuffer); - - NS::UInteger motionTransformCountBufferOffset() const; - void setMotionTransformCountBufferOffset(NS::UInteger motionTransformCountBufferOffset); - - static MTL::IndirectInstanceAccelerationStructureDescriptor* 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::AccelerationStructureCurveGeometryDescriptor* MTL::AccelerationStructureCurveGeometryDescriptor::alloc() -{ - return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureCurveGeometryDescriptor)); -} - -// method: init -_MTL_INLINE MTL::AccelerationStructureCurveGeometryDescriptor* MTL::AccelerationStructureCurveGeometryDescriptor::init() -{ - return NS::Object::init(); -} - -// property: controlPointBuffer -_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureCurveGeometryDescriptor::controlPointBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointBuffer)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointBuffer(const MTL::Buffer* controlPointBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointBuffer_), controlPointBuffer); -} - -// property: controlPointBufferOffset -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::controlPointBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointBufferOffset)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointBufferOffset(NS::UInteger controlPointBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointBufferOffset_), controlPointBufferOffset); -} - -// property: controlPointCount -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::controlPointCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointCount)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointCount(NS::UInteger controlPointCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointCount_), controlPointCount); -} - -// property: controlPointStride -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::controlPointStride() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointStride)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointStride(NS::UInteger controlPointStride) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointStride_), controlPointStride); -} - -// property: controlPointFormat -_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureCurveGeometryDescriptor::controlPointFormat() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointFormat)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setControlPointFormat(MTL::AttributeFormat controlPointFormat) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointFormat_), controlPointFormat); -} - -// property: radiusBuffer -_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureCurveGeometryDescriptor::radiusBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusBuffer)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusBuffer(const MTL::Buffer* radiusBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusBuffer_), radiusBuffer); -} - -// property: radiusBufferOffset -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::radiusBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusBufferOffset)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusBufferOffset(NS::UInteger radiusBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusBufferOffset_), radiusBufferOffset); -} - -// property: radiusFormat -_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureCurveGeometryDescriptor::radiusFormat() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusFormat)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusFormat(MTL::AttributeFormat radiusFormat) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusFormat_), radiusFormat); -} - -// property: radiusStride -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::radiusStride() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusStride)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setRadiusStride(NS::UInteger radiusStride) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusStride_), radiusStride); -} - -// property: indexBuffer -_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureCurveGeometryDescriptor::indexBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); -} - -// property: indexBufferOffset -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::indexBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); -} - -// property: indexType -_MTL_INLINE MTL::IndexType MTL::AccelerationStructureCurveGeometryDescriptor::indexType() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setIndexType(MTL::IndexType indexType) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); -} - -// property: segmentCount -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::segmentCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentCount)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setSegmentCount(NS::UInteger segmentCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentCount_), segmentCount); -} - -// property: segmentControlPointCount -_MTL_INLINE NS::UInteger MTL::AccelerationStructureCurveGeometryDescriptor::segmentControlPointCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentControlPointCount)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setSegmentControlPointCount(NS::UInteger segmentControlPointCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentControlPointCount_), segmentControlPointCount); -} - -// property: curveType -_MTL_INLINE MTL::CurveType MTL::AccelerationStructureCurveGeometryDescriptor::curveType() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveType)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setCurveType(MTL::CurveType curveType) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveType_), curveType); -} - -// property: curveBasis -_MTL_INLINE MTL::CurveBasis MTL::AccelerationStructureCurveGeometryDescriptor::curveBasis() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveBasis)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setCurveBasis(MTL::CurveBasis curveBasis) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveBasis_), curveBasis); -} - -// property: curveEndCaps -_MTL_INLINE MTL::CurveEndCaps MTL::AccelerationStructureCurveGeometryDescriptor::curveEndCaps() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveEndCaps)); -} - -_MTL_INLINE void MTL::AccelerationStructureCurveGeometryDescriptor::setCurveEndCaps(MTL::CurveEndCaps curveEndCaps) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveEndCaps_), curveEndCaps); -} - -// static method: descriptor -_MTL_INLINE MTL::AccelerationStructureCurveGeometryDescriptor* MTL::AccelerationStructureCurveGeometryDescriptor::descriptor() -{ - return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureCurveGeometryDescriptor), _MTL_PRIVATE_SEL(descriptor)); -} - -// static method: alloc -_MTL_INLINE MTL::AccelerationStructureMotionCurveGeometryDescriptor* MTL::AccelerationStructureMotionCurveGeometryDescriptor::alloc() -{ - return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionCurveGeometryDescriptor)); -} - -// method: init -_MTL_INLINE MTL::AccelerationStructureMotionCurveGeometryDescriptor* MTL::AccelerationStructureMotionCurveGeometryDescriptor::init() -{ - return NS::Object::init(); -} - -// property: controlPointBuffers -_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointBuffers() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointBuffers)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointBuffers(const NS::Array* controlPointBuffers) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointBuffers_), controlPointBuffers); -} - -// property: controlPointCount -_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointCount)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointCount(NS::UInteger controlPointCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointCount_), controlPointCount); -} - -// property: controlPointStride -_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointStride() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointStride)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointStride(NS::UInteger controlPointStride) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointStride_), controlPointStride); -} - -// property: controlPointFormat -_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureMotionCurveGeometryDescriptor::controlPointFormat() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(controlPointFormat)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setControlPointFormat(MTL::AttributeFormat controlPointFormat) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setControlPointFormat_), controlPointFormat); -} - -// property: radiusBuffers -_MTL_INLINE NS::Array* MTL::AccelerationStructureMotionCurveGeometryDescriptor::radiusBuffers() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusBuffers)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setRadiusBuffers(const NS::Array* radiusBuffers) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusBuffers_), radiusBuffers); -} - -// property: radiusFormat -_MTL_INLINE MTL::AttributeFormat MTL::AccelerationStructureMotionCurveGeometryDescriptor::radiusFormat() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusFormat)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setRadiusFormat(MTL::AttributeFormat radiusFormat) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusFormat_), radiusFormat); -} - -// property: radiusStride -_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::radiusStride() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(radiusStride)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setRadiusStride(NS::UInteger radiusStride) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setRadiusStride_), radiusStride); -} - -// property: indexBuffer -_MTL_INLINE MTL::Buffer* MTL::AccelerationStructureMotionCurveGeometryDescriptor::indexBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBuffer)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setIndexBuffer(const MTL::Buffer* indexBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBuffer_), indexBuffer); -} - -// property: indexBufferOffset -_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::indexBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexBufferOffset)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setIndexBufferOffset(NS::UInteger indexBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexBufferOffset_), indexBufferOffset); -} - -// property: indexType -_MTL_INLINE MTL::IndexType MTL::AccelerationStructureMotionCurveGeometryDescriptor::indexType() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(indexType)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setIndexType(MTL::IndexType indexType) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setIndexType_), indexType); -} - -// property: segmentCount -_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::segmentCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentCount)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setSegmentCount(NS::UInteger segmentCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentCount_), segmentCount); -} - -// property: segmentControlPointCount -_MTL_INLINE NS::UInteger MTL::AccelerationStructureMotionCurveGeometryDescriptor::segmentControlPointCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(segmentControlPointCount)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setSegmentControlPointCount(NS::UInteger segmentControlPointCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setSegmentControlPointCount_), segmentControlPointCount); -} - -// property: curveType -_MTL_INLINE MTL::CurveType MTL::AccelerationStructureMotionCurveGeometryDescriptor::curveType() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveType)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setCurveType(MTL::CurveType curveType) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveType_), curveType); -} - -// property: curveBasis -_MTL_INLINE MTL::CurveBasis MTL::AccelerationStructureMotionCurveGeometryDescriptor::curveBasis() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveBasis)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setCurveBasis(MTL::CurveBasis curveBasis) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveBasis_), curveBasis); -} - -// property: curveEndCaps -_MTL_INLINE MTL::CurveEndCaps MTL::AccelerationStructureMotionCurveGeometryDescriptor::curveEndCaps() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(curveEndCaps)); -} - -_MTL_INLINE void MTL::AccelerationStructureMotionCurveGeometryDescriptor::setCurveEndCaps(MTL::CurveEndCaps curveEndCaps) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setCurveEndCaps_), curveEndCaps); -} - -// static method: descriptor -_MTL_INLINE MTL::AccelerationStructureMotionCurveGeometryDescriptor* MTL::AccelerationStructureMotionCurveGeometryDescriptor::descriptor() -{ - return Object::sendMessage(_MTL_PRIVATE_CLS(MTLAccelerationStructureMotionCurveGeometryDescriptor), _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)); -} - -// static method: alloc -_MTL_INLINE MTL::IndirectInstanceAccelerationStructureDescriptor* MTL::IndirectInstanceAccelerationStructureDescriptor::alloc() -{ - return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLIndirectInstanceAccelerationStructureDescriptor)); -} - -// method: init -_MTL_INLINE MTL::IndirectInstanceAccelerationStructureDescriptor* MTL::IndirectInstanceAccelerationStructureDescriptor::init() -{ - return NS::Object::init(); -} - -// property: instanceDescriptorBuffer -_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBuffer)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorBuffer(const MTL::Buffer* instanceDescriptorBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBuffer_), instanceDescriptorBuffer); -} - -// property: instanceDescriptorBufferOffset -_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorBufferOffset)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorBufferOffset(NS::UInteger instanceDescriptorBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorBufferOffset_), instanceDescriptorBufferOffset); -} - -// property: instanceDescriptorStride -_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorStride() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorStride)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorStride(NS::UInteger instanceDescriptorStride) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorStride_), instanceDescriptorStride); -} - -// property: maxInstanceCount -_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::maxInstanceCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxInstanceCount)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMaxInstanceCount(NS::UInteger maxInstanceCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxInstanceCount_), maxInstanceCount); -} - -// property: instanceCountBuffer -_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::instanceCountBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceCountBuffer)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceCountBuffer(const MTL::Buffer* instanceCountBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceCountBuffer_), instanceCountBuffer); -} - -// property: instanceCountBufferOffset -_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::instanceCountBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceCountBufferOffset)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceCountBufferOffset(NS::UInteger instanceCountBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceCountBufferOffset_), instanceCountBufferOffset); -} - -// property: instanceDescriptorType -_MTL_INLINE MTL::AccelerationStructureInstanceDescriptorType MTL::IndirectInstanceAccelerationStructureDescriptor::instanceDescriptorType() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(instanceDescriptorType)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setInstanceDescriptorType(MTL::AccelerationStructureInstanceDescriptorType instanceDescriptorType) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setInstanceDescriptorType_), instanceDescriptorType); -} - -// property: motionTransformBuffer -_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBuffer)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformBuffer(const MTL::Buffer* motionTransformBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBuffer_), motionTransformBuffer); -} - -// property: motionTransformBufferOffset -_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformBufferOffset)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformBufferOffset(NS::UInteger motionTransformBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformBufferOffset_), motionTransformBufferOffset); -} - -// property: maxMotionTransformCount -_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::maxMotionTransformCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxMotionTransformCount)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMaxMotionTransformCount(NS::UInteger maxMotionTransformCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxMotionTransformCount_), maxMotionTransformCount); -} - -// property: motionTransformCountBuffer -_MTL_INLINE MTL::Buffer* MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformCountBuffer() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformCountBuffer)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformCountBuffer(const MTL::Buffer* motionTransformCountBuffer) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformCountBuffer_), motionTransformCountBuffer); -} - -// property: motionTransformCountBufferOffset -_MTL_INLINE NS::UInteger MTL::IndirectInstanceAccelerationStructureDescriptor::motionTransformCountBufferOffset() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(motionTransformCountBufferOffset)); -} - -_MTL_INLINE void MTL::IndirectInstanceAccelerationStructureDescriptor::setMotionTransformCountBufferOffset(NS::UInteger motionTransformCountBufferOffset) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMotionTransformCountBufferOffset_), motionTransformCountBufferOffset); -} - -// static method: descriptor -_MTL_INLINE MTL::IndirectInstanceAccelerationStructureDescriptor* MTL::IndirectInstanceAccelerationStructureDescriptor::descriptor() -{ - return Object::sendMessage(_MTL_PRIVATE_CLS(MTLIndirectInstanceAccelerationStructureDescriptor), _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/Sources/Apple/include/Metal/MTLAccelerationStructureCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLAccelerationStructureCommandEncoder.hpp deleted file mode 100644 index e0b4ccd9..00000000 --- a/Sources/Apple/include/Metal/MTLAccelerationStructureCommandEncoder.hpp +++ /dev/null @@ -1,290 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLAccelerationStructureTypes.hpp b/Sources/Apple/include/Metal/MTLAccelerationStructureTypes.hpp deleted file mode 100644 index 146ffc20..00000000 --- a/Sources/Apple/include/Metal/MTLAccelerationStructureTypes.hpp +++ /dev/null @@ -1,169 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLArgument.hpp b/Sources/Apple/include/Metal/MTLArgument.hpp deleted file mode 100644 index 29159e5a..00000000 --- a/Sources/Apple/include/Metal/MTLArgument.hpp +++ /dev/null @@ -1,848 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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, - DataTypeBFloat = 121, - DataTypeBFloat2 = 122, - DataTypeBFloat3 = 123, - DataTypeBFloat4 = 124, -}; - -_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, BindingAccess) { - ArgumentAccessReadOnly = 0, - BindingAccessReadOnly = 0, - ArgumentAccessReadWrite = 1, - BindingAccessReadWrite = 1, - BindingAccessWriteOnly = 2, - 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::BindingAccess 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::BindingAccess 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::BindingAccess 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::BindingAccess 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::BindingAccess 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::BindingAccess 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::BindingAccess 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::BindingAccess 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/Sources/Apple/include/Metal/MTLArgumentEncoder.hpp b/Sources/Apple/include/Metal/MTLArgumentEncoder.hpp deleted file mode 100644 index a81859c7..00000000 --- a/Sources/Apple/include/Metal/MTLArgumentEncoder.hpp +++ /dev/null @@ -1,244 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 -{ - -static const NS::UInteger AttributeStrideStatic = NS::UIntegerMax; - -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/Sources/Apple/include/Metal/MTLBinaryArchive.hpp b/Sources/Apple/include/Metal/MTLBinaryArchive.hpp deleted file mode 100644 index 1c77c078..00000000 --- a/Sources/Apple/include/Metal/MTLBinaryArchive.hpp +++ /dev/null @@ -1,139 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLBlitCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLBlitCommandEncoder.hpp deleted file mode 100644 index 8d4845a8..00000000 --- a/Sources/Apple/include/Metal/MTLBlitCommandEncoder.hpp +++ /dev/null @@ -1,246 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLBlitPass.hpp b/Sources/Apple/include/Metal/MTLBlitPass.hpp deleted file mode 100644 index 84987525..00000000 --- a/Sources/Apple/include/Metal/MTLBlitPass.hpp +++ /dev/null @@ -1,165 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLBuffer.hpp b/Sources/Apple/include/Metal/MTLBuffer.hpp deleted file mode 100644 index 684ee8e2..00000000 --- a/Sources/Apple/include/Metal/MTLBuffer.hpp +++ /dev/null @@ -1,109 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLCaptureManager.hpp b/Sources/Apple/include/Metal/MTLCaptureManager.hpp deleted file mode 100644 index ebe7ddd2..00000000 --- a/Sources/Apple/include/Metal/MTLCaptureManager.hpp +++ /dev/null @@ -1,220 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLCaptureScope.hpp b/Sources/Apple/include/Metal/MTLCaptureScope.hpp deleted file mode 100644 index 6d5d1d6f..00000000 --- a/Sources/Apple/include/Metal/MTLCaptureScope.hpp +++ /dev/null @@ -1,92 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLCommandBuffer.hpp b/Sources/Apple/include/Metal/MTLCommandBuffer.hpp deleted file mode 100644 index f8e2bfb6..00000000 --- a/Sources/Apple/include/Metal/MTLCommandBuffer.hpp +++ /dev/null @@ -1,474 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLCommandEncoder.hpp deleted file mode 100644 index 9a4d97c7..00000000 --- a/Sources/Apple/include/Metal/MTLCommandEncoder.hpp +++ /dev/null @@ -1,101 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLCommandQueue.hpp b/Sources/Apple/include/Metal/MTLCommandQueue.hpp deleted file mode 100644 index 07b29844..00000000 --- a/Sources/Apple/include/Metal/MTLCommandQueue.hpp +++ /dev/null @@ -1,89 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLComputeCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLComputeCommandEncoder.hpp deleted file mode 100644 index 50a3b241..00000000 --- a/Sources/Apple/include/Metal/MTLComputeCommandEncoder.hpp +++ /dev/null @@ -1,362 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 setBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index); - - void setBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range); - - void setBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index); - - void setBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index); - - 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: setBuffer:offset:attributeStride:atIndex: -_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, index); -} - -// method: setBuffers:offsets:attributeStrides:withRange: -_MTL_INLINE void MTL::ComputeCommandEncoder::setBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setBuffers_offsets_attributeStrides_withRange_), buffers, offsets, strides, range); -} - -// method: setBufferOffset:attributeStride:atIndex: -_MTL_INLINE void MTL::ComputeCommandEncoder::setBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setBufferOffset_attributeStride_atIndex_), offset, stride, index); -} - -// method: setBytes:length:attributeStride:atIndex: -_MTL_INLINE void MTL::ComputeCommandEncoder::setBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setBytes_length_attributeStride_atIndex_), bytes, length, stride, index); -} - -// 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/Sources/Apple/include/Metal/MTLComputePass.hpp b/Sources/Apple/include/Metal/MTLComputePass.hpp deleted file mode 100644 index bbc71841..00000000 --- a/Sources/Apple/include/Metal/MTLComputePass.hpp +++ /dev/null @@ -1,181 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLComputePipeline.hpp b/Sources/Apple/include/Metal/MTLComputePipeline.hpp deleted file mode 100644 index 3065b8f2..00000000 --- a/Sources/Apple/include/Metal/MTLComputePipeline.hpp +++ /dev/null @@ -1,373 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLCounters.hpp b/Sources/Apple/include/Metal/MTLCounters.hpp deleted file mode 100644 index c552f7ed..00000000 --- a/Sources/Apple/include/Metal/MTLCounters.hpp +++ /dev/null @@ -1,258 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLDefines.hpp b/Sources/Apple/include/Metal/MTLDefines.hpp deleted file mode 100644 index 7dd8ff95..00000000 --- a/Sources/Apple/include/Metal/MTLDefines.hpp +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLDepthStencil.hpp b/Sources/Apple/include/Metal/MTLDepthStencil.hpp deleted file mode 100644 index ba8bd8b0..00000000 --- a/Sources/Apple/include/Metal/MTLDepthStencil.hpp +++ /dev/null @@ -1,269 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLDevice.hpp b/Sources/Apple/include/Metal/MTLDevice.hpp deleted file mode 100644 index 12ffe5b4..00000000 --- a/Sources/Apple/include/Metal/MTLDevice.hpp +++ /dev/null @@ -1,1444 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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::BindingAccess access() const; - void setAccess(MTL::BindingAccess access); - - MTL::TextureType textureType() const; - void setTextureType(MTL::TextureType textureType); - - NS::UInteger constantBlockAlignment() const; - void setConstantBlockAlignment(NS::UInteger constantBlockAlignment); - }; - - class Architecture : public NS::Copying - { - public: - static class Architecture *alloc(); - - class Architecture *init(); - - NS::String *name() const; - } SWIFT_IMMORTAL_REFERENCE; - - 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; - - class Architecture *architecture() 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); - - class IOFileHandle *newIOFileHandle(const NS::URL *url, NS::Error **error); - - class IOFileHandle *newIOFileHandle(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; - } SWIFT_IMMORTAL_REFERENCE; - -} - -// 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::BindingAccess MTL::ArgumentDescriptor::access() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(access)); -} - -_MTL_INLINE void MTL::ArgumentDescriptor::setAccess(MTL::BindingAccess 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); -} - -// static method: alloc -_MTL_INLINE MTL::Architecture *MTL::Architecture::alloc() -{ - return NS::Object::alloc(_MTL_PRIVATE_CLS(MTLArchitecture)); -} - -// method: init -_MTL_INLINE MTL::Architecture *MTL::Architecture::init() -{ - return NS::Object::init(); -} - -// property: name -_MTL_INLINE NS::String *MTL::Architecture::name() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); -} - -_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: architecture -_MTL_INLINE MTL::Architecture *MTL::Device::architecture() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(architecture)); -} - -// 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: newIOFileHandleWithURL:error: -_MTL_INLINE MTL::IOFileHandle *MTL::Device::newIOFileHandle(const NS::URL *url, NS::Error **error) -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOFileHandleWithURL_error_), url, error); -} - -// method: newIOFileHandleWithURL:compressionMethod:error: -_MTL_INLINE MTL::IOFileHandle *MTL::Device::newIOFileHandle(const NS::URL *url, MTL::IOCompressionMethod compressionMethod, NS::Error **error) -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(newIOFileHandleWithURL_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/Sources/Apple/include/Metal/MTLDrawable.hpp b/Sources/Apple/include/Metal/MTLDrawable.hpp deleted file mode 100644 index 58945d03..00000000 --- a/Sources/Apple/include/Metal/MTLDrawable.hpp +++ /dev/null @@ -1,99 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLDynamicLibrary.hpp b/Sources/Apple/include/Metal/MTLDynamicLibrary.hpp deleted file mode 100644 index f951d125..00000000 --- a/Sources/Apple/include/Metal/MTLDynamicLibrary.hpp +++ /dev/null @@ -1,82 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLEvent.hpp b/Sources/Apple/include/Metal/MTLEvent.hpp deleted file mode 100644 index 965fc39e..00000000 --- a/Sources/Apple/include/Metal/MTLEvent.hpp +++ /dev/null @@ -1,159 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLFence.hpp b/Sources/Apple/include/Metal/MTLFence.hpp deleted file mode 100644 index c8ef24ca..00000000 --- a/Sources/Apple/include/Metal/MTLFence.hpp +++ /dev/null @@ -1,57 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLFunctionConstantValues.hpp b/Sources/Apple/include/Metal/MTLFunctionConstantValues.hpp deleted file mode 100644 index d23d98fc..00000000 --- a/Sources/Apple/include/Metal/MTLFunctionConstantValues.hpp +++ /dev/null @@ -1,85 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLFunctionDescriptor.hpp b/Sources/Apple/include/Metal/MTLFunctionDescriptor.hpp deleted file mode 100644 index ec82d981..00000000 --- a/Sources/Apple/include/Metal/MTLFunctionDescriptor.hpp +++ /dev/null @@ -1,157 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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, - FunctionOptionStoreFunctionInMetalScript = 2, -}; - -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/Sources/Apple/include/Metal/MTLFunctionHandle.hpp b/Sources/Apple/include/Metal/MTLFunctionHandle.hpp deleted file mode 100644 index 30f71f2e..00000000 --- a/Sources/Apple/include/Metal/MTLFunctionHandle.hpp +++ /dev/null @@ -1,61 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLFunctionLog.hpp b/Sources/Apple/include/Metal/MTLFunctionLog.hpp deleted file mode 100644 index 2a899525..00000000 --- a/Sources/Apple/include/Metal/MTLFunctionLog.hpp +++ /dev/null @@ -1,114 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLFunctionStitching.hpp b/Sources/Apple/include/Metal/MTLFunctionStitching.hpp deleted file mode 100644 index 0ae7d6a4..00000000 --- a/Sources/Apple/include/Metal/MTLFunctionStitching.hpp +++ /dev/null @@ -1,307 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 -{ -public: -}; - -class FunctionStitchingAttributeAlwaysInline : public NS::Referencing -{ -public: - static class FunctionStitchingAttributeAlwaysInline* alloc(); - - class FunctionStitchingAttributeAlwaysInline* init(); -}; - -class FunctionStitchingNode : public NS::Copying -{ -public: -}; - -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/Sources/Apple/include/Metal/MTLHeaderBridge.hpp b/Sources/Apple/include/Metal/MTLHeaderBridge.hpp deleted file mode 100644 index 23c3cec6..00000000 --- a/Sources/Apple/include/Metal/MTLHeaderBridge.hpp +++ /dev/null @@ -1,2436 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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(MTLAccelerationStructureCurveGeometryDescriptor); -_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureDescriptor); -_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureGeometryDescriptor); -_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor); -_MTL_PRIVATE_DEF_CLS(MTLAccelerationStructureMotionCurveGeometryDescriptor); -_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(MTLArchitecture); -_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(MTLIndirectInstanceAccelerationStructureDescriptor); -_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(architecture, - "architecture"); -_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(controlPointBuffer, - "controlPointBuffer"); -_MTL_PRIVATE_DEF_SEL(controlPointBufferOffset, - "controlPointBufferOffset"); -_MTL_PRIVATE_DEF_SEL(controlPointBuffers, - "controlPointBuffers"); -_MTL_PRIVATE_DEF_SEL(controlPointCount, - "controlPointCount"); -_MTL_PRIVATE_DEF_SEL(controlPointFormat, - "controlPointFormat"); -_MTL_PRIVATE_DEF_SEL(controlPointStride, - "controlPointStride"); -_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(curveBasis, - "curveBasis"); -_MTL_PRIVATE_DEF_SEL(curveType, - "curveType"); -_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(curveEndCaps, - "curveEndCaps"); -_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(instanceCountBuffer, - "instanceCountBuffer"); -_MTL_PRIVATE_DEF_SEL(instanceCountBufferOffset, - "instanceCountBufferOffset"); -_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(maxInstanceCount, - "maxInstanceCount"); -_MTL_PRIVATE_DEF_SEL(maxKernelBufferBindCount, - "maxKernelBufferBindCount"); -_MTL_PRIVATE_DEF_SEL(maxKernelThreadgroupMemoryBindCount, - "maxKernelThreadgroupMemoryBindCount"); -_MTL_PRIVATE_DEF_SEL(maxMotionTransformCount, - "maxMotionTransformCount"); -_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(meshLinkedFunctions, - "meshLinkedFunctions"); -_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(motionTransformCountBuffer, - "motionTransformCountBuffer"); -_MTL_PRIVATE_DEF_SEL(motionTransformCountBufferOffset, - "motionTransformCountBufferOffset"); -_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(newIOFileHandleWithURL_compressionMethod_error_, - "newIOFileHandleWithURL:compressionMethod:error:"); -_MTL_PRIVATE_DEF_SEL(newIOFileHandleWithURL_error_, - "newIOFileHandleWithURL: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(objectLinkedFunctions, - "objectLinkedFunctions"); -_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(radiusBuffer, - "radiusBuffer"); -_MTL_PRIVATE_DEF_SEL(radiusBufferOffset, - "radiusBufferOffset"); -_MTL_PRIVATE_DEF_SEL(radiusBuffers, - "radiusBuffers"); -_MTL_PRIVATE_DEF_SEL(radiusFormat, - "radiusFormat"); -_MTL_PRIVATE_DEF_SEL(radiusStride, - "radiusStride"); -_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(segmentControlPointCount, - "segmentControlPointCount"); -_MTL_PRIVATE_DEF_SEL(segmentCount, - "segmentCount"); -_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(setBuffer_offset_attributeStride_atIndex_, - "setBuffer:offset:attributeStride:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setBufferIndex_, - "setBufferIndex:"); -_MTL_PRIVATE_DEF_SEL(setBufferOffset_atIndex_, - "setBufferOffset:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setBufferOffset_attributeStride_atIndex_, - "setBufferOffset:attributeStride:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setBuffers_offsets_attributeStrides_withRange_, - "setBuffers:offsets:attributeStrides:withRange:"); -_MTL_PRIVATE_DEF_SEL(setBuffers_offsets_withRange_, - "setBuffers:offsets:withRange:"); -_MTL_PRIVATE_DEF_SEL(setBytes_length_atIndex_, - "setBytes:length:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setBytes_length_attributeStride_atIndex_, - "setBytes:length:attributeStride: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(setControlPointBuffer_, - "setControlPointBuffer:"); -_MTL_PRIVATE_DEF_SEL(setControlPointBufferOffset_, - "setControlPointBufferOffset:"); -_MTL_PRIVATE_DEF_SEL(setControlPointBuffers_, - "setControlPointBuffers:"); -_MTL_PRIVATE_DEF_SEL(setControlPointCount_, - "setControlPointCount:"); -_MTL_PRIVATE_DEF_SEL(setControlPointFormat_, - "setControlPointFormat:"); -_MTL_PRIVATE_DEF_SEL(setControlPointStride_, - "setControlPointStride:"); -_MTL_PRIVATE_DEF_SEL(setCounterSet_, - "setCounterSet:"); -_MTL_PRIVATE_DEF_SEL(setCpuCacheMode_, - "setCpuCacheMode:"); -_MTL_PRIVATE_DEF_SEL(setCullMode_, - "setCullMode:"); -_MTL_PRIVATE_DEF_SEL(setCurveBasis_, - "setCurveBasis:"); -_MTL_PRIVATE_DEF_SEL(setCurveType_, - "setCurveType:"); -_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(setCurveEndCaps_, - "setCurveEndCaps:"); -_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(setInstanceCountBuffer_, - "setInstanceCountBuffer:"); -_MTL_PRIVATE_DEF_SEL(setInstanceCountBufferOffset_, - "setInstanceCountBufferOffset:"); -_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(setKernelBuffer_offset_attributeStride_atIndex_, - "setKernelBuffer:offset:attributeStride: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(setMaxInstanceCount_, - "setMaxInstanceCount:"); -_MTL_PRIVATE_DEF_SEL(setMaxKernelBufferBindCount_, - "setMaxKernelBufferBindCount:"); -_MTL_PRIVATE_DEF_SEL(setMaxKernelThreadgroupMemoryBindCount_, - "setMaxKernelThreadgroupMemoryBindCount:"); -_MTL_PRIVATE_DEF_SEL(setMaxMotionTransformCount_, - "setMaxMotionTransformCount:"); -_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(setMeshLinkedFunctions_, - "setMeshLinkedFunctions:"); -_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(setMotionTransformCountBuffer_, - "setMotionTransformCountBuffer:"); -_MTL_PRIVATE_DEF_SEL(setMotionTransformCountBufferOffset_, - "setMotionTransformCountBufferOffset:"); -_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(setObjectLinkedFunctions_, - "setObjectLinkedFunctions:"); -_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(setOpaqueCurveIntersectionFunctionWithSignature_atIndex_, - "setOpaqueCurveIntersectionFunctionWithSignature:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setOpaqueCurveIntersectionFunctionWithSignature_withRange_, - "setOpaqueCurveIntersectionFunctionWithSignature:withRange:"); -_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(setRadiusBuffer_, - "setRadiusBuffer:"); -_MTL_PRIVATE_DEF_SEL(setRadiusBufferOffset_, - "setRadiusBufferOffset:"); -_MTL_PRIVATE_DEF_SEL(setRadiusBuffers_, - "setRadiusBuffers:"); -_MTL_PRIVATE_DEF_SEL(setRadiusFormat_, - "setRadiusFormat:"); -_MTL_PRIVATE_DEF_SEL(setRadiusStride_, - "setRadiusStride:"); -_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(setSegmentControlPointCount_, - "setSegmentControlPointCount:"); -_MTL_PRIVATE_DEF_SEL(setSegmentCount_, - "setSegmentCount:"); -_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(setSupportDynamicAttributeStride_, - "setSupportDynamicAttributeStride:"); -_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(setVertexBuffer_offset_attributeStride_atIndex_, - "setVertexBuffer:offset:attributeStride:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_, - "setVertexBufferOffset:"); -_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_atIndex_, - "setVertexBufferOffset:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setVertexBufferOffset_attributeStride_atIndex_, - "setVertexBufferOffset:attributeStride:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setVertexBuffers_, - "setVertexBuffers:"); -_MTL_PRIVATE_DEF_SEL(setVertexBuffers_offsets_attributeStrides_withRange_, - "setVertexBuffers:offsets:attributeStrides:withRange:"); -_MTL_PRIVATE_DEF_SEL(setVertexBuffers_offsets_withRange_, - "setVertexBuffers:offsets:withRange:"); -_MTL_PRIVATE_DEF_SEL(setVertexBytes_length_atIndex_, - "setVertexBytes:length:atIndex:"); -_MTL_PRIVATE_DEF_SEL(setVertexBytes_length_attributeStride_atIndex_, - "setVertexBytes:length:attributeStride: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(supportDynamicAttributeStride, - "supportDynamicAttributeStride"); -_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/Sources/Apple/include/Metal/MTLHeap.hpp b/Sources/Apple/include/Metal/MTLHeap.hpp deleted file mode 100644 index bb5b8361..00000000 --- a/Sources/Apple/include/Metal/MTLHeap.hpp +++ /dev/null @@ -1,329 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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* descriptor); - - 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* descriptor) -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(newTextureWithDescriptor_), descriptor); -} - -// 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/Sources/Apple/include/Metal/MTLIOCommandBuffer.hpp b/Sources/Apple/include/Metal/MTLIOCommandBuffer.hpp deleted file mode 100644 index fb28f3e7..00000000 --- a/Sources/Apple/include/Metal/MTLIOCommandBuffer.hpp +++ /dev/null @@ -1,200 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLIOCommandQueue.hpp b/Sources/Apple/include/Metal/MTLIOCommandQueue.hpp deleted file mode 100644 index b5f5d1c2..00000000 --- a/Sources/Apple/include/Metal/MTLIOCommandQueue.hpp +++ /dev/null @@ -1,225 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLIOCompressor.hpp b/Sources/Apple/include/Metal/MTLIOCompressor.hpp deleted file mode 100644 index ad9e92d1..00000000 --- a/Sources/Apple/include/Metal/MTLIOCompressor.hpp +++ /dev/null @@ -1,94 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 -{ -using IOCompresionContext=void*; - -_MTL_ENUM(NS::Integer, IOCompressionStatus) { - IOCompressionStatusComplete = 0, - IOCompressionStatusError = 1, -}; - -size_t IOCompressionContextDefaultChunkSize(); - -IOCompresionContext IOCreateCompressionContext(const char* path, IOCompressionMethod type, size_t chunkSize); - -void IOCompressionContextAppendData(IOCompresionContext context, const void* data, size_t size); - -IOCompressionStatus IOFlushAndDestroyCompressionContext(IOCompresionContext 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/Sources/Apple/include/Metal/MTLIndirectCommandBuffer.hpp b/Sources/Apple/include/Metal/MTLIndirectCommandBuffer.hpp deleted file mode 100644 index 52474a01..00000000 --- a/Sources/Apple/include/Metal/MTLIndirectCommandBuffer.hpp +++ /dev/null @@ -1,240 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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); - - NS::UInteger maxKernelThreadgroupMemoryBindCount() const; - void setMaxKernelThreadgroupMemoryBindCount(NS::UInteger maxKernelThreadgroupMemoryBindCount); - - bool supportRayTracing() const; - void setSupportRayTracing(bool supportRayTracing); - - bool supportDynamicAttributeStride() const; - void setSupportDynamicAttributeStride(bool supportDynamicAttributeStride); -}; - -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: maxKernelThreadgroupMemoryBindCount -_MTL_INLINE NS::UInteger MTL::IndirectCommandBufferDescriptor::maxKernelThreadgroupMemoryBindCount() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(maxKernelThreadgroupMemoryBindCount)); -} - -_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setMaxKernelThreadgroupMemoryBindCount(NS::UInteger maxKernelThreadgroupMemoryBindCount) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMaxKernelThreadgroupMemoryBindCount_), maxKernelThreadgroupMemoryBindCount); -} - -// 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: supportDynamicAttributeStride -_MTL_INLINE bool MTL::IndirectCommandBufferDescriptor::supportDynamicAttributeStride() const -{ - return Object::sendMessageSafe(this, _MTL_PRIVATE_SEL(supportDynamicAttributeStride)); -} - -_MTL_INLINE void MTL::IndirectCommandBufferDescriptor::setSupportDynamicAttributeStride(bool supportDynamicAttributeStride) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setSupportDynamicAttributeStride_), supportDynamicAttributeStride); -} - -// 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/Sources/Apple/include/Metal/MTLIndirectCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLIndirectCommandEncoder.hpp deleted file mode 100644 index 7464edb9..00000000 --- a/Sources/Apple/include/Metal/MTLIndirectCommandEncoder.hpp +++ /dev/null @@ -1,203 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, 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 setKernelBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, 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: setVertexBuffer:offset:attributeStride:atIndex: -_MTL_INLINE void MTL::IndirectRenderCommand::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, 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: setKernelBuffer:offset:attributeStride:atIndex: -_MTL_INLINE void MTL::IndirectComputeCommand::setKernelBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setKernelBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, 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/Sources/Apple/include/Metal/MTLIntersectionFunctionTable.hpp b/Sources/Apple/include/Metal/MTLIntersectionFunctionTable.hpp deleted file mode 100644 index e1c0911e..00000000 --- a/Sources/Apple/include/Metal/MTLIntersectionFunctionTable.hpp +++ /dev/null @@ -1,181 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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, - IntersectionFunctionSignatureMaxLevels = 64, - IntersectionFunctionSignatureCurveData = 128, -}; - -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 setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index); - - void setOpaqueCurveIntersectionFunction(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: setOpaqueCurveIntersectionFunctionWithSignature:atIndex: -_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueCurveIntersectionFunctionWithSignature_atIndex_), signature, index); -} - -// method: setOpaqueCurveIntersectionFunctionWithSignature:withRange: -_MTL_INLINE void MTL::IntersectionFunctionTable::setOpaqueCurveIntersectionFunction(MTL::IntersectionFunctionSignature signature, NS::Range range) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setOpaqueCurveIntersectionFunctionWithSignature_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/Sources/Apple/include/Metal/MTLLibrary.hpp b/Sources/Apple/include/Metal/MTLLibrary.hpp deleted file mode 100644 index 234373d4..00000000 --- a/Sources/Apple/include/Metal/MTLLibrary.hpp +++ /dev/null @@ -1,691 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLLinkedFunctions.hpp b/Sources/Apple/include/Metal/MTLLinkedFunctions.hpp deleted file mode 100644 index 89ee8759..00000000 --- a/Sources/Apple/include/Metal/MTLLinkedFunctions.hpp +++ /dev/null @@ -1,115 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLParallelRenderCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLParallelRenderCommandEncoder.hpp deleted file mode 100644 index d6d6ad8c..00000000 --- a/Sources/Apple/include/Metal/MTLParallelRenderCommandEncoder.hpp +++ /dev/null @@ -1,94 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLPipeline.hpp b/Sources/Apple/include/Metal/MTLPipeline.hpp deleted file mode 100644 index 1b6859ca..00000000 --- a/Sources/Apple/include/Metal/MTLPipeline.hpp +++ /dev/null @@ -1,109 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLPixelFormat.hpp b/Sources/Apple/include/Metal/MTLPixelFormat.hpp deleted file mode 100644 index 7a0c3c09..00000000 --- a/Sources/Apple/include/Metal/MTLPixelFormat.hpp +++ /dev/null @@ -1,173 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLPrivate.hpp b/Sources/Apple/include/Metal/MTLPrivate.hpp deleted file mode 100644 index e72e6354..00000000 --- a/Sources/Apple/include/Metal/MTLPrivate.hpp +++ /dev/null @@ -1,156 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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(__MAC_14_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__IPHONE_17_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) || defined(__TVOS_17_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(__MAC_14_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__IPHONE_17_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) || defined(__TVOS_17_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/Sources/Apple/include/Metal/MTLRasterizationRate.hpp b/Sources/Apple/include/Metal/MTLRasterizationRate.hpp deleted file mode 100644 index cac23392..00000000 --- a/Sources/Apple/include/Metal/MTLRasterizationRate.hpp +++ /dev/null @@ -1,386 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLRenderCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLRenderCommandEncoder.hpp deleted file mode 100644 index a3b0c420..00000000 --- a/Sources/Apple/include/Metal/MTLRenderCommandEncoder.hpp +++ /dev/null @@ -1,1177 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index); - - void setVertexBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range); - - void setVertexBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index); - - void setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index); - - 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: setVertexBuffer:offset:attributeStride:atIndex: -_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, index); -} - -// method: setVertexBuffers:offsets:attributeStrides:withRange: -_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBuffers_offsets_attributeStrides_withRange_), buffers, offsets, strides, range); -} - -// method: setVertexBufferOffset:attributeStride:atIndex: -_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_attributeStride_atIndex_), offset, stride, index); -} - -// method: setVertexBytes:length:attributeStride:atIndex: -_MTL_INLINE void MTL::RenderCommandEncoder::setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setVertexBytes_length_attributeStride_atIndex_), bytes, length, stride, index); -} - -// 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/Sources/Apple/include/Metal/MTLRenderPass.hpp b/Sources/Apple/include/Metal/MTLRenderPass.hpp deleted file mode 100644 index 087b4467..00000000 --- a/Sources/Apple/include/Metal/MTLRenderPass.hpp +++ /dev/null @@ -1,786 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLRenderPipeline.hpp b/Sources/Apple/include/Metal/MTLRenderPipeline.hpp deleted file mode 100644 index 1a3c08ee..00000000 --- a/Sources/Apple/include/Metal/MTLRenderPipeline.hpp +++ /dev/null @@ -1,1640 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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); - - class LinkedFunctions* objectLinkedFunctions() const; - void setObjectLinkedFunctions(const class LinkedFunctions* objectLinkedFunctions); - - class LinkedFunctions* meshLinkedFunctions() const; - void setMeshLinkedFunctions(const class LinkedFunctions* meshLinkedFunctions); - - class LinkedFunctions* fragmentLinkedFunctions() const; - void setFragmentLinkedFunctions(const class LinkedFunctions* fragmentLinkedFunctions); - - 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); -} - -// property: objectLinkedFunctions -_MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::objectLinkedFunctions() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(objectLinkedFunctions)); -} - -_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectLinkedFunctions(const MTL::LinkedFunctions* objectLinkedFunctions) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setObjectLinkedFunctions_), objectLinkedFunctions); -} - -// property: meshLinkedFunctions -_MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::meshLinkedFunctions() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(meshLinkedFunctions)); -} - -_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshLinkedFunctions(const MTL::LinkedFunctions* meshLinkedFunctions) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setMeshLinkedFunctions_), meshLinkedFunctions); -} - -// property: fragmentLinkedFunctions -_MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::fragmentLinkedFunctions() const -{ - return Object::sendMessage(this, _MTL_PRIVATE_SEL(fragmentLinkedFunctions)); -} - -_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setFragmentLinkedFunctions(const MTL::LinkedFunctions* fragmentLinkedFunctions) -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(setFragmentLinkedFunctions_), fragmentLinkedFunctions); -} - -// method: reset -_MTL_INLINE void MTL::MeshRenderPipelineDescriptor::reset() -{ - Object::sendMessage(this, _MTL_PRIVATE_SEL(reset)); -} diff --git a/Sources/Apple/include/Metal/MTLResource.hpp b/Sources/Apple/include/Metal/MTLResource.hpp deleted file mode 100644 index 69c57d38..00000000 --- a/Sources/Apple/include/Metal/MTLResource.hpp +++ /dev/null @@ -1,178 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLResourceStateCommandEncoder.hpp b/Sources/Apple/include/Metal/MTLResourceStateCommandEncoder.hpp deleted file mode 100644 index cf54f387..00000000 --- a/Sources/Apple/include/Metal/MTLResourceStateCommandEncoder.hpp +++ /dev/null @@ -1,103 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLResourceStatePass.hpp b/Sources/Apple/include/Metal/MTLResourceStatePass.hpp deleted file mode 100644 index 3c759b1a..00000000 --- a/Sources/Apple/include/Metal/MTLResourceStatePass.hpp +++ /dev/null @@ -1,165 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLSampler.hpp b/Sources/Apple/include/Metal/MTLSampler.hpp deleted file mode 100644 index b086744a..00000000 --- a/Sources/Apple/include/Metal/MTLSampler.hpp +++ /dev/null @@ -1,319 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLStageInputOutputDescriptor.hpp b/Sources/Apple/include/Metal/MTLStageInputOutputDescriptor.hpp deleted file mode 100644 index dbc37467..00000000 --- a/Sources/Apple/include/Metal/MTLStageInputOutputDescriptor.hpp +++ /dev/null @@ -1,383 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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, - AttributeFormatFloatRG11B10 = 54, - AttributeFormatFloatRGB9E5 = 55, -}; - -_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/Sources/Apple/include/Metal/MTLTexture.hpp b/Sources/Apple/include/Metal/MTLTexture.hpp deleted file mode 100644 index 15898f40..00000000 --- a/Sources/Apple/include/Metal/MTLTexture.hpp +++ /dev/null @@ -1,685 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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, - TextureUsageShaderAtomic = 32, -}; - -_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/Sources/Apple/include/Metal/MTLTypes.hpp b/Sources/Apple/include/Metal/MTLTypes.hpp deleted file mode 100644 index 09a81840..00000000 --- a/Sources/Apple/include/Metal/MTLTypes.hpp +++ /dev/null @@ -1,168 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/MTLVersion.hpp b/Sources/Apple/include/Metal/MTLVersion.hpp deleted file mode 100644 index 5926b6b5..00000000 --- a/Sources/Apple/include/Metal/MTLVersion.hpp +++ /dev/null @@ -1,32 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 341 -#define METALCPP_VERSION_MINOR 0 -#define METALCPP_VERSION_PATCH 0 - -#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/Sources/Apple/include/Metal/MTLVertexDescriptor.hpp b/Sources/Apple/include/Metal/MTLVertexDescriptor.hpp deleted file mode 100644 index 7e92b551..00000000 --- a/Sources/Apple/include/Metal/MTLVertexDescriptor.hpp +++ /dev/null @@ -1,349 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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 -{ - -static const NS::UInteger BufferLayoutStrideDynamic = NS::UIntegerMax; - -_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, - VertexFormatFloatRG11B10 = 54, - VertexFormatFloatRGB9E5 = 55, -}; - -_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/Sources/Apple/include/Metal/MTLVisibleFunctionTable.hpp b/Sources/Apple/include/Metal/MTLVisibleFunctionTable.hpp deleted file mode 100644 index 88e8fb1e..00000000 --- a/Sources/Apple/include/Metal/MTLVisibleFunctionTable.hpp +++ /dev/null @@ -1,104 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/Metal/Metal.hpp b/Sources/Apple/include/Metal/Metal.hpp deleted file mode 100644 index 6ea7adf3..00000000 --- a/Sources/Apple/include/Metal/Metal.hpp +++ /dev/null @@ -1,84 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/MetalFX/MTLFXDefines.hpp b/Sources/Apple/include/MetalFX/MTLFXDefines.hpp deleted file mode 100644 index 8b452168..00000000 --- a/Sources/Apple/include/MetalFX/MTLFXDefines.hpp +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// MetalFX/MTLFXDefines.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 _MTLFX_EXPORT _NS_EXPORT -#define _MTLFX_EXTERN _NS_EXTERN -#define _MTLFX_INLINE _NS_INLINE -#define _MTLFX_PACKED _NS_PACKED - -#define _MTLFX_CONST( type, name ) _NS_CONST( type, name ) -#define _MTLFX_ENUM( type, name ) _NS_ENUM( type, name ) -#define _MTLFX_OPTIONS( type, name ) _NS_OPTIONS( type, name ) - -#define _MTLFX_VALIDATE_SIZE( mtlfx, name ) _NS_VALIDATE_SIZE( mtlfx, name ) -#define _MTLFX_VALIDATE_ENUM( mtlfx, name ) _NS_VALIDATE_ENUM( mtlfx, name ) - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/MetalFX/MTLFXPrivate.hpp b/Sources/Apple/include/MetalFX/MTLFXPrivate.hpp deleted file mode 100644 index e4645537..00000000 --- a/Sources/Apple/include/MetalFX/MTLFXPrivate.hpp +++ /dev/null @@ -1,281 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// MetalFX/MTLFXPrivate.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 "MTLFXDefines.hpp" - -#include - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#define _MTLFX_PRIVATE_CLS( symbol ) ( Private::Class::s_k##symbol ) -#define _MTLFX_PRIVATE_SEL( accessor ) ( Private::Selector::s_k##accessor ) - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#if defined( MTLFX_PRIVATE_IMPLEMENTATION ) - -#if defined( METALCPP_SYMBOL_VISIBILITY_HIDDEN ) -#define _MTLFX_PRIVATE_VISIBILITY __attribute__( ( visibility("hidden" ) ) ) -#else -#define _MTLFX_PRIVATE_VISIBILITY __attribute__( ( visibility("default" ) ) ) -#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN - -#define _MTLFX_PRIVATE_IMPORT __attribute__( ( weak_import ) ) - -#ifdef __OBJC__ -#define _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) ( ( __bridge void* ) objc_lookUpClass( #symbol ) ) -#define _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) ( ( __bridge void* ) objc_getProtocol( #symbol ) ) -#else -#define _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) objc_lookUpClass(#symbol) -#define _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) objc_getProtocol(#symbol) -#endif // __OBJC__ - -#define _MTLFX_PRIVATE_DEF_CLS( symbol ) void* s_k##symbol _MTLFX_PRIVATE_VISIBILITY = _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) -#define _MTLFX_PRIVATE_DEF_PRO( symbol ) void* s_k##symbol _MTLFX_PRIVATE_VISIBILITY = _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) -#define _MTLFX_PRIVATE_DEF_SEL( accessor, symbol ) SEL s_k##accessor _MTLFX_PRIVATE_VISIBILITY = sel_registerName( symbol ) - -#include -#define MTLFX_DEF_FUNC( name, signature ) using Fn##name = signature; \ - Fn##name name = reinterpret_cast< Fn##name >( dlsym( RTLD_DEFAULT, #name ) ) - -namespace MTLFX::Private -{ - template - - inline _Type const LoadSymbol(const char* pSymbol) - { - const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol)); - - return pAddress ? *pAddress : nullptr; - } -} // MTLFX::Private - -#if defined( __MAC_13_0 ) || defined( __MAC_14_0 ) || defined( __IPHONE_16_0 ) || defined( __IPHONE_17_0 ) || defined( __TVOS_16_0 ) || defined( __TVOS_17_0 ) - -#define _MTLFX_PRIVATE_DEF_STR( type, symbol ) \ - _MTLFX_EXTERN type const MTLFX##symbol _MTLFX_PRIVATE_IMPORT; \ - type const MTLFX::symbol = ( nullptr != &MTLFX##symbol ) ? MTLFX##ssymbol : nullptr - -#define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) \ - _MTLFX_EXTERN type const MTLFX##ssymbol _MTLFX_PRIVATE_IMPORT; \ - type const MTLFX::symbol = (nullptr != &MTLFX##ssymbol) ? MTLFX##ssymbol : nullptr - -#define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) \ - _MTLFX_EXTERN type const MTLFX##ssymbol; \ - type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol ) - -#else - -#define _MTLFX_PRIVATE_DEF_STR( type, symbol ) \ - _MTLFX_EXTERN type const MTLFX##ssymbol; \ - type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol ) - -#define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) \ - _MTLFX_EXTERN type const MTLFX##ssymbol; \ - type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol ) - -#define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) _MTLFX_PRIVATE_DEF_CONST( type, symbol ) - -#endif // defined( __MAC_13_0 ) || defined( __MAC_14_0 ) || defined( __IPHONE_16_0 ) || defined( __IPHONE_17_0 ) || defined( __TVOS_16_0 ) || defined( __TVOS_17_0 ) - -#else - -#define _MTLFX_PRIVATE_DEF_CLS( symbol ) extern void* s_k##symbol -#define _MTLFX_PRIVATE_DEF_PRO( symbol ) extern void* s_k##symbol -#define _MTLFX_PRIVATE_DEF_SEL( accessor, symbol ) extern SEL s_k##accessor -#define _MTLFX_PRIVATE_DEF_STR( type, symbol ) extern type const MTLFX::symbol -#define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) extern type const MTLFX::symbol -#define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) extern type const MTLFX::symbol - -#endif // MTLFX_PRIVATE_IMPLEMENTATION - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace MTLFX -{ - namespace Private - { - namespace Class - { - _MTLFX_PRIVATE_DEF_CLS( MTLFXSpatialScalerDescriptor ); - _MTLFX_PRIVATE_DEF_CLS( MTLFXTemporalScalerDescriptor ); - } // Class - } // Private -} // MTLFX - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace MTLFX -{ - namespace Private - { - namespace Protocol - { - _MTLFX_PRIVATE_DEF_PRO( MTLFXSpatialScaler ); - _MTLFX_PRIVATE_DEF_PRO( MTLFXTemporalScaler ); - } // Protocol - } // Private -} // MTLFX - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace MTLFX -{ - namespace Private - { - namespace Selector - { - _MTLFX_PRIVATE_DEF_SEL( colorProcessingMode, - "colorProcessingMode" ); - _MTLFX_PRIVATE_DEF_SEL( colorTexture, - "colorTexture" ); - _MTLFX_PRIVATE_DEF_SEL( colorTextureFormat, - "colorTextureFormat" ); - _MTLFX_PRIVATE_DEF_SEL( colorTextureUsage, - "colorTextureUsage" ); - _MTLFX_PRIVATE_DEF_SEL( depthTexture, - "depthTexture" ); - _MTLFX_PRIVATE_DEF_SEL( depthTextureFormat, - "depthTextureFormat" ); - _MTLFX_PRIVATE_DEF_SEL( depthTextureUsage, - "depthTextureUsage" ); - _MTLFX_PRIVATE_DEF_SEL( encodeToCommandBuffer_, - "encodeToCommandBuffer:" ); - _MTLFX_PRIVATE_DEF_SEL( exposureTexture, - "exposureTexture" ); - _MTLFX_PRIVATE_DEF_SEL( fence, - "fence" ); - _MTLFX_PRIVATE_DEF_SEL( inputContentHeight, - "inputContentHeight" ); - _MTLFX_PRIVATE_DEF_SEL( inputContentMaxScale, - "inputContentMaxScale" ); - _MTLFX_PRIVATE_DEF_SEL( inputContentMinScale, - "inputContentMinScale" ); - _MTLFX_PRIVATE_DEF_SEL( inputContentWidth, - "inputContentWidth" ); - _MTLFX_PRIVATE_DEF_SEL( inputHeight, - "inputHeight" ); - _MTLFX_PRIVATE_DEF_SEL( inputWidth, - "inputWidth" ); - _MTLFX_PRIVATE_DEF_SEL( isAutoExposureEnabled, - "isAutoExposureEnabled" ); - _MTLFX_PRIVATE_DEF_SEL( isDepthReversed, - "isDepthReversed" ); - _MTLFX_PRIVATE_DEF_SEL( isInputContentPropertiesEnabled, - "isInputContentPropertiesEnabled" ); - _MTLFX_PRIVATE_DEF_SEL( jitterOffsetX, - "jitterOffsetX" ); - _MTLFX_PRIVATE_DEF_SEL( jitterOffsetY, - "jitterOffsetY" ); - _MTLFX_PRIVATE_DEF_SEL( motionTexture, - "motionTexture" ); - _MTLFX_PRIVATE_DEF_SEL( motionTextureFormat, - "motionTextureFormat" ); - _MTLFX_PRIVATE_DEF_SEL( motionTextureUsage, - "motionTextureUsage" ); - _MTLFX_PRIVATE_DEF_SEL( motionVectorScaleX, - "motionVectorScaleX" ); - _MTLFX_PRIVATE_DEF_SEL( motionVectorScaleY, - "motionVectorScaleY" ); - _MTLFX_PRIVATE_DEF_SEL( newSpatialScalerWithDevice_, - "newSpatialScalerWithDevice:" ); - _MTLFX_PRIVATE_DEF_SEL( newTemporalScalerWithDevice_, - "newTemporalScalerWithDevice:" ); - _MTLFX_PRIVATE_DEF_SEL( outputHeight, - "outputHeight" ); - _MTLFX_PRIVATE_DEF_SEL( outputTexture, - "outputTexture" ); - _MTLFX_PRIVATE_DEF_SEL( outputTextureFormat, - "outputTextureFormat" ); - _MTLFX_PRIVATE_DEF_SEL( outputTextureUsage, - "outputTextureUsage" ); - _MTLFX_PRIVATE_DEF_SEL( outputWidth, - "outputWidth" ); - _MTLFX_PRIVATE_DEF_SEL( preExposure, - "preExposure" ); - _MTLFX_PRIVATE_DEF_SEL( reset, - "reset" ); - _MTLFX_PRIVATE_DEF_SEL( setAutoExposureEnabled_, - "setAutoExposureEnabled:" ); - _MTLFX_PRIVATE_DEF_SEL( setColorProcessingMode_, - "setColorProcessingMode:" ); - _MTLFX_PRIVATE_DEF_SEL( setColorTexture_, - "setColorTexture:" ); - _MTLFX_PRIVATE_DEF_SEL( setColorTextureFormat_, - "setColorTextureFormat:" ); - _MTLFX_PRIVATE_DEF_SEL( setDepthReversed_, - "setDepthReversed:" ); - _MTLFX_PRIVATE_DEF_SEL( setDepthTexture_, - "setDepthTexture:" ); - _MTLFX_PRIVATE_DEF_SEL( setDepthTextureFormat_, - "setDepthTextureFormat:" ); - _MTLFX_PRIVATE_DEF_SEL( setExposureTexture_, - "setExposureTexture:" ); - _MTLFX_PRIVATE_DEF_SEL( setFence_, - "setFence:" ); - _MTLFX_PRIVATE_DEF_SEL( setInputContentHeight_, - "setInputContentHeight:" ); - _MTLFX_PRIVATE_DEF_SEL( setInputContentMaxScale_, - "setInputContentMaxScale:" ); - _MTLFX_PRIVATE_DEF_SEL( setInputContentMinScale_, - "setInputContentMinScale:" ); - _MTLFX_PRIVATE_DEF_SEL( setInputContentPropertiesEnabled_, - "setInputContentPropertiesEnabled:" ); - _MTLFX_PRIVATE_DEF_SEL( setInputContentWidth_, - "setInputContentWidth_:" ); - _MTLFX_PRIVATE_DEF_SEL( setInputHeight_, - "setInputHeight:" ); - _MTLFX_PRIVATE_DEF_SEL( setInputWidth_, - "setInputWidth:" ); - _MTLFX_PRIVATE_DEF_SEL( setJitterOffsetX_, - "setJitterOffsetX:" ); - _MTLFX_PRIVATE_DEF_SEL( setJitterOffsetY_, - "setJitterOffsetY:" ); - _MTLFX_PRIVATE_DEF_SEL( setMotionTexture_, - "setMotionTexture:" ); - _MTLFX_PRIVATE_DEF_SEL( setMotionTextureFormat_, - "setMotionTextureFormat:" ); - _MTLFX_PRIVATE_DEF_SEL( setMotionVectorScaleX_, - "setMotionVectorScaleX:" ); - _MTLFX_PRIVATE_DEF_SEL( setMotionVectorScaleY_, - "setMotionVectorScaleY:" ); - _MTLFX_PRIVATE_DEF_SEL( setOutputHeight_, - "setOutputHeight:" ); - _MTLFX_PRIVATE_DEF_SEL( setOutputTexture_, - "setOutputTexture:" ); - _MTLFX_PRIVATE_DEF_SEL( setOutputTextureFormat_, - "setOutputTextureFormat:" ); - _MTLFX_PRIVATE_DEF_SEL( setOutputWidth_, - "setOutputWidth:" ); - _MTLFX_PRIVATE_DEF_SEL( setPreExposure_, - "setPreExposure:" ); - _MTLFX_PRIVATE_DEF_SEL( setReset_, - "setReset:" ); - _MTLFX_PRIVATE_DEF_SEL( supportsDevice_, - "supportsDevice:" ); - } // Selector - } // Private -} // MTLFX - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/MetalFX/MTLFXSpatialScaler.hpp b/Sources/Apple/include/MetalFX/MTLFXSpatialScaler.hpp deleted file mode 100644 index 841898d4..00000000 --- a/Sources/Apple/include/MetalFX/MTLFXSpatialScaler.hpp +++ /dev/null @@ -1,372 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// MetalFX/MTLFXSpatialScaler.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 "MTLFXDefines.hpp" -#include "MTLFXPrivate.hpp" - -#include "../Metal/Metal.hpp" - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace MTLFX -{ - _MTLFX_ENUM( NS::Integer, SpatialScalerColorProcessingMode ) - { - SpatialScalerColorProcessingModePerceptual = 0, - SpatialScalerColorProcessingModeLinear = 1, - SpatialScalerColorProcessingModeHDR = 2 - }; - - class SpatialScalerDescriptor : public NS::Copying< SpatialScalerDescriptor > - { - public: - static class SpatialScalerDescriptor* alloc(); - class SpatialScalerDescriptor* init(); - - MTL::PixelFormat colorTextureFormat() const; - void setColorTextureFormat( MTL::PixelFormat format ); - - MTL::PixelFormat outputTextureFormat() const; - void setOutputTextureFormat( MTL::PixelFormat format ); - - NS::UInteger inputWidth() const; - void setInputWidth( NS::UInteger width ); - - NS::UInteger inputHeight() const; - void setInputHeight( NS::UInteger height ); - - NS::UInteger outputWidth() const; - void setOutputWidth( NS::UInteger width ); - - NS::UInteger outputHeight() const; - void setOutputHeight( NS::UInteger height ); - - SpatialScalerColorProcessingMode colorProcessingMode() const; - void setColorProcessingMode( SpatialScalerColorProcessingMode mode ); - - class SpatialScaler* newSpatialScaler( const MTL::Device* pDevice ); - - static bool supportsDevice( const MTL::Device* ); - }; - - class SpatialScaler : public NS::Referencing< SpatialScaler > - { - public: - MTL::TextureUsage colorTextureUsage() const; - MTL::TextureUsage outputTextureUsage() const; - - NS::UInteger inputContentWidth() const; - void setInputContentWidth( NS::UInteger width ); - - NS::UInteger inputContentHeight() const; - void setInputContentHeight( NS::UInteger height ); - - MTL::Texture* colorTexture() const; - void setColorTexture( MTL::Texture* pTexture ); - - MTL::Texture* outputTexture() const; - void setOutputTexture( MTL::Texture* pTexture ); - - MTL::PixelFormat colorTextureFormat() const; - MTL::PixelFormat outputTextureFormat() const; - NS::UInteger inputWidth() const; - NS::UInteger inputHeight() const; - NS::UInteger outputWidth() const; - NS::UInteger outputHeight() const; - SpatialScalerColorProcessingMode colorProcessingMode() const; - - MTL::Fence* fence() const; - void setFence( MTL::Fence* pFence ); - - void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ); - }; -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::alloc() -{ - return NS::Object::alloc< SpatialScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::init() -{ - return NS::Object::init< SpatialScalerDescriptor >(); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::colorTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTextureFormat_ ), format ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::outputTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTextureFormat_ ), format ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputWidth( NS::UInteger width ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputWidth_ ), width ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputHeight( NS::UInteger height ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputHeight_ ), height ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputWidth( NS::UInteger width ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputWidth_ ), width ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputHeight( NS::UInteger height ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputHeight_ ), height ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScalerDescriptor::colorProcessingMode() const -{ - return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorProcessingMode( SpatialScalerColorProcessingMode mode ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorProcessingMode_ ), mode ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::SpatialScaler* MTLFX::SpatialScalerDescriptor::newSpatialScaler( const MTL::Device* pDevice ) -{ - return Object::sendMessage< SpatialScaler* >( this, _MTLFX_PRIVATE_SEL( newSpatialScalerWithDevice_ ), pDevice ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE bool MTLFX::SpatialScalerDescriptor::supportsDevice( const MTL::Device* pDevice ) -{ - return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScaler::colorTextureUsage() const -{ - return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScaler::outputTextureUsage() const -{ - return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputContentWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScaler::setInputContentWidth( NS::UInteger width ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentWidth_ ), width ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputContentHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScaler::setInputContentHeight( NS::UInteger height ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentHeight_ ), height ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScaler::colorTexture() const -{ - return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScaler::setColorTexture( MTL::Texture* pTexture ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTexture_ ), pTexture ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Texture* MTLFX::SpatialScaler::outputTexture() const -{ - return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScaler::setOutputTexture( MTL::Texture* pTexture ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTexture_ ), pTexture ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScaler::colorTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScaler::outputTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::outputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::outputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScaler::colorProcessingMode() const -{ - return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Fence* MTLFX::SpatialScaler::fence() const -{ - return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScaler::setFence( MTL::Fence* pFence ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setFence_ ), pFence ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::SpatialScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/MetalFX/MTLFXTemporalScaler.hpp b/Sources/Apple/include/MetalFX/MTLFXTemporalScaler.hpp deleted file mode 100644 index 97e189af..00000000 --- a/Sources/Apple/include/MetalFX/MTLFXTemporalScaler.hpp +++ /dev/null @@ -1,660 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// MetalFX/MTLFXTemporalScaler.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 "MTLFXDefines.hpp" -#include "MTLFXPrivate.hpp" - -#include "../Metal/Metal.hpp" - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace MTLFX -{ - class TemporalScalerDescriptor : public NS::Copying< TemporalScalerDescriptor > - { - public: - static class TemporalScalerDescriptor* alloc(); - class TemporalScalerDescriptor* init(); - - MTL::PixelFormat colorTextureFormat() const; - void setColorTextureFormat( MTL::PixelFormat format ); - - MTL::PixelFormat depthTextureFormat() const; - void setDepthTextureFormat( MTL::PixelFormat format ); - - MTL::PixelFormat motionTextureFormat() const; - void setMotionTextureFormat( MTL::PixelFormat format ); - - MTL::PixelFormat outputTextureFormat() const; - void setOutputTextureFormat( MTL::PixelFormat format ); - - NS::UInteger inputWidth() const; - void setInputWidth( NS::UInteger width ); - - NS::UInteger inputHeight() const; - void setInputHeight( NS::UInteger height ); - - NS::UInteger outputWidth() const; - void setOutputWidth( NS::UInteger width ); - - NS::UInteger outputHeight() const; - void setOutputHeight( NS::UInteger height ); - - bool isAutoExposureEnabled() const; - void setAutoExposureEnabled( bool enabled ); - - bool isInputContentPropertiesEnabled() const; - void setInputContentPropertiesEnabled( bool enabled ); - - float inputContentMinScale() const; - void setInputContentMinScale( float scale ); - - float inputContentMaxScale() const; - void setInputContentMaxScale( float scale ); - - class TemporalScaler* newTemporalScaler( const MTL::Device* pDevice ) const; - - static bool supportsDevice( const MTL::Device* pDevice ); - }; - - class TemporalScaler : public NS::Referencing< TemporalScaler > - { - public: - MTL::TextureUsage colorTextureUsage() const; - MTL::TextureUsage depthTextureUsage() const; - MTL::TextureUsage motionTextureUsage() const; - MTL::TextureUsage outputTextureUsage() const; - - NS::UInteger inputContentWidth() const; - void setInputContentWidth( NS::UInteger width ); - - NS::UInteger inputContentHeight() const; - void setInputContentHeight( NS::UInteger height ); - - MTL::Texture* colorTexture() const; - void setColorTexture( MTL::Texture* pTexture ); - - MTL::Texture* depthTexture() const; - void setDepthTexture( MTL::Texture* pTexture ); - - MTL::Texture* motionTexture() const; - void setMotionTexture( MTL::Texture* pTexture ); - - MTL::Texture* outputTexture() const; - void setOutputTexture( MTL::Texture* pTexture ); - - MTL::Texture* exposureTexture() const; - void setExposureTexture( MTL::Texture* pTexture ); - - float preExposure() const; - void setPreExposure( float preExposure ); - - float jitterOffsetX() const; - void setJitterOffsetX( float offset ); - - float jitterOffsetY() const; - void setJitterOffsetY( float offset ); - - float motionVectorScaleX() const; - void setMotionVectorScaleX( float scale ); - - float motionVectorScaleY() const; - void setMotionVectorScaleY( float scale ); - - bool reset() const; - void setReset( bool reset ); - - bool isDepthReversed() const; - void setDepthReversed( bool depthReversed ); - - MTL::PixelFormat colorTextureFormat() const; - MTL::PixelFormat depthTextureFormat() const; - MTL::PixelFormat motionTextureFormat() const; - MTL::PixelFormat outputTextureFormat() const; - NS::UInteger inputWidth() const; - NS::UInteger inputHeight() const; - NS::UInteger outputWidth() const; - NS::UInteger outputHeight() const; - float inputContentMinScale() const; - float inputContentMaxScale() const; - - MTL::Fence* fence() const; - void setFence( MTL::Fence* pFence ); - - void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ); - }; -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::TemporalScalerDescriptor* MTLFX::TemporalScalerDescriptor::alloc() -{ - return NS::Object::alloc< TemporalScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::TemporalScalerDescriptor* MTLFX::TemporalScalerDescriptor::init() -{ - return NS::Object::init< TemporalScalerDescriptor >(); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::colorTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTextureFormat_ ), format ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::depthTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( depthTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setDepthTextureFormat( MTL::PixelFormat format ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthTextureFormat_ ), format ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::motionTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( motionTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setMotionTextureFormat( MTL::PixelFormat format ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionTextureFormat_ ), format ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::outputTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTextureFormat_ ), format ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::inputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputWidth( NS::UInteger width ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputWidth_ ), width ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::inputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputHeight( NS::UInteger height ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputHeight_ ), height ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::outputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputWidth( NS::UInteger width ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputWidth_ ), width ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::outputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputHeight( NS::UInteger height ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputHeight_ ), height ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::isAutoExposureEnabled() const -{ - return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isAutoExposureEnabled ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setAutoExposureEnabled( bool enabled ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setAutoExposureEnabled_ ), enabled ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::isInputContentPropertiesEnabled() const -{ - return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isInputContentPropertiesEnabled ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentPropertiesEnabled( bool enabled ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentPropertiesEnabled_ ), enabled ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::inputContentMinScale() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMinScale ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentMinScale( float scale ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentMinScale_ ), scale ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::inputContentMaxScale() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMaxScale ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentMaxScale( float scale ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentMaxScale_ ), scale ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTLFX::TemporalScaler* MTLFX::TemporalScalerDescriptor::newTemporalScaler( const MTL::Device* pDevice ) const -{ - return Object::sendMessage< TemporalScaler* >( this, _MTLFX_PRIVATE_SEL( newTemporalScalerWithDevice_ ), pDevice ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::supportsDevice( const MTL::Device* pDevice ) -{ - return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::colorTextureUsage() const -{ - return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::depthTextureUsage() const -{ - return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( depthTextureUsage ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::motionTextureUsage() const -{ - return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( motionTextureUsage ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::outputTextureUsage() const -{ - return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputContentWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setInputContentWidth( NS::UInteger width ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentWidth_ ), width ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputContentHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setInputContentHeight( NS::UInteger height ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentHeight_ ), height ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::colorTexture() const -{ - return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setColorTexture( MTL::Texture* pTexture ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTexture_ ), pTexture ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::depthTexture() const -{ - return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( depthTexture ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setDepthTexture( MTL::Texture* pTexture ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthTexture_ ), pTexture ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::motionTexture() const -{ - return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( motionTexture ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setMotionTexture( MTL::Texture* pTexture ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionTexture_ ), pTexture ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::outputTexture() const -{ - return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setOutputTexture( MTL::Texture* pTexture ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTexture_ ), pTexture ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::exposureTexture() const -{ - return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( exposureTexture ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setExposureTexture( MTL::Texture* pTexture ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setExposureTexture_ ), pTexture ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScaler::preExposure() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( preExposure ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setPreExposure( float preExposure ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setPreExposure_ ), preExposure ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScaler::jitterOffsetX() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( jitterOffsetX ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setJitterOffsetX( float offset ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setJitterOffsetX_ ), offset ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScaler::jitterOffsetY() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( jitterOffsetY ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setJitterOffsetY( float offset ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setJitterOffsetY_ ), offset ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScaler::motionVectorScaleX() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( motionVectorScaleX ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setMotionVectorScaleX( float scale ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionVectorScaleX_ ), scale ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScaler::motionVectorScaleY() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( motionVectorScaleY ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setMotionVectorScaleY( float scale ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionVectorScaleY_ ), scale ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE bool MTLFX::TemporalScaler::reset() const -{ - return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( reset ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setReset( bool reset ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setReset_ ), reset ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE bool MTLFX::TemporalScaler::isDepthReversed() const -{ - return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isDepthReversed ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setDepthReversed( bool depthReversed ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthReversed_ ), depthReversed ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::colorTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::depthTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( depthTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::motionTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( motionTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::outputTextureFormat() const -{ - return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::outputWidth() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::outputHeight() const -{ - return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScaler::inputContentMinScale() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMinScale ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE float MTLFX::TemporalScaler::inputContentMaxScale() const -{ - return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMaxScale ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE MTL::Fence* MTLFX::TemporalScaler::fence() const -{ - return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::setFence( MTL::Fence* pFence ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setFence_ ), pFence ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -_MTLFX_INLINE void MTLFX::TemporalScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer ) -{ - Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer ); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/MetalFX/MetalFX.hpp b/Sources/Apple/include/MetalFX/MetalFX.hpp deleted file mode 100644 index 40405cd3..00000000 --- a/Sources/Apple/include/MetalFX/MetalFX.hpp +++ /dev/null @@ -1,28 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// MetalFX/MetalFX.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 "MTLFXSpatialScaler.hpp" -#include "MTLFXTemporalScaler.hpp" - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/OpenGL/NSGLContext.hpp b/Sources/Apple/include/OpenGL/NSGLContext.hpp deleted file mode 100644 index 73d19def..00000000 --- a/Sources/Apple/include/OpenGL/NSGLContext.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/* ---------------------------------------------------------------- - * :: : M E T A V E R S E : :: - * ---------------------------------------------------------------- - * This software is Licensed under the terms of the Apache License, - * version 2.0 (the "Apache License") with the following additional - * modification; you may not use this file except within compliance - * of the Apache License and the following modification made to it. - * Section 6. Trademarks. is deleted and replaced with: - * - * Trademarks. This License does not grant permission to use any of - * its trade names, trademarks, service marks, or the product names - * of this Licensor or its affiliates, except as required to comply - * with Section 4(c.) of this License, and to reproduce the content - * of the NOTICE file. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an - * implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the Apache License for more details. - * - * You should have received a copy for this software license of the - * Apache License along with this program; or, if not, please write - * to the Free Software Foundation Inc., with the following address - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) 2024 Wabi Foundation. All Rights Reserved. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ---------------------------------------------------------------- */ - -#pragma once - -#include "NSGLDefines.hpp" -#include "NSGLPrivate.hpp" -#include "NSGLPixelFormat.hpp" - -#include - -#include "OpenGL.hpp" - -namespace NSGL -{ -_NSGL_ENUM(NS::Integer, OpenGLContextParameter) { - OpenGLContextParameterSwapInterval = 222, - OpenGLContextParameterSurfaceOrder = 235, - OpenGLContextParameterSurfaceOpacity = 236, - OpenGLContextParameterSurfaceBackingSize = 304, - OpenGLContextParameterReclaimResources = 308, - OpenGLContextParameterCurrentRendererID = 309, - OpenGLContextParameterGPUVertexProcessing = 310, - OpenGLContextParameterGPUFragmentProcessing = 311, - OpenGLContextParameterHasDrawable = 314, - OpenGLContextParameterMPSwapsInFlight = 315, - OpenGLContextParameterSwapRectangle = 200, - OpenGLContextParameterSwapRectangleEnable = 201, - OpenGLContextParameterRasterizationEnable = 221, - OpenGLContextParameterStateValidation = 301, - OpenGLContextParameterSurfaceSurfaceVolatile = 306, -}; - -class OpenGLContext : public NS::Referencing -{ - public: - static class OpenGLContext* alloc(); - - NSGL::OpenGLContext* init(const NSGL::OpenGLPixelFormat* format, NSGL::OpenGLContext* share); - - NSGL::OpenGLPixelFormat* pixelFormat() const; - -#if 0 - void setView(NS::View* view); - NS::View* view() const; - - void setPixelBuffer(NS::PixelBuffer* pixelBuffer); - NS::PixelBuffer* pixelBuffer() const; -#endif // 0 - - void setOffScreen(void* baseaddr, NS::Integer width, NS::Integer height, NS::Integer rowbytes); - - void clearDrawable(); - void update(); - - /* Flush draw buffer */ - void flushBuffer(); - - /* Current context control */ - void makeCurrentContext(); - static void clearCurrentContext(); - static NSGL::OpenGLContext* currentContext(); - - void setFullScreen(); - void clearFullScreen(); - - void setValues(const NS::Integer* vals, NSGL::OpenGLContextParameter param); - void getValues(NS::Integer* vals, NSGL::OpenGLContextParameter param); - - NS::Integer currentVirtualScreen() const; - - void* CGLContextObj() const; -}; -} // namespace NSGL - -// static method: alloc -_NSGL_INLINE NSGL::OpenGLContext* NSGL::OpenGLContext::alloc() -{ - return NS::Object::alloc(_NSGL_PRIVATE_CLS(NSOpenGLContext)); -} - -// method: initWithFormat:shareContext: -_NSGL_INLINE NSGL::OpenGLContext* NSGL::OpenGLContext::init(const NSGL::OpenGLPixelFormat* format, NSGL::OpenGLContext* share) -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(initWithFormat_shareContext_), format, share); -} - -// method: pixelFormat -_NSGL_INLINE NSGL::OpenGLPixelFormat* NSGL::OpenGLContext::pixelFormat() const -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(pixelFormat)); -} - -// method: setOffScreen:width:height:rowbytes: -_NSGL_INLINE void NSGL::OpenGLContext::setOffScreen(void* baseaddr, NS::Integer width, NS::Integer height, NS::Integer rowbytes) -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(setOffScreen_width_height_rowbytes_), baseaddr, width, height, rowbytes); -} - -// method: clearDrawable -_NSGL_INLINE void NSGL::OpenGLContext::clearDrawable() -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(clearDrawable)); -} - -// method: update -_NSGL_INLINE void NSGL::OpenGLContext::update() -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(update)); -} - -// method: flushBuffer -_NSGL_INLINE void NSGL::OpenGLContext::flushBuffer() -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(flushBuffer)); -} - -// method: makeCurrentContext -_NSGL_INLINE void NSGL::OpenGLContext::makeCurrentContext() -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(makeCurrentContext)); -} - -// static method: clearCurrentContext -_NSGL_INLINE void NSGL::OpenGLContext::clearCurrentContext() -{ - Object::sendMessage(_NSGL_PRIVATE_CLS(NSOpenGLContext), _NSGL_PRIVATE_SEL(clearCurrentContext)); -} - -// static method: currentContext -_NSGL_INLINE NSGL::OpenGLContext* NSGL::OpenGLContext::currentContext() -{ - return Object::sendMessage(_NSGL_PRIVATE_CLS(NSOpenGLContext), _NSGL_PRIVATE_SEL(currentContext)); -} - -// method: setFullScreen -_NSGL_INLINE void NSGL::OpenGLContext::setFullScreen() -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(setFullScreen)); -} - -// method: clearFullScreen -_NSGL_INLINE void NSGL::OpenGLContext::clearFullScreen() -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(clearFullScreen)); -} - -// method: setValues:forParameter: -_NSGL_INLINE void NSGL::OpenGLContext::setValues(const NS::Integer* vals, NSGL::OpenGLContextParameter param) -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(setValues_forParameter_), vals, param); -} - -// method: getValues:forParameter: -_NSGL_INLINE void NSGL::OpenGLContext::getValues(NS::Integer* vals, NSGL::OpenGLContextParameter param) -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(getValues_forParameter_), vals, param); -} - -// method: currentVirtualScreen -_NSGL_INLINE NS::Integer NSGL::OpenGLContext::currentVirtualScreen() const -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(currentVirtualScreen)); -} - -// method: CGLContextObj -_NSGL_INLINE void* NSGL::OpenGLContext::CGLContextObj() const -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(CGLContextObj)); -} diff --git a/Sources/Apple/include/OpenGL/NSGLDefines.hpp b/Sources/Apple/include/OpenGL/NSGLDefines.hpp deleted file mode 100644 index 6754204c..00000000 --- a/Sources/Apple/include/OpenGL/NSGLDefines.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* ---------------------------------------------------------------- - * :: : M E T A V E R S E : :: - * ---------------------------------------------------------------- - * This software is Licensed under the terms of the Apache License, - * version 2.0 (the "Apache License") with the following additional - * modification; you may not use this file except within compliance - * of the Apache License and the following modification made to it. - * Section 6. Trademarks. is deleted and replaced with: - * - * Trademarks. This License does not grant permission to use any of - * its trade names, trademarks, service marks, or the product names - * of this Licensor or its affiliates, except as required to comply - * with Section 4(c.) of this License, and to reproduce the content - * of the NOTICE file. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an - * implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the Apache License for more details. - * - * You should have received a copy for this software license of the - * Apache License along with this program; or, if not, please write - * to the Free Software Foundation Inc., with the following address - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) 2024 Wabi Foundation. All Rights Reserved. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ---------------------------------------------------------------- */ - -#pragma once - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#include "../Foundation/NSDefines.hpp" - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#define _NSGL_EXPORT _NS_EXPORT -#define _NSGL_EXTERN _NS_EXTERN -#define _NSGL_INLINE _NS_INLINE -#define _NSGL_PACKED _NS_PACKED - -#define _NSGL_CONST(type, name) _NS_CONST(type, name) -#define _NSGL_ENUM(type, name) _NS_ENUM(type, name) -#define _NSGL_OPTIONS(type, name) _NS_OPTIONS(type, name) - -#define _NSGL_VALIDATE_SIZE(ns, name) _NS_VALIDATE_SIZE(ns, name) -#define _NSGL_VALIDATE_ENUM(ns, name) _NS_VALIDATE_ENUM(ns, name) - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/OpenGL/NSGLPixelFormat.hpp b/Sources/Apple/include/OpenGL/NSGLPixelFormat.hpp deleted file mode 100644 index bbd931ec..00000000 --- a/Sources/Apple/include/OpenGL/NSGLPixelFormat.hpp +++ /dev/null @@ -1,147 +0,0 @@ -/* ---------------------------------------------------------------- - * :: : M E T A V E R S E : :: - * ---------------------------------------------------------------- - * This software is Licensed under the terms of the Apache License, - * version 2.0 (the "Apache License") with the following additional - * modification; you may not use this file except within compliance - * of the Apache License and the following modification made to it. - * Section 6. Trademarks. is deleted and replaced with: - * - * Trademarks. This License does not grant permission to use any of - * its trade names, trademarks, service marks, or the product names - * of this Licensor or its affiliates, except as required to comply - * with Section 4(c.) of this License, and to reproduce the content - * of the NOTICE file. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an - * implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the Apache License for more details. - * - * You should have received a copy for this software license of the - * Apache License along with this program; or, if not, please write - * to the Free Software Foundation Inc., with the following address - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) 2024 Wabi Foundation. All Rights Reserved. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ---------------------------------------------------------------- */ - -#pragma once - -#include "NSGLDefines.hpp" -#include "NSGLPrivate.hpp" - -#include - -#include "OpenGL.hpp" - -namespace NSGL -{ -_NSGL_ENUM(NS::UInteger, OpenGLPixelFormatAttribute) -{ - OpenGLPFAAllRenderers = 1, - OpenGLPFATripleBuffer = 3, - OpenGLPFADoubleBuffer = 5, - OpenGLPFAAuxBuffers = 7, - OpenGLPFAColorSize = 8, - OpenGLPFAAlphaSize = 11, - OpenGLPFADepthSize = 12, - OpenGLPFAStencilSize = 13, - OpenGLPFAAccumSize = 14, - OpenGLPFAMinimumPolicy = 51, - OpenGLPFAMaximumPolicy = 52, - OpenGLPFASampleBuffers = 55, - OpenGLPFASamples = 56, - OpenGLPFAAuxDepthStencil = 57, - OpenGLPFAColorFloat = 58, - OpenGLPFAMultisample = 59, - OpenGLPFASupersample = 60, - OpenGLPFASampleAlpha = 61, - OpenGLPFARendererID = 70, - OpenGLPFANoRecovery = 72, - OpenGLPFAAccelerated = 73, - OpenGLPFAClosestPolicy = 74, - OpenGLPFABackingStore = 76, - OpenGLPFAScreenMask = 84, - OpenGLPFAAllowOfflineRenderers = 96, - OpenGLPFAAcceleratedCompute = 97, - OpenGLPFAOpenGLProfile = 99, - OpenGLPFAVirtualScreenCount = 128, - - OpenGLPFAStereo = 6, - OpenGLPFAOffScreen = 53, - OpenGLPFAFullScreen = 54, - OpenGLPFASingleRenderer = 71, - OpenGLPFARobust = 75, - OpenGLPFAMPSafe = 78, - OpenGLPFAWindow = 80, - OpenGLPFAMultiScreen = 81, - OpenGLPFACompliant = 83, - OpenGLPFAPixelBuffer = 90, - OpenGLPFARemotePixelBuffer = 91, - - OpenGLProfileVersionLegacy = 0x1000, /* choose a Legacy/Pre-OpenGL 3.0 Implementation */ - OpenGLProfileVersion3_2Core = 0x3200, /* choose an OpenGL 3.2 Core Implementation */ - OpenGLProfileVersion4_1Core = 0x4100, /* choose an OpenGL 4.1 Core Implementation */ -}; - -class OpenGLPixelFormat : public NS::Referencing -{ - public: - static class OpenGLPixelFormat* alloc(); - - NSGL::OpenGLPixelFormat* init(const NSGL::OpenGLPixelFormatAttribute* attribs); - NSGL::OpenGLPixelFormat* init(NS::Data* attribs); - - NS::Data* attributes(NSGL::OpenGLPixelFormatAttribute attributes); - void getValues(NS::Integer* vals, NSGL::OpenGLPixelFormatAttribute attrib, NS::Integer screen); - - NS::Integer numberOfVirtualScreens() const; - - void* CGLPixelFormatObj() const; -}; -} // namespace NSGL - -// static method: alloc -_NSGL_INLINE NSGL::OpenGLPixelFormat* NSGL::OpenGLPixelFormat::alloc() -{ - return NS::Object::alloc(_NSGL_PRIVATE_CLS(NSOpenGLPixelFormat)); -} - -// method: initWithAttributes: -_NSGL_INLINE NSGL::OpenGLPixelFormat* NSGL::OpenGLPixelFormat::init(const NSGL::OpenGLPixelFormatAttribute* attribs) -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(initWithAttributes_), attribs); -} - -// method: initWithData: -_NSGL_INLINE NSGL::OpenGLPixelFormat* NSGL::OpenGLPixelFormat::init(NS::Data* attribs) -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(initWithData_), attribs); -} - -// method: attributes -_NSGL_INLINE NS::Data* NSGL::OpenGLPixelFormat::attributes(NSGL::OpenGLPixelFormatAttribute attributes) -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(attributes), attributes); -} - -// method: getValues:forAttribute:forVirtualScreen: -_NSGL_INLINE void NSGL::OpenGLPixelFormat::getValues(NS::Integer* vals, NSGL::OpenGLPixelFormatAttribute attrib, NS::Integer screen) -{ - Object::sendMessage(this, _NSGL_PRIVATE_SEL(getValues_forAttribute_forVirtualScreen_), vals, attrib, screen); -} - -// property: numberOfVirtualScreens -_NSGL_INLINE NS::Integer NSGL::OpenGLPixelFormat::numberOfVirtualScreens() const -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(numberOfVirtualScreens)); -} - -// property: CGLPixelFormatObj -_NSGL_INLINE void* NSGL::OpenGLPixelFormat::CGLPixelFormatObj() const -{ - return Object::sendMessage(this, _NSGL_PRIVATE_SEL(CGLPixelFormatObj)); -} diff --git a/Sources/Apple/include/OpenGL/NSGLPrivate.hpp b/Sources/Apple/include/OpenGL/NSGLPrivate.hpp deleted file mode 100644 index 1788d737..00000000 --- a/Sources/Apple/include/OpenGL/NSGLPrivate.hpp +++ /dev/null @@ -1,206 +0,0 @@ -/* ---------------------------------------------------------------- - * :: : M E T A V E R S E : :: - * ---------------------------------------------------------------- - * This software is Licensed under the terms of the Apache License, - * version 2.0 (the "Apache License") with the following additional - * modification; you may not use this file except within compliance - * of the Apache License and the following modification made to it. - * Section 6. Trademarks. is deleted and replaced with: - * - * Trademarks. This License does not grant permission to use any of - * its trade names, trademarks, service marks, or the product names - * of this Licensor or its affiliates, except as required to comply - * with Section 4(c.) of this License, and to reproduce the content - * of the NOTICE file. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an - * implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the Apache License for more details. - * - * You should have received a copy for this software license of the - * Apache License along with this program; or, if not, please write - * to the Free Software Foundation Inc., with the following address - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) 2024 Wabi Foundation. All Rights Reserved. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ---------------------------------------------------------------- */ - -#pragma once - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#include "NSGLDefines.hpp" - -#include - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#define _NSGL_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol) -#define _NSGL_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor) - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#if defined(NSGL_PRIVATE_IMPLEMENTATION) - -#ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN -#define _NSGL_PRIVATE_VISIBILITY __attribute__((visibility("hidden"))) -#else -#define _NSGL_PRIVATE_VISIBILITY __attribute__((visibility("default"))) -#endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN - -#define _NSGL_PRIVATE_IMPORT __attribute__((weak_import)) - -#ifdef __OBJC__ -#define _NSGL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol)) -#define _NSGL_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol)) -#else -#define _NSGL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol) -#define _NSGL_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol) -#endif // __OBJC__ - -#define _NSGL_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _NSGL_PRIVATE_VISIBILITY = _NSGL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) -#define _NSGL_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _NSGL_PRIVATE_VISIBILITY = _NSGL_PRIVATE_OBJC_GET_PROTOCOL(symbol) -#define _NSGL_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _NSGL_PRIVATE_VISIBILITY = sel_registerName(symbol) - -#include -#define NSGL_DEF_FUNC( name, signature ) \ - using Fn##name = signature; \ - Fn##name name = reinterpret_cast< Fn##name >( dlsym( RTLD_DEFAULT, #name ) ) - -namespace NSGL::Private -{ - template - inline _Type const LoadSymbol(const char* pSymbol) - { - const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol)); - - return pAddress ? *pAddress : nullptr; - } -} // NSGL::Private - -#if defined(__MAC_10_16) || defined(__MAC_11_0) || defined(__MAC_12_0) || defined(__MAC_13_0) || defined(__MAC_14_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__IPHONE_17_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) || defined(__TVOS_17_0) - -#define _NSGL_PRIVATE_DEF_STR(type, symbol) \ - _NSGL_EXTERN type const NS##symbol _NSGL_PRIVATE_IMPORT; \ - type const NS::symbol = (nullptr != &NS##symbol) ? NS##symbol : nullptr - -#define _NSGL_PRIVATE_DEF_CONST(type, symbol) \ - _NSGL_EXTERN type const NS##symbol _NSGL_PRIVATE_IMPORT; \ - type const NS::symbol = (nullptr != &NS##symbol) ? NS##symbol : nullptr - -#define _NSGL_PRIVATE_DEF_WEAK_CONST(type, symbol) \ - _NSGL_EXTERN type const NS##symbol; \ - type const NS::symbol = Private::LoadSymbol("NS" #symbol) - -#else - -#define _NSGL_PRIVATE_DEF_STR(type, symbol) \ - _NSGL_EXTERN type const NS##symbol; \ - type const NS::symbol = Private::LoadSymbol("NS" #symbol) - -#define _NSGL_PRIVATE_DEF_CONST(type, symbol) \ - _NSGL_EXTERN type const NS##symbol; \ - type const NS::symbol = Private::LoadSymbol("NS" #symbol) - -#define _NSGL_PRIVATE_DEF_WEAK_CONST(type, symbol) _NSGL_PRIVATE_DEF_CONST(type, symbol) - -#endif // defined(__MAC_10_16) || defined(__MAC_11_0) || defined(__MAC_12_0) || defined(__MAC_13_0) || defined(__MAC_14_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__IPHONE_17_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) || defined(__TVOS_17_0) - -#else - -#define _NSGL_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol -#define _NSGL_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol -#define _NSGL_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor -#define _NSGL_PRIVATE_DEF_STR(type, symbol) extern type const NS::symbol -#define _NSGL_PRIVATE_DEF_CONST(type, symbol) extern type const NS::symbol -#define _NSGL_PRIVATE_DEF_WEAK_CONST(type, symbol) extern type const NS::symbol - -#endif // NSGL_PRIVATE_IMPLEMENTATION - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace NSGL -{ - namespace Private - { - namespace Class - { - _NSGL_PRIVATE_DEF_CLS(NSOpenGLPixelFormat); - _NSGL_PRIVATE_DEF_CLS(NSOpenGLContext); - _NSGL_PRIVATE_DEF_CLS(NSOpenGLPixelBuffer); - } // Class - } // Private -} // NSGL - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace NSGL -{ - namespace Private - { - namespace Protocol - { - _NSGL_PRIVATE_DEF_PRO(NSCoding); - _NSGL_PRIVATE_DEF_PRO(NSLocking); - } // Protocol - } // Private -} // NSGL - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -namespace NSGL -{ - namespace Private - { - namespace Selector - { - _NSGL_PRIVATE_DEF_SEL(initWithAttributes_, - "initWithAttributes:"); - _NSGL_PRIVATE_DEF_SEL(initWithData_, - "initWithData:"); - _NSGL_PRIVATE_DEF_SEL(attributes, - "attributes"); - _NSGL_PRIVATE_DEF_SEL(getValues_forAttribute_forVirtualScreen_, - "getValues:forAttribute:forVirtualScreen:"); - _NSGL_PRIVATE_DEF_SEL(numberOfVirtualScreens, - "numberOfVirtualScreens"); - _NSGL_PRIVATE_DEF_SEL(CGLPixelFormatObj, - "CGLPixelFormatObj"); - _NSGL_PRIVATE_DEF_SEL(initWithFormat_shareContext_, - "initWithFormat:shareContext:"); - _NSGL_PRIVATE_DEF_SEL(pixelFormat, - "pixelFormat"); - _NSGL_PRIVATE_DEF_SEL(setOffScreen_width_height_rowbytes_, - "setOffScreen:width:height:rowbytes:"); - _NSGL_PRIVATE_DEF_SEL(clearDrawable, - "clearDrawable"); - _NSGL_PRIVATE_DEF_SEL(update, - "update"); - _NSGL_PRIVATE_DEF_SEL(flushBuffer, - "flushBuffer"); - _NSGL_PRIVATE_DEF_SEL(makeCurrentContext, - "makeCurrentContext"); - _NSGL_PRIVATE_DEF_SEL(clearCurrentContext, - "clearCurrentContext"); - _NSGL_PRIVATE_DEF_SEL(currentContext, - "currentContext"); - _NSGL_PRIVATE_DEF_SEL(setFullScreen, - "setFullScreen"); - _NSGL_PRIVATE_DEF_SEL(clearFullScreen, - "clearFullScreen"); - _NSGL_PRIVATE_DEF_SEL(setValues_forParameter_, - "setValues:forParameter:"); - _NSGL_PRIVATE_DEF_SEL(getValues_forParameter_, - "getValues:forParameter:"); - _NSGL_PRIVATE_DEF_SEL(currentVirtualScreen, - "currentVirtualScreen"); - _NSGL_PRIVATE_DEF_SEL(CGLContextObj, - "CGLContextObj"); - } // Class - } // Private -} // NSGL - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/OpenGL/OpenGL.hpp b/Sources/Apple/include/OpenGL/OpenGL.hpp deleted file mode 100644 index 3b17a5e1..00000000 --- a/Sources/Apple/include/OpenGL/OpenGL.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* ---------------------------------------------------------------- - * :: : M E T A V E R S E : :: - * ---------------------------------------------------------------- - * This software is Licensed under the terms of the Apache License, - * version 2.0 (the "Apache License") with the following additional - * modification; you may not use this file except within compliance - * of the Apache License and the following modification made to it. - * Section 6. Trademarks. is deleted and replaced with: - * - * Trademarks. This License does not grant permission to use any of - * its trade names, trademarks, service marks, or the product names - * of this Licensor or its affiliates, except as required to comply - * with Section 4(c.) of this License, and to reproduce the content - * of the NOTICE file. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an - * implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the Apache License for more details. - * - * You should have received a copy for this software license of the - * Apache License along with this program; or, if not, please write - * to the Free Software Foundation Inc., with the following address - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) 2024 Wabi Foundation. All Rights Reserved. - * ---------------------------------------------------------------- - * . x x x . o o o . x x x . : : : . o x o . : : : . - * ---------------------------------------------------------------- */ - -#pragma once - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- - -#include "NSGLDefines.hpp" -#include "NSGLPrivate.hpp" -#include "NSGLPixelFormat.hpp" -#include "NSGLContext.hpp" - -//------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Sources/Apple/include/QuartzCore/CADefines.hpp b/Sources/Apple/include/QuartzCore/CADefines.hpp deleted file mode 100644 index 83f3d8fc..00000000 --- a/Sources/Apple/include/QuartzCore/CADefines.hpp +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/QuartzCore/CAMetalDrawable.hpp b/Sources/Apple/include/QuartzCore/CAMetalDrawable.hpp deleted file mode 100644 index 99a3872a..00000000 --- a/Sources/Apple/include/QuartzCore/CAMetalDrawable.hpp +++ /dev/null @@ -1,57 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/QuartzCore/CAMetalLayer.hpp b/Sources/Apple/include/QuartzCore/CAMetalLayer.hpp deleted file mode 100644 index 904e2188..00000000 --- a/Sources/Apple/include/QuartzCore/CAMetalLayer.hpp +++ /dev/null @@ -1,131 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/QuartzCore/CAPrivate.hpp b/Sources/Apple/include/QuartzCore/CAPrivate.hpp deleted file mode 100644 index 701ee082..00000000 --- a/Sources/Apple/include/QuartzCore/CAPrivate.hpp +++ /dev/null @@ -1,132 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/Apple/include/QuartzCore/QuartzCore.hpp b/Sources/Apple/include/QuartzCore/QuartzCore.hpp deleted file mode 100644 index beb57b61..00000000 --- a/Sources/Apple/include/QuartzCore/QuartzCore.hpp +++ /dev/null @@ -1,28 +0,0 @@ -//------------------------------------------------------------------------------------------------------------------------------------------------------------- -// -// 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/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.cpp b/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm similarity index 65% rename from Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.cpp rename to Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm index e74207cc..6fb1b402 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.cpp +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm @@ -16,21 +16,21 @@ MATERIALX_NAMESPACE_BEGIN // MetalFramebufferPtr -MetalFramebuffer::create(MTL::Device *device, unsigned int width, +MetalFramebuffer::create(id device, unsigned int width, unsigned int height, unsigned channelCount, - Image::BaseType baseType, MTL::Texture *colorTexture, - bool encodeSrgb, MTL::PixelFormat pixelFormat) { + Image::BaseType baseType, MTLTexture *colorTexture, + bool encodeSrgb, MTLPixelFormat pixelFormat) { return MetalFramebufferPtr( new MetalFramebuffer(device, width, height, channelCount, baseType, colorTexture, encodeSrgb, pixelFormat)); } -MetalFramebuffer::MetalFramebuffer(MTL::Device *device, unsigned int width, +MetalFramebuffer::MetalFramebuffer(id device, unsigned int width, unsigned int height, unsigned int channelCount, Image::BaseType baseType, - MTL::Texture *colorTexture, bool encodeSrgb, - MTL::PixelFormat pixelFormat) + MTLTexture *colorTexture, bool encodeSrgb, + MTLPixelFormat pixelFormat) : _width(0), _height(0), _channelCount(channelCount), _baseType(baseType), _encodeSrgb(encodeSrgb), _device(device), _colorTexture(colorTexture), _depthTexture(0) { @@ -46,24 +46,24 @@ MetalFramebuffer::~MetalFramebuffer() { } void MetalFramebuffer::resize(unsigned int width, unsigned int height, - bool forceRecreate, MTL::PixelFormat pixelFormat, - MTL::Texture *extColorTexture) { + bool forceRecreate, MTLPixelFormat pixelFormat, + MTLTexture *extColorTexture) { if (width * height <= 0) { return; } if (width != _width || _height != height || forceRecreate) { // Convert texture format to Metal - MTL::DataType dataType; - if (pixelFormat == MTL::PixelFormatInvalid) + MTLDataType dataType; + if (pixelFormat == MTLPixelFormatInvalid) MetalTextureHandler::mapTextureFormatToMetal( _baseType, _channelCount, _encodeSrgb, dataType, pixelFormat); - MTL::TextureDescriptor *texDescriptor = - MTL::TextureDescriptor::texture2DDescriptor(pixelFormat, width, height, + MTLTextureDescriptor *texDescriptor = + MTLTextureDescriptor::texture2DDescriptor(pixelFormat, width, height, NO); - texDescriptor->setStorageMode(MTL::StorageModePrivate); - texDescriptor->setUsage(MTL::TextureUsageRenderTarget | - MTL::TextureUsageShaderRead); + texDescriptor->setStorageMode(MTLStorageModePrivate); + texDescriptor->setUsage(MTLTextureUsageRenderTarget | + MTLTextureUsageShaderRead); if (extColorTexture == nil) { _colorTexture = _device->newTexture(texDescriptor); @@ -73,8 +73,8 @@ void MetalFramebuffer::resize(unsigned int width, unsigned int height, _colorTextureOwned = false; } - texDescriptor->setPixelFormat(MTL::PixelFormatDepth32Float); - texDescriptor->setUsage(MTL::TextureUsageRenderTarget); + texDescriptor->setPixelFormat(MTLPixelFormatDepth32Float); + texDescriptor->setUsage(MTLTextureUsageRenderTarget); _depthTexture = _device->newTexture(texDescriptor); _width = width; @@ -82,17 +82,17 @@ void MetalFramebuffer::resize(unsigned int width, unsigned int height, } } -void MetalFramebuffer::bind(MTL::RenderPassDescriptor *renderpassDesc) { +void MetalFramebuffer::bind(MTLRenderPassDescriptor *renderpassDesc) { renderpassDesc->colorAttachments()->object(0)->setTexture(getColorTexture()); renderpassDesc->colorAttachments()->object(0)->setLoadAction( - MTL::LoadActionClear); + MTLLoadActionClear); renderpassDesc->colorAttachments()->object(0)->setStoreAction( - MTL::StoreActionStore); + MTLStoreActionStore); renderpassDesc->depthAttachment()->setTexture(getDepthTexture()); renderpassDesc->depthAttachment()->setClearDepth(1.0); - renderpassDesc->depthAttachment()->setLoadAction(MTL::LoadActionClear); - renderpassDesc->depthAttachment()->setStoreAction(MTL::StoreActionStore); + renderpassDesc->depthAttachment()->setLoadAction(MTLLoadActionClear); + renderpassDesc->depthAttachment()->setStoreAction(MTLStoreActionStore); renderpassDesc->setStencilAttachment(nil); renderpassDesc->setRenderTargetWidth(_width); @@ -101,7 +101,7 @@ void MetalFramebuffer::bind(MTL::RenderPassDescriptor *renderpassDesc) { void MetalFramebuffer::unbind() {} -ImagePtr MetalFramebuffer::getColorImage(MTL::CommandQueue *cmdQueue, +ImagePtr MetalFramebuffer::getColorImage(MTLCommandQueue *cmdQueue, ImagePtr image) { if (!image) { image = Image::create(_width, _height, _channelCount, _baseType); @@ -116,16 +116,16 @@ ImagePtr MetalFramebuffer::getColorImage(MTL::CommandQueue *cmdQueue, MetalTextureHandler::getTextureBaseTypeSize(_baseType); size_t bytesPerImage = _height * bytesPerRow; - MTL::Buffer *buffer = - _device->newBuffer(bytesPerImage, MTL::ResourceStorageModeShared); + MTLBuffer *buffer = + _device->newBuffer(bytesPerImage, MTLResourceStorageModeShared); - MTL::CommandBuffer *cmdBuffer = cmdQueue->commandBuffer(); + MTLCommandBuffer *cmdBuffer = cmdQueue->commandBuffer(); - MTL::BlitCommandEncoder *blitCmdEncoder = cmdBuffer->blitCommandEncoder(); + MTLBlitCommandEncoder *blitCmdEncoder = cmdBuffer->blitCommandEncoder(); blitCmdEncoder->copyFromTexture( - _colorTexture, 0, 0, MTL::Origin::Make(0, 0, 0), - MTL::Size::Make(_width, _height, 1), buffer, 0, bytesPerRow, - bytesPerImage, MTL::BlitOptionNone); + _colorTexture, 0, 0, MTLOrigin::Make(0, 0, 0), + MTLSize::Make(_width, _height, 1), buffer, 0, bytesPerRow, + bytesPerImage, MTLBlitOptionNone); blitCmdEncoder->endEncoding(); @@ -135,7 +135,7 @@ ImagePtr MetalFramebuffer::getColorImage(MTL::CommandQueue *cmdQueue, std::vector imageData(bytesPerImage); memcpy(imageData.data(), buffer->contents(), bytesPerImage); - if (_colorTexture->pixelFormat() == MTL::PixelFormatBGRA8Unorm) { + if (_colorTexture->pixelFormat() == MTLPixelFormatBGRA8Unorm) { for (unsigned int j = 0; j < _height; ++j) { unsigned int rawStart = j * (_width * _channelCount); for (unsigned int i = 0; i < _width; ++i) { diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.cpp b/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm similarity index 78% rename from Sources/MaterialX/source/MaterialXRenderMsl/MetalState.cpp rename to Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm index d322c60e..a6dd869f 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.cpp +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm @@ -4,8 +4,8 @@ // #include -#include -#include +#import +#import #include @@ -13,48 +13,48 @@ std::unique_ptr MetalState::singleton = nullptr; MetalState::MetalState() {} -void MetalState::initialize(MTL::Device *mtlDevice, - MTL::CommandQueue *mtlCmdQueue) { +void MetalState::initialize(id mtlDevice, + MTLCommandQueue *mtlCmdQueue) { device = mtlDevice; cmdQueue = mtlCmdQueue; #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - supportsTiledPipeline = device->supportsFamily(MTL::GPUFamilyApple4); + supportsTiledPipeline = device->supportsFamily(MTLGPUFamilyApple4); #else supportsTiledPipeline = false; #endif - MTL::DepthStencilDescriptor *depthStencilDesc = - MTL::DepthStencilDescriptor::alloc()->init(); + MTLDepthStencilDescriptor *depthStencilDesc = + MTLDepthStencilDescriptor::alloc()->init(); depthStencilDesc->setDepthWriteEnabled(true); - depthStencilDesc->setDepthCompareFunction(MTL::CompareFunctionLess); + depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionLess); opaqueDepthStencilState = device->newDepthStencilState(depthStencilDesc); depthStencilDesc->setDepthWriteEnabled(false); - depthStencilDesc->setDepthCompareFunction(MTL::CompareFunctionLess); + depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionLess); transparentDepthStencilState = device->newDepthStencilState(depthStencilDesc); depthStencilDesc->setDepthWriteEnabled(true); - depthStencilDesc->setDepthCompareFunction(MTL::CompareFunctionAlways); + depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionAlways); envMapDepthStencilState = device->newDepthStencilState(depthStencilDesc); initLinearToSRGBKernel(); } void MetalState::initLinearToSRGBKernel() { - NS::Error *error = nil; - MTL::CompileOptions *options = MTL::CompileOptions::alloc()->init(); + NSError *error = nil; + MTLCompileOptions *options = MTLCompileOptions::alloc()->init(); #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - options->setLanguageVersion(MTL::LanguageVersion2_3); + options->setLanguageVersion(MTLLanguageVersion2_3); #else - options->setLanguageVersion(MTL::LanguageVersion2_0); + options->setLanguageVersion(MTLLanguageVersion2_0); #endif // defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) options->setFastMathEnabled(true); #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) bool useTiledPipeline = supportsTiledPipeline; if (useTiledPipeline) { - NS::String *linearToSRGB_kernel = NS::String::string( + NSString *linearToSRGB_kernel = NSString::string( "#include \n" "#include \n" "\n" @@ -93,16 +93,16 @@ void MetalState::initLinearToSRGBKernel() { " imageBlock.write(srgbValue, tid);\n" "};\n", NS::UTF8StringEncoding); - MTL::Library *library = + MTLLibrary *library = device->newLibrary(linearToSRGB_kernel, options, &error); - MTL::Function *function = library->newFunction( - NS::String::string("LinearToSRGB_kernel", NS::UTF8StringEncoding)); + MTLFunction *function = library->newFunction( + NSString::string("LinearToSRGB_kernel", NS::UTF8StringEncoding)); - MTL::TileRenderPipelineDescriptor *renderPipelineDescriptor = - MTL::TileRenderPipelineDescriptor::alloc()->init(); + MTLTileRenderPipelineDescriptor *renderPipelineDescriptor = + MTLTileRenderPipelineDescriptor::alloc()->init(); renderPipelineDescriptor->setRasterSampleCount(1); renderPipelineDescriptor->colorAttachments()->object(0)->setPixelFormat( - MTL::PixelFormatBGRA8Unorm); + MTLPixelFormatBGRA8Unorm); renderPipelineDescriptor->setTileFunction(function); linearToSRGB_pso = device->newRenderPipelineState(renderPipelineDescriptor, 0, nil, &error); @@ -111,7 +111,7 @@ void MetalState::initLinearToSRGBKernel() { useTiledPipeline = false; #endif if (!useTiledPipeline) { - NS::String *linearToSRGB_kernel = NS::String::string( + NSString *linearToSRGB_kernel = NSString::string( "#include \n" "#include \n" " \n" @@ -160,46 +160,46 @@ void MetalState::initLinearToSRGBKernel() { "} \n", NS::UTF8StringEncoding); - MTL::Library *library = + MTLLibrary *library = device->newLibrary(linearToSRGB_kernel, options, &error); - MTL::Function *vertexfunction = library->newFunction( - NS::String::string("VertexMain", NS::UTF8StringEncoding)); - MTL::Function *Fragmentfunction = library->newFunction( - NS::String::string("FragmentMain", NS::UTF8StringEncoding)); + MTLFunction *vertexfunction = library->newFunction( + NSString::string("VertexMain", NS::UTF8StringEncoding)); + MTLFunction *Fragmentfunction = library->newFunction( + NSString::string("FragmentMain", NS::UTF8StringEncoding)); - MTL::RenderPipelineDescriptor *renderPipelineDesc = - MTL::RenderPipelineDescriptor::alloc()->init(); + MTLRenderPipelineDescriptor *renderPipelineDesc = + MTLRenderPipelineDescriptor::alloc()->init(); renderPipelineDesc->setVertexFunction(vertexfunction); renderPipelineDesc->setFragmentFunction(Fragmentfunction); renderPipelineDesc->colorAttachments()->object(0)->setPixelFormat( - MTL::PixelFormatBGRA8Unorm); + MTLPixelFormatBGRA8Unorm); renderPipelineDesc->setDepthAttachmentPixelFormat( - MTL::PixelFormatDepth32Float); + MTLPixelFormatDepth32Float); linearToSRGB_pso = device->newRenderPipelineState(renderPipelineDesc, &error); } } void MetalState::triggerProgrammaticCapture() { - MTL::CaptureManager *captureManager = - MTL::CaptureManager::sharedCaptureManager(); - MTL::CaptureDescriptor *captureDescriptor = - MTL::CaptureDescriptor::alloc()->init(); + MTLCaptureManager *captureManager = + MTLCaptureManager::sharedCaptureManager(); + MTLCaptureDescriptor *captureDescriptor = + MTLCaptureDescriptor::alloc()->init(); captureDescriptor->setCaptureObject(device); - NS::Error *error = nil; + NSError *error = nil; if (!captureManager->startCapture(captureDescriptor, &error)) { #if WITH_APPLE_NSLOG - NS::Log(NS::String::string("Failed to start capture, error %@", error)); + NS::Log(NSString::string("Failed to start capture, error %@", error)); #endif /* WITH_APPLE_NSLOG */ } } void MetalState::stopProgrammaticCapture() { - MTL::CaptureManager *captureManager = - MTL::CaptureManager::sharedCaptureManager(); + MTLCaptureManager *captureManager = + MTLCaptureManager::sharedCaptureManager(); captureManager->stopCapture(); } @@ -208,7 +208,7 @@ void MetalState::beginCommandBuffer() { inFlightCommandBuffers++; } -void MetalState::beginEncoder(MTL::RenderPassDescriptor *renderpassDesc) { +void MetalState::beginEncoder(MTLRenderPassDescriptor *renderpassDesc) { renderCmdEncoder = cmdBuffer->renderCommandEncoder(renderpassDesc); } @@ -216,7 +216,7 @@ void MetalState::endEncoder() { renderCmdEncoder->endEncoding(); } void MetalState::endCommandBuffer() { endEncoder(); - cmdBuffer->addCompletedHandler([&](MTL::CommandBuffer *buffer) -> void { + cmdBuffer->addCompletedHandler([&](MTLCommandBuffer *buffer) -> void { inFlightCommandBuffers--; inFlightCV.notify_one(); }); diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.cpp b/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm similarity index 70% rename from Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.cpp rename to Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm index 46fdbb93..2b5f9b3c 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.cpp +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm @@ -11,7 +11,7 @@ MATERIALX_NAMESPACE_BEGIN -MetalTextureHandler::MetalTextureHandler(MTL::Device *device, +MetalTextureHandler::MetalTextureHandler(id device, ImageLoaderPtr imageLoader) : ImageHandler(imageLoader) { int maxTextureUnits = 31; @@ -33,12 +33,12 @@ bool MetalTextureHandler::bindImage( return true; } -MTL::SamplerState *MetalTextureHandler::getSamplerState( +MTLSamplerState *MetalTextureHandler::getSamplerState( const ImageSamplingProperties &samplingProperties) { if (_imageSamplerStateMap.find(samplingProperties) == _imageSamplerStateMap.end()) { - MTL::SamplerDescriptor *samplerDesc = - MTL::SamplerDescriptor::alloc()->init(); + MTLSamplerDescriptor *samplerDesc = + MTLSamplerDescriptor::alloc()->init(); samplerDesc->setSAddressMode( mapAddressModeToMetal(samplingProperties.uaddressMode)); samplerDesc->setRAddressMode( @@ -46,15 +46,15 @@ MTL::SamplerState *MetalTextureHandler::getSamplerState( samplerDesc->setTAddressMode( mapAddressModeToMetal(samplingProperties.vaddressMode)); samplerDesc->setBorderColor(samplingProperties.defaultColor[0] == 0 - ? MTL::SamplerBorderColorOpaqueBlack - : MTL::SamplerBorderColorOpaqueWhite); - MTL::SamplerMinMagFilter minmagFilter; - MTL::SamplerMipFilter mipFilter; + ? MTLSamplerBorderColorOpaqueBlack + : MTLSamplerBorderColorOpaqueWhite); + MTLSamplerMinMagFilter minmagFilter; + MTLSamplerMipFilter mipFilter; mapFilterTypeToMetal(samplingProperties.filterType, samplingProperties.enableMipmaps, minmagFilter, mipFilter); // Magnification filters are more restrictive than minification - samplerDesc->setMagFilter(MTL::SamplerMinMagFilterLinear); + samplerDesc->setMagFilter(MTLSamplerMinMagFilterLinear); samplerDesc->setMinFilter(minmagFilter); samplerDesc->setMipFilter(mipFilter); samplerDesc->setMaxAnisotropy(16); @@ -66,7 +66,7 @@ MTL::SamplerState *MetalTextureHandler::getSamplerState( return _imageSamplerStateMap[samplingProperties]; } -bool MetalTextureHandler::bindImage(MTL::RenderCommandEncoder *renderCmdEncoder, +bool MetalTextureHandler::bindImage(MTLRenderCommandEncoder *renderCmdEncoder, int textureUnit, ImagePtr image) { // Create renderer resources if needed. if (image->getResourceId() == MslProgram::UNDEFINED_METAL_RESOURCE_ID) { @@ -86,7 +86,7 @@ bool MetalTextureHandler::bindImage(MTL::RenderCommandEncoder *renderCmdEncoder, return true; } -MTL::Texture *MetalTextureHandler::getAssociatedMetalTexture(ImagePtr image) { +MTLTexture *MetalTextureHandler::getAssociatedMetalTexture(ImagePtr image) { if (image) { auto tex = _metalTextureMap.find(image->getResourceId()); if (tex != _metalTextureMap.end()) @@ -95,7 +95,7 @@ MTL::Texture *MetalTextureHandler::getAssociatedMetalTexture(ImagePtr image) { return nil; } -MTL::Texture * +MTLTexture * MetalTextureHandler::getMTLTextureForImage(unsigned int index) const { auto imageInfo = _imageBindingInfo.find(index); if (imageInfo != _imageBindingInfo.end()) { @@ -111,7 +111,7 @@ MetalTextureHandler::getMTLTextureForImage(unsigned int index) const { return nil; } -MTL::SamplerState * +MTLSamplerState * MetalTextureHandler::getMTLSamplerStateForImage(unsigned int index) { auto imageInfo = _imageBindingInfo.find(index); if (imageInfo != _imageBindingInfo.end()) { @@ -134,10 +134,10 @@ bool MetalTextureHandler::unbindImage(ImagePtr image) { bool MetalTextureHandler::createRenderResources(ImagePtr image, bool generateMipMaps) { - MTL::Texture *texture = nil; + MTLTexture *texture = nil; - MTL::PixelFormat pixelFormat; - MTL::DataType dataType; + MTLPixelFormat pixelFormat; + MTLDataType dataType; if (image->getResourceId() == MslProgram::UNDEFINED_METAL_RESOURCE_ID) { static unsigned int resourceId = 0; @@ -146,26 +146,26 @@ bool MetalTextureHandler::createRenderResources(ImagePtr image, mapTextureFormatToMetal(image->getBaseType(), image->getChannelCount(), false, dataType, pixelFormat); - MTL::TextureDescriptor *texDesc = MTL::TextureDescriptor::alloc()->init(); - texDesc->setTextureType(MTL::TextureType2D); + MTLTextureDescriptor *texDesc = MTLTextureDescriptor::alloc()->init(); + texDesc->setTextureType(MTLTextureType2D); texDesc->setWidth(image->getWidth()); texDesc->setHeight(image->getHeight()); texDesc->setMipmapLevelCount(generateMipMaps ? image->getMaxMipCount() : 1); - texDesc->setUsage(MTL::TextureUsageShaderRead | + texDesc->setUsage(MTLTextureUsageShaderRead | // For now, we set generate mip maps flag off, // when we want to use the texture as render target - (!generateMipMaps ? MTL::TextureUsageRenderTarget : 0)); - texDesc->setResourceOptions(MTL::ResourceStorageModePrivate); + (!generateMipMaps ? MTLTextureUsageRenderTarget : 0)); + texDesc->setResourceOptions(MTLResourceStorageModePrivate); texDesc->setPixelFormat(pixelFormat); if (generateMipMaps) { if (image->getChannelCount() == 1) { - texDesc->setSwizzle(MTL::TextureSwizzleChannels{ - MTL::TextureSwizzleRed, MTL::TextureSwizzleRed, - MTL::TextureSwizzleRed, MTL::TextureSwizzleRed}); + texDesc->setSwizzle(MTLTextureSwizzleChannels{ + MTLTextureSwizzleRed, MTLTextureSwizzleRed, + MTLTextureSwizzleRed, MTLTextureSwizzleRed}); } else if (image->getChannelCount() == 2) { - texDesc->setSwizzle(MTL::TextureSwizzleChannels{ - MTL::TextureSwizzleRed, MTL::TextureSwizzleGreen, - MTL::TextureSwizzleRed, MTL::TextureSwizzleGreen}); + texDesc->setSwizzle(MTLTextureSwizzleChannels{ + MTLTextureSwizzleRed, MTLTextureSwizzleGreen, + MTLTextureSwizzleRed, MTLTextureSwizzleGreen}); } } texture = _device->newTexture(texDesc); @@ -178,10 +178,10 @@ bool MetalTextureHandler::createRenderResources(ImagePtr image, texture = _metalTextureMap[image->getResourceId()]; } - MTL::CommandQueue *cmdQueue = _device->newCommandQueue(); - MTL::CommandBuffer *cmdBuffer = cmdQueue->commandBuffer(); + MTLCommandQueue *cmdQueue = _device->newCommandQueue(); + MTLCommandBuffer *cmdBuffer = cmdQueue->commandBuffer(); - MTL::BlitCommandEncoder *blitCmdEncoder = cmdBuffer->blitCommandEncoder(); + MTLBlitCommandEncoder *blitCmdEncoder = cmdBuffer->blitCommandEncoder(); NS::UInteger channelCount = image->getChannelCount(); @@ -193,10 +193,10 @@ bool MetalTextureHandler::createRenderResources(ImagePtr image, std::vector rearrangedDataC; void *imageData = image->getResourceBuffer(); - if ((pixelFormat == MTL::PixelFormatRGBA32Float || - pixelFormat == MTL::PixelFormatRGBA8Unorm) && + if ((pixelFormat == MTLPixelFormatRGBA32Float || + pixelFormat == MTLPixelFormatRGBA8Unorm) && channelCount == 3) { - bool isFloat = pixelFormat == MTL::PixelFormatRGBA32Float; + bool isFloat = pixelFormat == MTLPixelFormatRGBA32Float; sourceBytesPerRow = sourceBytesPerRow / 3 * 4; sourceBytesPerImage = sourceBytesPerImage / 3 * 4; @@ -232,14 +232,14 @@ bool MetalTextureHandler::createRenderResources(ImagePtr image, channelCount = 4; } - MTL::Buffer *buffer = nil; + MTLBuffer *buffer = nil; if (imageData) { buffer = _device->newBuffer(imageData, sourceBytesPerImage, - MTL::StorageModeShared); + MTLStorageModeShared); blitCmdEncoder->copyFromBuffer( buffer, 0, sourceBytesPerRow, sourceBytesPerImage, - MTL::Size::Make(image->getWidth(), image->getHeight(), 1), texture, 0, - 0, MTL::Origin::Make(0, 0, 0)); + MTLSize::Make(image->getWidth(), image->getHeight(), 1), texture, 0, + 0, MTLOrigin::Make(0, 0, 0)); } if (generateMipMaps && image->getMaxMipCount() > 1) @@ -283,23 +283,23 @@ int MetalTextureHandler::getBoundTextureLocation(unsigned int resourceId) { return -1; } -MTL::SamplerAddressMode MetalTextureHandler::mapAddressModeToMetal( +MTLSamplerAddressMode MetalTextureHandler::mapAddressModeToMetal( ImageSamplingProperties::AddressMode addressModeEnum) { - const vector addressModes{ + const vector addressModes{ // Constant color. Use clamp to border // with border color to achieve this - MTL::SamplerAddressModeClampToBorderColor, + MTLSamplerAddressModeClampToBorderColor, // Clamp - MTL::SamplerAddressModeClampToEdge, + MTLSamplerAddressModeClampToEdge, // Repeat - MTL::SamplerAddressModeRepeat, + MTLSamplerAddressModeRepeat, // Mirror - MTL::SamplerAddressModeMirrorRepeat}; + MTLSamplerAddressModeMirrorRepeat}; - MTL::SamplerAddressMode addressMode = MTL::SamplerAddressModeRepeat; + MTLSamplerAddressMode addressMode = MTLSamplerAddressModeRepeat; if (addressModeEnum != ImageSamplingProperties::AddressMode::UNSPECIFIED) { addressMode = addressModes[static_cast(addressModeEnum)]; } @@ -308,53 +308,53 @@ MTL::SamplerAddressMode MetalTextureHandler::mapAddressModeToMetal( void MetalTextureHandler::mapFilterTypeToMetal( ImageSamplingProperties::FilterType filterTypeEnum, bool enableMipmaps, - MTL::SamplerMinMagFilter &minMagFilter, MTL::SamplerMipFilter &mipFilter) { + MTLSamplerMinMagFilter &minMagFilter, MTLSamplerMipFilter &mipFilter) { if (enableMipmaps) { if (filterTypeEnum == ImageSamplingProperties::FilterType::LINEAR || filterTypeEnum == ImageSamplingProperties::FilterType::CUBIC || filterTypeEnum == ImageSamplingProperties::FilterType::UNSPECIFIED) { - minMagFilter = MTL::SamplerMinMagFilterLinear; - mipFilter = MTL::SamplerMipFilterLinear; + minMagFilter = MTLSamplerMinMagFilterLinear; + mipFilter = MTLSamplerMipFilterLinear; } else { - minMagFilter = MTL::SamplerMinMagFilterNearest; - mipFilter = MTL::SamplerMipFilterNearest; + minMagFilter = MTLSamplerMinMagFilterNearest; + mipFilter = MTLSamplerMipFilterNearest; } } else { if (filterTypeEnum == ImageSamplingProperties::FilterType::LINEAR || filterTypeEnum == ImageSamplingProperties::FilterType::CUBIC || filterTypeEnum == ImageSamplingProperties::FilterType::UNSPECIFIED) { - minMagFilter = MTL::SamplerMinMagFilterLinear; - mipFilter = MTL::SamplerMipFilterNotMipmapped; + minMagFilter = MTLSamplerMinMagFilterLinear; + mipFilter = MTLSamplerMipFilterNotMipmapped; } else { - minMagFilter = MTL::SamplerMinMagFilterNearest; - mipFilter = MTL::SamplerMipFilterNotMipmapped; + minMagFilter = MTLSamplerMinMagFilterNearest; + mipFilter = MTLSamplerMipFilterNotMipmapped; } } } void MetalTextureHandler::mapTextureFormatToMetal( Image::BaseType baseType, unsigned int channelCount, bool srgb, - MTL::DataType &dataType, MTL::PixelFormat &pixelFormat) { + MTLDataType &dataType, MTLPixelFormat &pixelFormat) { if (baseType == Image::BaseType::UINT8) { - dataType = MTL::DataTypeChar; + dataType = MTLDataTypeChar; switch (channelCount) { case 4: pixelFormat = - srgb ? MTL::PixelFormatRGBA8Unorm_sRGB : MTL::PixelFormatRGBA8Unorm; - dataType = MTL::DataTypeChar4; + srgb ? MTLPixelFormatRGBA8Unorm_sRGB : MTLPixelFormatRGBA8Unorm; + dataType = MTLDataTypeChar4; break; case 3: pixelFormat = - srgb ? MTL::PixelFormatRGBA8Unorm_sRGB : MTL::PixelFormatRGBA8Unorm; - dataType = MTL::DataTypeChar3; + srgb ? MTLPixelFormatRGBA8Unorm_sRGB : MTLPixelFormatRGBA8Unorm; + dataType = MTLDataTypeChar3; break; case 2: - pixelFormat = MTL::PixelFormatRG8Unorm; - dataType = MTL::DataTypeChar2; + pixelFormat = MTLPixelFormatRG8Unorm; + dataType = MTLDataTypeChar2; break; case 1: - pixelFormat = MTL::PixelFormatR8Unorm; - dataType = MTL::DataTypeChar; + pixelFormat = MTLPixelFormatR8Unorm; + dataType = MTLDataTypeChar; break; default: throw Exception("Unsupported channel count in mapTextureFormatToMetal"); @@ -362,20 +362,20 @@ void MetalTextureHandler::mapTextureFormatToMetal( } else if (baseType == Image::BaseType::UINT16) { switch (channelCount) { case 4: - pixelFormat = MTL::PixelFormatRGBA16Uint; - dataType = MTL::DataTypeShort4; + pixelFormat = MTLPixelFormatRGBA16Uint; + dataType = MTLDataTypeShort4; break; case 3: - pixelFormat = MTL::PixelFormatRGBA16Uint; - dataType = MTL::DataTypeShort3; + pixelFormat = MTLPixelFormatRGBA16Uint; + dataType = MTLDataTypeShort3; break; case 2: - pixelFormat = MTL::PixelFormatRG16Uint; - dataType = MTL::DataTypeShort2; + pixelFormat = MTLPixelFormatRG16Uint; + dataType = MTLDataTypeShort2; break; case 1: - pixelFormat = MTL::PixelFormatR16Uint; - dataType = MTL::DataTypeShort; + pixelFormat = MTLPixelFormatR16Uint; + dataType = MTLDataTypeShort; break; default: throw Exception("Unsupported channel count in mapTextureFormatToMetal"); @@ -383,20 +383,20 @@ void MetalTextureHandler::mapTextureFormatToMetal( } else if (baseType == Image::BaseType::HALF) { switch (channelCount) { case 4: - pixelFormat = MTL::PixelFormatRGBA16Float; - dataType = MTL::DataTypeHalf4; + pixelFormat = MTLPixelFormatRGBA16Float; + dataType = MTLDataTypeHalf4; break; case 3: - pixelFormat = MTL::PixelFormatRGBA16Float; - dataType = MTL::DataTypeHalf3; + pixelFormat = MTLPixelFormatRGBA16Float; + dataType = MTLDataTypeHalf3; break; case 2: - pixelFormat = MTL::PixelFormatRG16Float; - dataType = MTL::DataTypeHalf2; + pixelFormat = MTLPixelFormatRG16Float; + dataType = MTLDataTypeHalf2; break; case 1: - pixelFormat = MTL::PixelFormatR16Float; - dataType = MTL::DataTypeHalf; + pixelFormat = MTLPixelFormatR16Float; + dataType = MTLDataTypeHalf; break; default: throw Exception("Unsupported channel count in mapTextureFormatToMetal"); @@ -404,20 +404,20 @@ void MetalTextureHandler::mapTextureFormatToMetal( } else if (baseType == Image::BaseType::FLOAT) { switch (channelCount) { case 4: - pixelFormat = MTL::PixelFormatRGBA32Float; - dataType = MTL::DataTypeFloat4; + pixelFormat = MTLPixelFormatRGBA32Float; + dataType = MTLDataTypeFloat4; break; case 3: - pixelFormat = MTL::PixelFormatRGBA32Float; - dataType = MTL::DataTypeFloat3; + pixelFormat = MTLPixelFormatRGBA32Float; + dataType = MTLDataTypeFloat3; break; case 2: - pixelFormat = MTL::PixelFormatRG32Float; - dataType = MTL::DataTypeFloat2; + pixelFormat = MTLPixelFormatRG32Float; + dataType = MTLDataTypeFloat2; break; case 1: - pixelFormat = MTL::PixelFormatR32Float; - dataType = MTL::DataTypeFloat; + pixelFormat = MTLPixelFormatR32Float; + dataType = MTLDataTypeFloat; break; default: throw Exception("Unsupported channel count in mapTextureFormatToMetal"); diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.cpp b/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm similarity index 98% rename from Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.cpp rename to Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm index eed76c4f..9e097de1 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.cpp +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm @@ -234,8 +234,8 @@ void MslMaterial::drawPartition(MeshPartitionPtr part) const { MeshIndexBuffer &indexData = part->getIndices(); MTL(renderCmdEncoder) - ->drawIndexedPrimitives(MTL::PrimitiveTypeTriangle, indexData.size(), - MTL::IndexTypeUInt32, + ->drawIndexedPrimitives(MTLPrimitiveTypeTriangle, indexData.size(), + MTLIndexTypeUInt32, _glProgram->getIndexBuffer(part), 0); } diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.cpp b/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm similarity index 86% rename from Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.cpp rename to Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm index 6300b292..166f27a3 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.cpp +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm @@ -3,11 +3,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +// #import #include #include #include -#include +#import #include #include @@ -79,43 +79,43 @@ void MslProgram::clearStages() { clearInputLists(); } -MTL::VertexFormat GetMetalFormatFromMetalType(MTL::DataType type) { +MTLVertexFormat GetMetalFormatFromMetalType(MTLDataType type) { switch (type) { - case MTL::DataTypeFloat: - return MTL::VertexFormatFloat; - case MTL::DataTypeFloat2: - return MTL::VertexFormatFloat2; - case MTL::DataTypeFloat3: - return MTL::VertexFormatFloat3; - case MTL::DataTypeFloat4: - return MTL::VertexFormatFloat4; - case MTL::DataTypeInt: - return MTL::VertexFormatInt; - case MTL::DataTypeInt2: - return MTL::VertexFormatInt2; - case MTL::DataTypeInt3: - return MTL::VertexFormatInt3; - case MTL::DataTypeInt4: - return MTL::VertexFormatInt4; + case MTLDataTypeFloat: + return MTLVertexFormatFloat; + case MTLDataTypeFloat2: + return MTLVertexFormatFloat2; + case MTLDataTypeFloat3: + return MTLVertexFormatFloat3; + case MTLDataTypeFloat4: + return MTLVertexFormatFloat4; + case MTLDataTypeInt: + return MTLVertexFormatInt; + case MTLDataTypeInt2: + return MTLVertexFormatInt2; + case MTLDataTypeInt3: + return MTLVertexFormatInt3; + case MTLDataTypeInt4: + return MTLVertexFormatInt4; default: - return MTL::VertexFormatInvalid; + return MTLVertexFormatInvalid; } - return MTL::VertexFormatInt; + return MTLVertexFormatInt; } -int GetStrideOfMetalType(MTL::DataType type) { +int GetStrideOfMetalType(MTLDataType type) { switch (type) { - case MTL::DataTypeInt: - case MTL::DataTypeFloat: + case MTLDataTypeInt: + case MTLDataTypeFloat: return 1 * 4; - case MTL::DataTypeInt2: - case MTL::DataTypeFloat2: + case MTLDataTypeInt2: + case MTLDataTypeFloat2: return 2 * 4; - case MTL::DataTypeInt3: - case MTL::DataTypeFloat3: + case MTLDataTypeInt3: + case MTLDataTypeFloat3: return 3 * 4; - case MTL::DataTypeInt4: - case MTL::DataTypeFloat4: + case MTLDataTypeInt4: + case MTLDataTypeFloat4: return 4 * 4; default: return 0; @@ -124,12 +124,12 @@ int GetStrideOfMetalType(MTL::DataType type) { return 0; } -MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, - MetalFramebufferPtr framebuffer) { +MTLRenderPipelineState *MslProgram::build(id device, + MetalFramebufferPtr framebuffer) { StringVec errors; const string errorType("MSL program creation error."); - NS::Error *error = nil; + NSError *error = nil; reset(); @@ -142,16 +142,16 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, desiredStages++; } - MTL::CompileOptions *options = MTL::CompileOptions::alloc()->init(); + MTLCompileOptions *options = MTLCompileOptions::alloc()->init(); #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - options->setLanguageVersion(MTL::LanguageVersion2_3); + options->setLanguageVersion(MTLLanguageVersion2_3); #else - options->setLanguageVersion(MTL::LanguageVersion2_0); + options->setLanguageVersion(MTLLanguageVersion2_0); #endif // defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) options->setFastMathEnabled(true); // Create vertex shader - MTL::Function *vertexShaderId = nil; + MTLFunction *vertexShaderId = nil; { string &vertexShaderSource = _stages[Stage::VERTEX]; if (vertexShaderSource.length() < 1) { @@ -159,9 +159,9 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, return nil; } - NS::String *sourcCode = - NS::String::string(vertexShaderSource.c_str(), NS::UTF8StringEncoding); - MTL::Library *library = device->newLibrary(sourcCode, options, &error); + NSString *sourcCode = + NSString::string(vertexShaderSource.c_str(), NS::UTF8StringEncoding); + MTLLibrary *library = device->newLibrary(sourcCode, options, &error); if (library == nil) { errors.push_back("Error in compiling vertex shader:"); @@ -172,7 +172,7 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, } vertexShaderId = library->newFunction( - NS::String::string("VertexMain", NS::UTF8StringEncoding)); + NSString::string("VertexMain", NS::UTF8StringEncoding)); if (vertexShaderId) { stagesBuilt++; @@ -187,11 +187,11 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, } // Fragment shader compilation code - MTL::Function *fragmentShaderId = nil; + MTLFunction *fragmentShaderId = nil; { - NS::String *sourcCode = NS::String::string(fragmentShaderSource.c_str(), + NSString *sourcCode = NSString::string(fragmentShaderSource.c_str(), NS::UTF8StringEncoding); - MTL::Library *library = device->newLibrary(sourcCode, options, &error); + MTLLibrary *library = device->newLibrary(sourcCode, options, &error); if (!library) { errors.push_back("Error in compiling fragment shader:"); if (error) { @@ -204,7 +204,7 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, } fragmentShaderId = library->newFunction( - NS::String::string("FragmentMain", NS::UTF8StringEncoding)); + NSString::string("FragmentMain", NS::UTF8StringEncoding)); assert(fragmentShaderId); if (library) { @@ -214,37 +214,37 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, // Link stages to a programs if (stagesBuilt == desiredStages) { - MTL::RenderPipelineDescriptor *psoDesc = - MTL::RenderPipelineDescriptor::alloc()->init(); + MTLRenderPipelineDescriptor *psoDesc = + MTLRenderPipelineDescriptor::alloc()->init(); psoDesc->setVertexFunction(vertexShaderId); psoDesc->setFragmentFunction(fragmentShaderId); psoDesc->colorAttachments()->object(0)->setPixelFormat( framebuffer->getColorTexture()->pixelFormat()); - psoDesc->setDepthAttachmentPixelFormat(MTL::PixelFormatDepth32Float); + psoDesc->setDepthAttachmentPixelFormat(MTLPixelFormatDepth32Float); if (_shader->hasAttribute(HW::ATTR_TRANSPARENT)) { psoDesc->colorAttachments()->object(0)->setBlendingEnabled(YES); psoDesc->colorAttachments()->object(0)->setRgbBlendOperation( - MTL::BlendOperationAdd); + MTLBlendOperationAdd); psoDesc->colorAttachments()->object(0)->setAlphaBlendOperation( - MTL::BlendOperationAdd); + MTLBlendOperationAdd); psoDesc->colorAttachments()->object(0)->setSourceRGBBlendFactor( - MTL::BlendFactorSourceAlpha); + MTLBlendFactorSourceAlpha); psoDesc->colorAttachments()->object(0)->setSourceAlphaBlendFactor( - MTL::BlendFactorSourceAlpha); + MTLBlendFactorSourceAlpha); psoDesc->colorAttachments()->object(0)->setDestinationRGBBlendFactor( - MTL::BlendFactorOneMinusSourceAlpha); + MTLBlendFactorOneMinusSourceAlpha); psoDesc->colorAttachments()->object(0)->setDestinationAlphaBlendFactor( - MTL::BlendFactorOneMinusSourceAlpha); + MTLBlendFactorOneMinusSourceAlpha); _alphaBlendingEnabled = true; } - MTL::VertexDescriptor *vd = MTL::VertexDescriptor::alloc()->init(); + MTLVertexDescriptor *vd = MTLVertexDescriptor::alloc()->init(); for (int i = 0; i < vertexShaderId->vertexAttributes()->count(); ++i) { - MTL::VertexAttribute *vertexAttrib = - vertexShaderId->vertexAttributes()->object(i); + MTLVertexAttribute *vertexAttrib = + vertexShaderId->vertexAttributes()->object(i); vd->attributes()->object(i)->setBufferIndex(i); vd->attributes()->object(i)->setFormat( @@ -276,14 +276,14 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, vd->layouts()->object(i)->setStride( GetStrideOfMetalType(vertexAttrib->attributeType())); vd->layouts()->object(i)->setStepFunction( - MTL::VertexStepFunctionPerVertex); + MTLVertexStepFunctionPerVertex); } psoDesc->setVertexDescriptor(vd); _pso = device->newRenderPipelineState(psoDesc, - MTL::PipelineOptionArgumentInfo | - MTL::PipelineOptionBufferTypeInfo, + MTLPipelineOptionArgumentInfo | + MTLPipelineOptionBufferTypeInfo, &_psoReflection, &error); _pso->retain(); @@ -310,7 +310,7 @@ MTL::RenderPipelineState *MslProgram::build(MTL::Device *device, return _pso; } -bool MslProgram::bind(MTL::RenderCommandEncoder *renderCmdEncoder) { +bool MslProgram::bind(MTLRenderCommandEncoder *renderCmdEncoder) { if (_pso != nil) { renderCmdEncoder->setRenderPipelineState(_pso); return true; @@ -319,7 +319,7 @@ bool MslProgram::bind(MTL::RenderCommandEncoder *renderCmdEncoder) { } void MslProgram::prepareUsedResources( - MTL::RenderCommandEncoder *renderCmdEncoder, CameraPtr cam, + MTLRenderCommandEncoder *renderCmdEncoder, CameraPtr cam, GeometryHandlerPtr geometryHandler, ImageHandlerPtr imageHandler, LightHandlerPtr lightHandler) { // Bind the program to use @@ -342,7 +342,7 @@ void MslProgram::prepareUsedResources( bindUniformBuffers(renderCmdEncoder, lightHandler, cam); } -void MslProgram::bindAttribute(MTL::RenderCommandEncoder *renderCmdEncoder, +void MslProgram::bindAttribute(MTLRenderCommandEncoder *renderCmdEncoder, const MslProgram::InputMap &inputs, MeshPtr mesh) { const string errorType("MSL bind attribute error."); @@ -400,8 +400,8 @@ void MslProgram::bindAttribute(MTL::RenderCommandEncoder *renderCmdEncoder, } // Create a buffer based on attribute type. - MTL::Buffer *buffer = _device->newBuffer(bufferData, bufferSize, - MTL::ResourceStorageModeShared); + MTLBuffer *buffer = _device->newBuffer(bufferData, bufferSize, + MTLResourceStorageModeShared); _attributeBufferIds[input.first] = buffer; } @@ -421,14 +421,14 @@ void MslProgram::bindPartition(MeshPartitionPtr part) { if (_indexBufferIds.find(part) == _indexBufferIds.end()) { MeshIndexBuffer &indexData = part->getIndices(); size_t indexBufferSize = indexData.size(); - MTL::Buffer *indexBuffer = + MTLBuffer *indexBuffer = _device->newBuffer(&indexData[0], indexBufferSize * sizeof(uint32_t), - MTL::StorageModeShared); + MTLStorageModeShared); _indexBufferIds[part] = indexBuffer; } } -void MslProgram::bindMesh(MTL::RenderCommandEncoder *renderCmdEncoder, +void MslProgram::bindMesh(MTLRenderCommandEncoder *renderCmdEncoder, MeshPtr mesh) { StringVec errors; const string errorType("MSL geometry bind error."); @@ -506,7 +506,7 @@ void MslProgram::unbindGeometry() { _indexBufferIds.clear(); } -ImagePtr MslProgram::bindTexture(MTL::RenderCommandEncoder *renderCmdEncoder, +ImagePtr MslProgram::bindTexture(MTLRenderCommandEncoder *renderCmdEncoder, unsigned int uniformLocation, const FilePath &filePath, ImageSamplingProperties samplingProperties, @@ -519,7 +519,7 @@ ImagePtr MslProgram::bindTexture(MTL::RenderCommandEncoder *renderCmdEncoder, return bindTexture(renderCmdEncoder, uniformLocation, image, imageHandler); } -ImagePtr MslProgram::bindTexture(MTL::RenderCommandEncoder *renderCmdEncoder, +ImagePtr MslProgram::bindTexture(MTLRenderCommandEncoder *renderCmdEncoder, unsigned int uniformLocation, ImagePtr image, ImageHandlerPtr imageHandler) { // Acquire the image. @@ -544,7 +544,7 @@ MslProgram::findUniformValue(const string &uniformName, return nullptr; } -void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, +void MslProgram::bindTextures(MTLRenderCommandEncoder *renderCmdEncoder, LightHandlerPtr lightHandler, ImageHandlerPtr imageHandler) { const VariableBlock &publicUniforms = @@ -552,8 +552,8 @@ void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, for (NS::UInteger argIdx = 0; argIdx < _psoReflection->fragmentArguments()->count(); argIdx++) { if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTL::ArgumentTypeTexture) { + ->object(argIdx) + ->type() == MTLArgumentTypeTexture) { bool found = false; if (lightHandler) { @@ -563,7 +563,7 @@ void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, {HW::ENV_IRRADIANCE, lightHandler->getEnvIrradianceMap()}}; for (const auto &env : envLights) { std::string str(_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()); size_t loc = str.find(env.first); @@ -580,7 +580,7 @@ void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, ->bindImage(env.second, samplingProperties); bindTexture(renderCmdEncoder, (unsigned int)_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->index(), env.second, imageHandler); found = true; @@ -591,12 +591,12 @@ void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, if (!found) { ImagePtr image = nullptr; if (_explicitBoundImages.find(_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()) != _explicitBoundImages.end()) { image = _explicitBoundImages[_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()]; } @@ -604,7 +604,7 @@ void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, if (image && (image->getWidth() > 1 || image->getHeight() > 1)) { bindTexture(renderCmdEncoder, (unsigned int)_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->index(), image, imageHandler); found = true; @@ -613,7 +613,7 @@ void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, if (!found) { auto uniform = _uniformList.find(_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()); if (uniform != _uniformList.end()) { @@ -634,7 +634,7 @@ void MslProgram::bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, samplingProperties.enableMipmaps = _enableMipMapping; bindTexture(renderCmdEncoder, (unsigned int)_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->index(), fileName, samplingProperties, imageHandler); } @@ -863,43 +863,43 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { for (NS::UInteger argIdx = 0; argIdx < _psoReflection->vertexArguments()->count(); argIdx++) { if (_psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataType() == MTL::DataTypeStruct) { + ->object(argIdx) + ->bufferDataType() == MTLDataTypeStruct) { for (NS::UInteger memberIdx = 0; memberIdx < _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->structType() ->members() ->count(); memberIdx++) { InputPtr inputPtr = std::make_shared(_psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->index(), _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->dataType(), _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->bufferDataSize(), EMPTY_STRING); std::string memberName = _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String(); std::string uboDotMemberName = std::string(_psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()) + "." + _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String(); _uniformList[uboDotMemberName] = inputPtr; _globalUniformNameList[_psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()] = uboDotMemberName; } @@ -909,46 +909,46 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { for (NS::UInteger argIdx = 0; argIdx < _psoReflection->fragmentArguments()->count(); argIdx++) { if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTL::ArgumentTypeBuffer && + ->object(argIdx) + ->type() == MTLArgumentTypeBuffer && _psoReflection->fragmentArguments() - ->object(argIdx) - ->bufferDataType() == MTL::DataTypeStruct) { + ->object(argIdx) + ->bufferDataType() == MTLDataTypeStruct) { for (NS::UInteger memberIdx = 0; memberIdx < _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->structType() ->members() ->count(); memberIdx++) { std::string uboObjectName = std::string(_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()); std::string memberName = _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String(); std::string uboDotMemberName = uboObjectName + "." + memberName; InputPtr inputPtr = std::make_shared(_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->index(), _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->dataType(), _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->bufferDataSize(), EMPTY_STRING); _uniformList[uboDotMemberName] = inputPtr; _globalUniformNameList[memberName] = uboDotMemberName; - if (MTL::ArrayType *arrayMember = + if (MTLArrayType *arrayMember = _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->arrayType()) { for (int i = 0; i < arrayMember->arrayLength(); ++i) { for (NS::UInteger arrayStructIdx = 0; @@ -959,7 +959,7 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { memberName + "[" + std::to_string(i) + "]." + arrayMember->elementStructType() ->members() - ->object(arrayStructIdx) + ->object(arrayStructIdx) ->name() ->utf8String(); std::string uboDotMemberNameDotSubmemberName = @@ -968,15 +968,15 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { InputPtr inputPtr = std::make_shared( arrayMember->elementStructType() ->members() - ->object(arrayStructIdx) + ->object(arrayStructIdx) ->argumentIndex(), arrayMember->elementStructType() ->members() - ->object(arrayStructIdx) + ->object(arrayStructIdx) ->dataType(), arrayMember->elementStructType() ->members() - ->object(arrayStructIdx) + ->object(arrayStructIdx) ->offset(), EMPTY_STRING); _uniformList[uboDotMemberNameDotSubmemberName] = inputPtr; @@ -989,23 +989,23 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { } if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTL::ArgumentTypeTexture) { + ->object(argIdx) + ->type() == MTLArgumentTypeTexture) { if (HW::ENV_RADIANCE != _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String() && HW::ENV_IRRADIANCE != _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()) { std::string texture_name = _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String(); InputPtr inputPtr = std::make_shared(_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->index(), 58, -1, EMPTY_STRING); _uniformList[texture_name] = inputPtr; @@ -1050,7 +1050,7 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { for (size_t i = 0; i < uniforms.size(); ++i) { const ShaderPort *v = uniforms[i]; - MTL::DataType resourceType = mapTypeToMetalType(v->getType()); + MTLDataType resourceType = mapTypeToMetalType(v->getType()); // There is no way to match with an unnamed variable if (v->getVariable().empty()) { @@ -1058,7 +1058,7 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { } // Ignore types which are unsupported in MSL. - if (resourceType == MTL::DataTypeNone) { + if (resourceType == MTLDataTypeNone) { continue; } @@ -1136,7 +1136,7 @@ const MslProgram::InputMap &MslProgram::updateUniformsList() { return _uniformList; } -void MslProgram::bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, +void MslProgram::bindUniformBuffers(MTLRenderCommandEncoder *renderCmdEncoder, LightHandlerPtr lightHandler, CameraPtr cam) { auto setCommonUniform = [this](LightHandlerPtr lightHandler, CameraPtr cam, @@ -1305,60 +1305,60 @@ void MslProgram::bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, for (NS::UInteger argIdx = 0; argIdx < _psoReflection->vertexArguments()->count(); argIdx++) { if (_psoReflection->vertexArguments() - ->object(argIdx) - ->type() == MTL::ArgumentTypeBuffer && + ->object(argIdx) + ->type() == MTLArgumentTypeBuffer && _psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataType() == MTL::DataTypeStruct) { + ->object(argIdx) + ->bufferDataType() == MTLDataTypeStruct) { std::vector uniformBufferData( _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->bufferDataSize()); for (NS::UInteger memberIdx = 0; memberIdx < _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->structType() ->members() ->count(); memberIdx++) { if (!setCommonUniform(lightHandler, cam, _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String(), uniformBufferData, _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->offset())) { MaterialX::ValuePtr value = _uniformList[string(_psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()) + "." + _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()] ->value; if (value) { setValue(value, uniformBufferData, _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->offset()); } } } if (_psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->bufferStructType()) renderCmdEncoder->setVertexBytes((void *)uniformBufferData.data(), _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->bufferDataSize(), _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->index()); } } @@ -1366,41 +1366,41 @@ void MslProgram::bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, for (NS::UInteger argIdx = 0; argIdx < _psoReflection->fragmentArguments()->count(); argIdx++) { if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTL::ArgumentTypeBuffer && + ->object(argIdx) + ->type() == MTLArgumentTypeBuffer && _psoReflection->fragmentArguments() - ->object(argIdx) - ->bufferDataType() == MTL::DataTypeStruct) { + ->object(argIdx) + ->bufferDataType() == MTLDataTypeStruct) { std::vector uniformBufferData( _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->bufferDataSize()); for (NS::UInteger memberIdx = 0; memberIdx < _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->structType() ->members() ->count(); memberIdx++) { string uniformName = string(_psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String()) + "." + _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String(); if (!setCommonUniform(lightHandler, cam, _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->name() ->utf8String(), uniformBufferData, _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->offset())) { auto uniformInfo = _uniformList.find(uniformName); if (uniformInfo != _uniformList.end()) { @@ -1408,16 +1408,16 @@ void MslProgram::bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, if (value) { setValue(value, uniformBufferData, _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->offset()); } } else { } } - if (MTL::ArrayType *arrayMember = + if (MTLArrayType *arrayMember = _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->arrayType()) { for (int i = 0; i < arrayMember->arrayLength(); ++i) { for (NS::UInteger memberIdx = 0; @@ -1428,7 +1428,7 @@ void MslProgram::bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, uniformName + "[" + std::to_string(i) + "]." + arrayMember->elementStructType() ->members() - ->object(memberIdx) + ->object(memberIdx) ->name() ->utf8String(); @@ -1438,12 +1438,12 @@ void MslProgram::bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, if (value) { setValue(value, uniformBufferData, _psoReflection->fragmentArguments() - ->object(argIdx) + ->object(argIdx) ->offset() + i * arrayMember->stride() + arrayMember->elementStructType() ->members() - ->object(memberIdx) + ->object(memberIdx) ->offset()); } } @@ -1453,14 +1453,14 @@ void MslProgram::bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, } if (_psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->bufferStructType()) renderCmdEncoder->setFragmentBytes((void *)uniformBufferData.data(), _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->bufferDataSize(), _psoReflection->vertexArguments() - ->object(argIdx) + ->object(argIdx) ->index()); } } @@ -1481,33 +1481,33 @@ void MslProgram::reset() { clearInputLists(); } -MTL::DataType MslProgram::mapTypeToMetalType(const TypeDesc *type) { +MTLDataType MslProgram::mapTypeToMetalType(const TypeDesc *type) { if (type == Type::INTEGER) - return MTL::DataTypeInt; + return MTLDataTypeInt; else if (type == Type::BOOLEAN) - return MTL::DataTypeBool; + return MTLDataTypeBool; else if (type == Type::FLOAT) - return MTL::DataTypeFloat; + return MTLDataTypeFloat; else if (type->isFloat2()) - return MTL::DataTypeFloat2; + return MTLDataTypeFloat2; else if (type->isFloat3()) - return MTL::DataTypeFloat3; + return MTLDataTypeFloat3; else if (type->isFloat4()) - return MTL::DataTypeFloat4; + return MTLDataTypeFloat4; else if (type == Type::MATRIX33) - return MTL::DataTypeFloat3x3; + return MTLDataTypeFloat3x3; else if (type == Type::MATRIX44) - return MTL::DataTypeFloat4x4; + return MTLDataTypeFloat4x4; else if (type == Type::FILENAME) { // A "filename" is not indicative of type, so just return a 2d sampler. - return MTL::DataTypeTexture; + return MTLDataTypeTexture; } else if (type == Type::BSDF || type == Type::MATERIAL || type == Type::DISPLACEMENTSHADER || type == Type::EDF || type == Type::VDF || type == Type::SURFACESHADER || type == Type::LIGHTSHADER || type == Type::VOLUMESHADER) - return MTL::DataTypeStruct; + return MTLDataTypeStruct; - return MTL::DataTypeNone; + return MTLDataTypeNone; } const MslProgram::InputMap &MslProgram::updateAttributesList() { diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.cpp b/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm similarity index 77% rename from Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.cpp rename to Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm index 316f4152..ec5615cf 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.cpp +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#import #include #include #include @@ -11,7 +11,7 @@ #include -#include +#import MATERIALX_NAMESPACE_BEGIN @@ -24,7 +24,7 @@ MslRendererPtr MslRenderer::create(unsigned int width, unsigned int height, return MslRendererPtr(new MslRenderer(width, height, baseType)); } -MTL::Device *MslRenderer::getMetalDevice() const { return _device; } +id MslRenderer::getMetalDevice() const { return _device; } MslRenderer::MslRenderer(unsigned int width, unsigned int height, Image::BaseType baseType) @@ -45,7 +45,7 @@ void MslRenderer::initialize(RenderContextHandle) { throw ExceptionRenderError("Failed to initialize renderer window"); } - _device = MTL::CreateSystemDefaultDevice(); + _device = MTLCreateSystemDefaultDevice(); _cmdQueue = _device->newCommandQueue(); createFrameBuffer(true); @@ -72,12 +72,12 @@ void MslRenderer::renderTextureSpace(const Vector2 &uvMin, if (captureRenderTextureSpace) triggerProgrammaticCapture(); - MTL::RenderPassDescriptor *desc = MTL::RenderPassDescriptor::alloc()->init(); + MTLRenderPassDescriptor *desc = MTLRenderPassDescriptor::alloc()->init(); _framebuffer->bind(desc); _cmdBuffer = _cmdQueue->commandBuffer(); - MTL::RenderCommandEncoder *rendercmdEncoder = + MTLRenderCommandEncoder *rendercmdEncoder = _cmdBuffer->renderCommandEncoder(desc); _program->bind(rendercmdEncoder); _program->prepareUsedResources(rendercmdEncoder, _camera, _geometryHandler, @@ -89,7 +89,7 @@ void MslRenderer::renderTextureSpace(const Vector2 &uvMin, _program->bindPartition(part); MeshIndexBuffer &indexData = part->getIndices(); rendercmdEncoder->drawIndexedPrimitives( - MTL::PrimitiveTypeTriangle, indexData.size(), MTL::IndexTypeUInt32, + MTLPrimitiveTypeTriangle, indexData.size(), MTLIndexTypeUInt32, _program->getIndexBuffer(part), 0); _framebuffer->unbind(); @@ -130,24 +130,24 @@ void MslRenderer::setSize(unsigned int width, unsigned int height) { } void MslRenderer::triggerProgrammaticCapture() { - MTL::CaptureManager *captureManager = - MTL::CaptureManager::sharedCaptureManager(); - MTL::CaptureDescriptor *captureDescriptor = - MTL::CaptureDescriptor::alloc()->init(); + MTLCaptureManager *captureManager = + MTLCaptureManager::sharedCaptureManager(); + MTLCaptureDescriptor *captureDescriptor = + MTLCaptureDescriptor::alloc()->init(); captureDescriptor->setCaptureObject(_device); - NS::Error *error = nil; + NSError *error = nil; if (!captureManager->startCapture(captureDescriptor, &error)) { #if WITH_APPLE_NSLOG - NS::Log(NS::String::string("Failed to start capture, error %@", error), + NS::Log(NSString::string("Failed to start capture, error %@", error), NS::UTF8StringEncoding); #endif /* WITH_APPLE_NSLOG */ } } void MslRenderer::stopProgrammaticCapture() { - MTL::CaptureManager *captureManager = - MTL::CaptureManager::sharedCaptureManager(); + MTLCaptureManager *captureManager = + MTLCaptureManager::sharedCaptureManager(); captureManager->stopCapture(); } @@ -157,27 +157,27 @@ void MslRenderer::render() { triggerProgrammaticCapture(); _cmdBuffer = _cmdQueue->commandBuffer(); - MTL::RenderPassDescriptor *renderpassDesc = - MTL::RenderPassDescriptor::alloc()->init(); + MTLRenderPassDescriptor *renderpassDesc = + MTLRenderPassDescriptor::alloc()->init(); _framebuffer->bind(renderpassDesc); renderpassDesc->colorAttachments()->object(0)->setClearColor( - MTL::ClearColor::Make(_screenColor[0], _screenColor[1], _screenColor[2], + MTLClearColor::Make(_screenColor[0], _screenColor[1], _screenColor[2], 1.0f)); - MTL::RenderCommandEncoder *renderCmdEncoder = + MTLRenderCommandEncoder *renderCmdEncoder = _cmdBuffer->renderCommandEncoder(renderpassDesc); - MTL::DepthStencilDescriptor *depthStencilDesc = - MTL::DepthStencilDescriptor::alloc()->init(); + MTLDepthStencilDescriptor *depthStencilDesc = + MTLDepthStencilDescriptor::alloc()->init(); depthStencilDesc->setDepthWriteEnabled(!(_program->isTransparent())); - depthStencilDesc->setDepthCompareFunction(MTL::CompareFunctionLess); + depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionLess); - MTL::DepthStencilState *depthStencilState = + MTLDepthStencilState *depthStencilState = _device->newDepthStencilState(depthStencilDesc); renderCmdEncoder->setDepthStencilState(depthStencilState); - renderCmdEncoder->setCullMode(MTL::CullModeBack); + renderCmdEncoder->setCullMode(MTLCullModeBack); try { // Bind program and input parameters @@ -198,16 +198,16 @@ void MslRenderer::render() { MeshIndexBuffer &indexData = part->getIndices(); if (_program->isTransparent()) { - renderCmdEncoder->setCullMode(MTL::CullModeFront); + renderCmdEncoder->setCullMode(MTLCullModeFront); renderCmdEncoder->drawIndexedPrimitives( - MTL::PrimitiveTypeTriangle, (int)indexData.size(), - MTL::IndexTypeUInt32, _program->getIndexBuffer(part), 0); - renderCmdEncoder->setCullMode(MTL::CullModeBack); + MTLPrimitiveTypeTriangle, (int)indexData.size(), + MTLIndexTypeUInt32, _program->getIndexBuffer(part), 0); + renderCmdEncoder->setCullMode(MTLCullModeBack); } renderCmdEncoder->drawIndexedPrimitives( - MTL::PrimitiveTypeTriangle, (int)indexData.size(), - MTL::IndexTypeUInt32, _program->getIndexBuffer(part), 0); + MTLPrimitiveTypeTriangle, (int)indexData.size(), + MTLIndexTypeUInt32, _program->getIndexBuffer(part), 0); } } } diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.cpp b/Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.mm similarity index 100% rename from Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.cpp rename to Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.mm From 582851004b4333ee9b568b63444812a76f52dbec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furby=E2=84=A2?= Date: Thu, 21 May 2026 14:10:28 -0600 Subject: [PATCH 2/7] Remove custom Apple framework shims in favor of official SDKs * Remove custom bundled Apple, Metal, Foundation, AppKit, and UIKit C++ modules and migrate fully to the official Apple SDKs. * Restore MaterialX and ImGui Metal/Apple integration code closer to their upstream implementations to reduce local divergence and improve maintainability and portability. --- Package.swift | 30 +- Sources/GLFW/cocoa_platform.h | 4 +- Sources/ImGui/backends/ImplMacOS.mm | 32 +- Sources/ImGui/backends/ImplMetal.h | 14 +- Sources/ImGui/backends/ImplMetal.mm | 29 +- Sources/MaterialX/excluded/JsMXHelpers.h | 580 +- Sources/MaterialX/excluded/JsMXMapHelper.h | 90 +- Sources/MaterialX/excluded/JsMXVectorHelper.h | 131 +- Sources/MaterialX/include/MaterialX/Cgltf.h | 11802 +++++++------- Sources/MaterialX/include/MaterialX/Glad.h | 3429 +++-- .../MaterialX/include/MaterialX/KHRPlatform.h | 141 +- .../include/MaterialX/MXCoreGenerated.h | 7 +- .../include/MaterialX/MXGraphEditorGraph.h | 2 +- .../include/MaterialX/MXGraphEditorUiNode.h | 2 +- .../MaterialX/MXRenderGlslGLCocoaWrappers.h | 37 +- .../include/MaterialX/MXRenderGlslGLContext.h | 2 +- .../MaterialX/MXRenderHwWindowCocoaWrappers.h | 13 +- .../MaterialX/MXRenderMslMetalFramebuffer.h | 45 +- .../include/MaterialX/MXRenderMslMetalState.h | 22 +- .../MXRenderMslMetalTextureHandler.h | 35 +- .../MXRenderMslPipelineStateObject.h | 36 +- .../include/MaterialX/MXRenderMslRenderer.h | 10 +- .../MaterialX/include/MaterialX/MaterialX.h | 14 +- .../MaterialX/include/MaterialX/StbImage.h | 12716 ++++++++-------- .../include/MaterialX/StbImageWrite.h | 21 +- .../JsMaterialXCore/JsExceptions.cpp | 13 +- .../External/PugiXML/pugixml.cpp | 21 +- .../MaterialXRenderGlsl/GLCocoaWrappers.m | 69 +- .../MaterialXRenderHw/WindowWrapper.cpp | 2 +- .../MaterialXRenderMsl/MetalFramebuffer.mm | 102 +- .../source/MaterialXRenderMsl/MetalState.mm | 320 +- .../MaterialXRenderMsl/MetalTextureHandler.mm | 148 +- .../source/MaterialXRenderMsl/MslMaterial.mm | 9 +- .../MslPipelineStateObject.mm | 668 +- .../source/MaterialXRenderMsl/MslRenderer.mm | 106 +- .../source/MaterialXRenderOsl/OslRenderer.cpp | 10 +- .../MaterialXView/RenderPipelineMetal.mm | 26 +- Sources/MetaversalDemo/Creator.swift | 6 +- .../include/OpenSubdiv/OSDSurfaceMTLCommon.h | 2 +- Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm | 4 +- .../osd/MTLLegacyGregoryPatchTable.mm | 4 +- Sources/OpenSubdiv/osd/MTLVertexBuffer.mm | 2 +- .../MetaverseKitTests/MetaverseKitTests.swift | 2 +- 43 files changed, 16274 insertions(+), 14484 deletions(-) diff --git a/Package.swift b/Package.swift index d24edf5f..ceb4d0d4 100644 --- a/Package.swift +++ b/Package.swift @@ -250,8 +250,6 @@ let package = Package( ] ), - .target(name: "Apple"), - .target( name: "MicrosoftSTL", cxxSettings: [ @@ -319,11 +317,11 @@ let package = Package( .target( name: "MXResources", exclude: [ - // todo: fix metal shader compilation. + // TODO: fix metal shader compilation. "libraries" ], resources: [ - // todo: fix metal shader compilation. + // TODO: fix metal shader compilation. // .copy("libraries"), .copy("Resources/Geometry"), .copy("Resources/Images"), @@ -345,7 +343,6 @@ let package = Package( .target( name: "MaterialX", dependencies: [ - .target(name: "Apple", condition: .when(platforms: Arch.OS.apple.platform)), .target(name: "ImGui"), .target(name: "OpenImageIO"), .target(name: "OpenImageIO_Util"), @@ -700,7 +697,7 @@ let package = Package( linkerSettings: getConfig(for: .openvdb).linkerSettings ), - /* + /* * Run this from the command line via: * * swift bundler run -p macOS MetaversalDemo */ @@ -1135,10 +1132,6 @@ func getConfig(for target: PkgTarget) -> TargetInfo name: "TBBMallocProxy", targets: ["TBBMallocProxy"] ), - .library( - name: "Apple", - targets: ["Apple"] - ), .library( name: "MicrosoftSTL", targets: ["MicrosoftSTL"] @@ -1310,7 +1303,7 @@ enum Arch /// everything not android (all - android). case nodroid - public var platform: [Platform] + var platform: [Platform] { switch self { @@ -1326,7 +1319,7 @@ enum Arch } } - public static func packageDeps() -> [Package.Dependency] + static func packageDeps() -> [Package.Dependency] { #if os(macOS) || os(visionOS) || os(iOS) || os(tvOS) || os(watchOS) [ @@ -1344,7 +1337,7 @@ enum Arch #endif } - public static func targets() -> [Target] + static func targets() -> [Target] { #if os(macOS) || os(visionOS) || os(iOS) || os(tvOS) || os(watchOS) var targs: [Target] = [] @@ -1377,7 +1370,7 @@ enum Arch return targs } - public static func products() -> [Product] + static func products() -> [Product] { #if os(macOS) || os(visionOS) || os(iOS) || os(tvOS) || os(watchOS) var prods: [Product] = [ @@ -1406,7 +1399,7 @@ enum Arch return prods } - public static func ocioDeps() -> [Target.Dependency] + static func ocioDeps() -> [Target.Dependency] { // only add sse2neon on arm arch. let sse2neon: [Target.Dependency] = Arch.cpuArch.family.contains(.arm) ? [.target(name: "sse2neon")] : [] @@ -1440,7 +1433,7 @@ enum Arch #endif } - public static func minizipDeps() -> [Target.Dependency] + static func minizipDeps() -> [Target.Dependency] { #if os(Linux) || os(OpenBSD) || os(FreeBSD) [ @@ -1456,11 +1449,10 @@ enum Arch #endif } - public static func glfwDeps() -> [Target.Dependency] + static func glfwDeps() -> [Target.Dependency] { #if os(macOS) || os(visionOS) || os(iOS) || os(tvOS) || os(watchOS) [ - .target(name: "Apple", condition: .when(platforms: Arch.OS.apple.platform)), .product(name: "MoltenVK", package: "MetaverseVulkanFramework", condition: .when(platforms: [.macOS, .iOS, .tvOS])), ] #else /* os(Linux) || os(Android) || os(OpenBSD) || os(FreeBSD) || os(Windows) || os(Cygwin) || os(WASI) */ @@ -1483,7 +1475,7 @@ enum Arch case wasm32 case arm64_32 - public var family: [CPU] + var family: [CPU] { switch self { diff --git a/Sources/GLFW/cocoa_platform.h b/Sources/GLFW/cocoa_platform.h index e0453aba..dedabbc8 100644 --- a/Sources/GLFW/cocoa_platform.h +++ b/Sources/GLFW/cocoa_platform.h @@ -42,8 +42,8 @@ # if !TARGET_OS_IPHONE # import # else /* TARGET_OS_IPHONE */ -# import -# import +@import UIKit; +@import Foundation; # endif /* !TARGET_OS_IPHONE */ #else /* !defined(__OBJC__) */ typedef void* id; diff --git a/Sources/ImGui/backends/ImplMacOS.mm b/Sources/ImGui/backends/ImplMacOS.mm index 7b1b773b..08c39bf5 100644 --- a/Sources/ImGui/backends/ImplMacOS.mm +++ b/Sources/ImGui/backends/ImplMacOS.mm @@ -29,17 +29,17 @@ #ifndef IMGUI_DISABLE #import "ImplMacOS.h" #if !TARGET_OS_IPHONE -# import +#import #else /* TARGET_OS_IPHONE */ -# include -# include +#include +#include +#endif /* !TARGET_OS_IPHONE */ +#if !TARGET_OS_IPHONE +#import +#else /* TARGET_OS_IPHONE */ +#import +#import #endif /* !TARGET_OS_IPHONE */ -# if !TARGET_OS_IPHONE -# import -# else /* TARGET_OS_IPHONE */ -# import -# import -# endif /* !TARGET_OS_IPHONE */ #import #import @@ -118,7 +118,7 @@ KeyEventResponder *KeyEventResponder; #if !TARGET_OS_IPHONE NSTextInputContext *InputContext; -#else /* TARGET_OS_IPHONE */ +#else /* TARGET_OS_IPHONE */ UITextInputContext *InputContext; #endif /* !TARGET_OS_IPHONE */ id Monitor; @@ -521,7 +521,7 @@ static ImGuiKey ImGui_ImplOSX_KeyCodeToImGuiKey(int key_code) { default: return ImGuiKey_None; } -#else /* TARGET_OS_IPHONE */ +#else /* TARGET_OS_IPHONE */ return ImGuiKey_None; #endif /* !TARGET_OS_IPHONE */ } @@ -727,7 +727,9 @@ static void ImGui_ImplOSX_UpdateGamepads() { // Update gamepad inputs #define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V) #define MAP_BUTTON(KEY_NO, BUTTON_NAME) \ - { io.AddKeyEvent(KEY_NO, gp.BUTTON_NAME.isPressed); } + { \ + io.AddKeyEvent(KEY_NO, gp.BUTTON_NAME.isPressed); \ + } #define MAP_ANALOG(KEY_NO, AXIS_NAME, V0, V1) \ { \ float vn = (float)(gp.AXIS_NAME.value - V0) / (float)(V1 - V0); \ @@ -833,14 +835,14 @@ static ImGuiMouseSource GetMouseSource(NSEvent *event) { default: return ImGuiMouseSource_Mouse; } -#else /* TARGET_OS_IPHONE */ - return ImGuiMouseSource_TouchScreen; +#else /* TARGET_OS_IPHONE */ + return ImGuiMouseSource_TouchScreen; #endif /* !TARGET_OS_IPHONE */ } static bool ImGui_ImplOSX_HandleEvent(NSEvent *event, NSView *view) { #if !TARGET_OS_IPHONE - + ImGuiIO &io = ImGui::GetIO(); if (event.type == NSEventTypeLeftMouseDown || diff --git a/Sources/ImGui/backends/ImplMetal.h b/Sources/ImGui/backends/ImplMetal.h index 6884354b..6386bf58 100644 --- a/Sources/ImGui/backends/ImplMetal.h +++ b/Sources/ImGui/backends/ImplMetal.h @@ -52,22 +52,22 @@ IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects(); // https://developer.apple.com/metal/cpp/ #ifdef IMGUI_IMPL_METAL_CPP -#include +#import #ifndef __OBJC__ -IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device *device); +IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id device); IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); IMGUI_IMPL_API void -ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor *renderPassDescriptor); +ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor); IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData *draw_data, - MTL::CommandBuffer *commandBuffer, - MTL::RenderCommandEncoder *commandEncoder); + id commandBuffer, + id commandEncoder); // Called by Init/NewFrame/Shutdown -IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device *device); +IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id device); IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture(); -IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device *device); +IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id device); IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects(); #endif diff --git a/Sources/ImGui/backends/ImplMetal.mm b/Sources/ImGui/backends/ImplMetal.mm index 81bda0a6..369c8675 100644 --- a/Sources/ImGui/backends/ImplMetal.mm +++ b/Sources/ImGui/backends/ImplMetal.mm @@ -41,6 +41,7 @@ #include "ImGui/ImGui.h" #ifndef IMGUI_DISABLE #include "ImplMetal.h" + #import #import @@ -114,28 +115,29 @@ static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { #pragma mark - Dear ImGui Metal C++ Backend API -bool ImGui_ImplMetal_Init(MTL::Device *device) { +bool ImGui_ImplMetal_Init(id device) { return ImGui_ImplMetal_Init((__bridge id)(device)); } -void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor *renderPassDescriptor) { +void ImGui_ImplMetal_NewFrame( + id renderPassDescriptor) { ImGui_ImplMetal_NewFrame( - (__bridge MTLRenderPassDescriptor *)(renderPassDescriptor)); + (__bridge id)(renderPassDescriptor)); } -void ImGui_ImplMetal_RenderDrawData(ImDrawData *draw_data, - MTL::CommandBuffer *commandBuffer, - MTL::RenderCommandEncoder *commandEncoder) { +void ImGui_ImplMetal_RenderDrawData( + ImDrawData *draw_data, id commandBuffer, + id commandEncoder) { ImGui_ImplMetal_RenderDrawData( draw_data, (__bridge id)(commandBuffer), (__bridge id)(commandEncoder)); } -bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device *device) { +bool ImGui_ImplMetal_CreateFontsTexture(id device) { return ImGui_ImplMetal_CreateFontsTexture((__bridge id)(device)); } -bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device *device) { +bool ImGui_ImplMetal_CreateDeviceObjects(id device) { return ImGui_ImplMetal_CreateDeviceObjects((__bridge id)(device)); } @@ -458,13 +460,14 @@ @implementation FramebufferDescriptor - (instancetype)initWithRenderPassDescriptor: (MTLRenderPassDescriptor *)renderPassDescriptor { if ((self = [super init])) { - _sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount; - _colorPixelFormat = - renderPassDescriptor.colorAttachments[0].texture.pixelFormat; + _sampleCount = [[[[renderPassDescriptor colorAttachments] + objectAtIndexedSubscript:0] texture] sampleCount]; + _colorPixelFormat = [[[[renderPassDescriptor colorAttachments] + objectAtIndexedSubscript:0] texture] pixelFormat]; _depthPixelFormat = - renderPassDescriptor.depthAttachment.texture.pixelFormat; + [[[renderPassDescriptor depthAttachment] texture] pixelFormat]; _stencilPixelFormat = - renderPassDescriptor.stencilAttachment.texture.pixelFormat; + [[[renderPassDescriptor stencilAttachment] texture] pixelFormat]; } return self; } diff --git a/Sources/MaterialX/excluded/JsMXHelpers.h b/Sources/MaterialX/excluded/JsMXHelpers.h index 8b52473a..71ffb9c5 100644 --- a/Sources/MaterialX/excluded/JsMXHelpers.h +++ b/Sources/MaterialX/excluded/JsMXHelpers.h @@ -8,375 +8,415 @@ #include -using stRef = const std::string&; +using stRef = const std::string &; // Binding helpers #define UNPACK(...) __VA_ARGS__ /** - * Use this macro to conveniently create bindings for class member functions with optional parameters. - * If this is the last member on a class binding, finalize the invocation with a semicolon, e.g. BIND_MEMBER_FUNC(...); - * NOTE: The macro expects the MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! - * @param JSNAME The name of the function in JavaScript, as a double-quoted string (e.g. "addNodeGraph"). - * @param CLASSNAME The name (and scope) of the class that the member functions belongs to (e.g. mx::Document). + * Use this macro to conveniently create bindings for class member functions + * with optional parameters. If this is the last member on a class binding, + * finalize the invocation with a semicolon, e.g. BIND_MEMBER_FUNC(...); NOTE: + * The macro expects the MaterialX scope to be available as 'mx', and the + * emscripten scope as 'ems'! + * @param JSNAME The name of the function in JavaScript, as a double-quoted + * string (e.g. "addNodeGraph"). + * @param CLASSNAME The name (and scope) of the class that the member functions + * belongs to (e.g. mx::Document). * @param FUNCNAME The name of the function to bind (e.g. addNodeGraph). - * @param MINARGS The minimal number of parameters that need to provided when calling the function (a.k.a # of required parameters). - * @param MAXARGS The total number of parameters that the function takes, including optional ones. - * @param ... The types of all parameters, as a comma-separated list (e.g. const std::string&, float, bool) + * @param MINARGS The minimal number of parameters that need to provided when + * calling the function (a.k.a # of required parameters). + * @param MAXARGS The total number of parameters that the function takes, + * including optional ones. + * @param ... The types of all parameters, as a comma-separated list (e.g. const + * std::string&, float, bool) */ -#define BIND_MEMBER_FUNC(JSNAME, CLASSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ -BIND_ ##MINARGS ## _ ##MAXARGS(.function, JSNAME, CLASSNAME &self, (,), self., FUNCNAME, ( ), , __VA_ARGS__) +#define BIND_MEMBER_FUNC(JSNAME, CLASSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ + BIND_##MINARGS##_##MAXARGS(.function, JSNAME, CLASSNAME &self, (, ), self., \ + FUNCNAME, (), , __VA_ARGS__) /** - * Use this macro to conveniently create bindings for class member functions with optional parameters, - * where some of the parameters are raw pointers. - * If this is the last member on a class binding, finalize the invocation with a semicolon, e.g. BIND_MEMBER_FUNC_RAW_PTR(...); - * NOTE: The macro expects the MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! - * @param JSNAME The name of the function in JavaScript, as a double-quoted string (e.g. "addNodeGraph"). - * @param CLASSNAME The name (and scope) of the class that the member functions belongs to (e.g. mx::Document). + * Use this macro to conveniently create bindings for class member functions + * with optional parameters, where some of the parameters are raw pointers. If + * this is the last member on a class binding, finalize the invocation with a + * semicolon, e.g. BIND_MEMBER_FUNC_RAW_PTR(...); NOTE: The macro expects the + * MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! + * @param JSNAME The name of the function in JavaScript, as a double-quoted + * string (e.g. "addNodeGraph"). + * @param CLASSNAME The name (and scope) of the class that the member functions + * belongs to (e.g. mx::Document). * @param FUNCNAME The name of the function to bind (e.g. addNodeGraph). - * @param MINARGS The minimal number of parameters that need to provided when calling the function (a.k.a # of required parameters). - * @param MAXARGS The total number of parameters that the function takes, including optional ones. - * @param ... The types of all parameters, as a comma-separated list (e.g. const std::string&, float, bool) + * @param MINARGS The minimal number of parameters that need to provided when + * calling the function (a.k.a # of required parameters). + * @param MAXARGS The total number of parameters that the function takes, + * including optional ones. + * @param ... The types of all parameters, as a comma-separated list (e.g. const + * std::string&, float, bool) */ -#define BIND_MEMBER_FUNC_RAW_PTR(JSNAME, CLASSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ -BIND_ ##MINARGS ## _ ##MAXARGS(.function, JSNAME, CLASSNAME &self, (,), self., FUNCNAME, (, ems::allow_raw_pointers()), , __VA_ARGS__) - +#define BIND_MEMBER_FUNC_RAW_PTR(JSNAME, CLASSNAME, FUNCNAME, MINARGS, \ + MAXARGS, ...) \ + BIND_##MINARGS##_##MAXARGS(.function, JSNAME, CLASSNAME &self, (, ), self., \ + FUNCNAME, (, ems::allow_raw_pointers()), , \ + __VA_ARGS__) /** - * Use this macro to conveniently create bindings for static class functions with optional parameters. - * If this is the last member on a class binding, finalize the invocation with a semicolon, e.g. BIND_CLASS_FUNC(...); - * NOTE: The macro expects the MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! - * @param JSNAME The name of the function in JavaScript, as a double-quoted string (e.g. "addNodeGraph"). - * @param CLASSNAME The name (and scope) of the class that the member functions belongs to (e.g. mx::Document). + * Use this macro to conveniently create bindings for static class functions + * with optional parameters. If this is the last member on a class binding, + * finalize the invocation with a semicolon, e.g. BIND_CLASS_FUNC(...); NOTE: + * The macro expects the MaterialX scope to be available as 'mx', and the + * emscripten scope as 'ems'! + * @param JSNAME The name of the function in JavaScript, as a double-quoted + * string (e.g. "addNodeGraph"). + * @param CLASSNAME The name (and scope) of the class that the member functions + * belongs to (e.g. mx::Document). * @param FUNCNAME The name of the function to bind (e.g. addNodeGraph). - * @param MINARGS The minimal number of parameters that need to provided when calling the function (a.k.a # of required parameters). - * @param MAXARGS The total number of parameters that the function takes, including optional ones. - * @param ... The types of all parameters, as a comma-separated list (e.g. const std::string&, float, bool) + * @param MINARGS The minimal number of parameters that need to provided when + * calling the function (a.k.a # of required parameters). + * @param MAXARGS The total number of parameters that the function takes, + * including optional ones. + * @param ... The types of all parameters, as a comma-separated list (e.g. const + * std::string&, float, bool) */ -#define BIND_CLASS_FUNC(JSNAME, CLASSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ -BIND_ ##MINARGS ## _ ##MAXARGS(.class_function, JSNAME, , ( ), CLASSNAME ::, FUNCNAME, ( ), , __VA_ARGS__) +#define BIND_CLASS_FUNC(JSNAME, CLASSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ + BIND_##MINARGS##_##MAXARGS(.class_function, JSNAME, , (), CLASSNAME ::, \ + FUNCNAME, (), , __VA_ARGS__) /** - * Use this macro to conveniently create bindings for static class functions with optional parameters, - * where some of the parameters are raw pointers. - * If this is the last member on a class binding, finalize the invocation with a semicolon, e.g. BIND_CLASS_FUNC_RAW_PTR(...); - * NOTE: The macro expects the MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! - * @param JSNAME The name of the function in JavaScript, as a double-quoted string (e.g. "addNodeGraph"). - * @param CLASSNAME The name (and scope) of the class that the member functions belongs to (e.g. mx::Document). + * Use this macro to conveniently create bindings for static class functions + * with optional parameters, where some of the parameters are raw pointers. If + * this is the last member on a class binding, finalize the invocation with a + * semicolon, e.g. BIND_CLASS_FUNC_RAW_PTR(...); NOTE: The macro expects the + * MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! + * @param JSNAME The name of the function in JavaScript, as a double-quoted + * string (e.g. "addNodeGraph"). + * @param CLASSNAME The name (and scope) of the class that the member functions + * belongs to (e.g. mx::Document). * @param FUNCNAME The name of the function to bind (e.g. addNodeGraph). - * @param MINARGS The minimal number of parameters that need to provided when calling the function (a.k.a # of required parameters). - * @param MAXARGS The total number of parameters that the function takes, including optional ones. - * @param ... The types of all parameters, as a comma-separated list (e.g. const std::string&, float, bool) + * @param MINARGS The minimal number of parameters that need to provided when + * calling the function (a.k.a # of required parameters). + * @param MAXARGS The total number of parameters that the function takes, + * including optional ones. + * @param ... The types of all parameters, as a comma-separated list (e.g. const + * std::string&, float, bool) */ -#define BIND_CLASS_FUNC_RAW_PTR(JSNAME, CLASSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ -BIND_ ##MINARGS ## _ ##MAXARGS(.class_function, JSNAME, , ( ), CLASSNAME ::, FUNCNAME, (, ems::allow_raw_pointers()), , __VA_ARGS__) - +#define BIND_CLASS_FUNC_RAW_PTR(JSNAME, CLASSNAME, FUNCNAME, MINARGS, MAXARGS, \ + ...) \ + BIND_##MINARGS##_##MAXARGS(.class_function, JSNAME, , (), CLASSNAME ::, \ + FUNCNAME, (, ems::allow_raw_pointers()), , \ + __VA_ARGS__) /** - * Use this macro to conveniently create bindings for global (utility) functions with optional parameters. - * Do not finalize the invocation with a semicolon, e.g. simply use it as BIND_FUNC(...) - * NOTE: The macro expects the MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! - * @param JSNAME The name of the function in JavaScript, as a double-quoted string (e.g. "createDocument"). + * Use this macro to conveniently create bindings for global (utility) functions + * with optional parameters. Do not finalize the invocation with a semicolon, + * e.g. simply use it as BIND_FUNC(...) NOTE: The macro expects the MaterialX + * scope to be available as 'mx', and the emscripten scope as 'ems'! + * @param JSNAME The name of the function in JavaScript, as a double-quoted + * string (e.g. "createDocument"). * @param FUNCNAME The name of the function to bind (e.g. createDocument). - * @param MINARGS The minimal number of parameters that need to provided when calling the function (a.k.a # of required parameters). - * @param MAXARGS The total number of parameters that the function takes, including optional ones. - * @param ... The types of all parameters, as a comma-separated list (e.g. const std::string&, float, bool) + * @param MINARGS The minimal number of parameters that need to provided when + * calling the function (a.k.a # of required parameters). + * @param MAXARGS The total number of parameters that the function takes, + * including optional ones. + * @param ... The types of all parameters, as a comma-separated list (e.g. const + * std::string&, float, bool) */ -#define BIND_FUNC(JSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ -BIND_ ##MINARGS ## _ ##MAXARGS(ems::function, JSNAME, , ( ), , FUNCNAME, ( ), ;, __VA_ARGS__) +#define BIND_FUNC(JSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ + BIND_##MINARGS##_##MAXARGS(ems::function, JSNAME, , (), , FUNCNAME, (), ; \ + , __VA_ARGS__) /** - * Use this macro to conveniently create bindings for global (utility) functions with optional parameters, - * where some of the parameters are raw pointers. - * Do not finalize the invocation with a semicolon, e.g. simply use it as BIND_FUNC_RAW_PTR(...). - * NOTE: The macro expects the MaterialX scope to be available as 'mx', and the emscripten scope as 'ems'! - * @param JSNAME The name of the function in JavaScript, as a double-quoted string (e.g. "createDocument"). + * Use this macro to conveniently create bindings for global (utility) functions + * with optional parameters, where some of the parameters are raw pointers. Do + * not finalize the invocation with a semicolon, e.g. simply use it as + * BIND_FUNC_RAW_PTR(...). NOTE: The macro expects the MaterialX scope to be + * available as 'mx', and the emscripten scope as 'ems'! + * @param JSNAME The name of the function in JavaScript, as a double-quoted + * string (e.g. "createDocument"). * @param FUNCNAME The name of the function to bind (e.g. createDocument). - * @param MINARGS The minimal number of parameters that need to provided when calling the function (a.k.a # of required parameters). - * @param MAXARGS The total number of parameters that the function takes, including optional ones. - * @param ... The types of all parameters, as a comma-separated list (e.g. const std::string&, float, bool) + * @param MINARGS The minimal number of parameters that need to provided when + * calling the function (a.k.a # of required parameters). + * @param MAXARGS The total number of parameters that the function takes, + * including optional ones. + * @param ... The types of all parameters, as a comma-separated list (e.g. const + * std::string&, float, bool) */ -#define BIND_FUNC_RAW_PTR(JSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ -BIND_ ##MINARGS ## _ ##MAXARGS(ems::function, JSNAME, , ( ), , FUNCNAME, (, ems::allow_raw_pointers()), ;, __VA_ARGS__) - - -#define BIND_8(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ - TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, TYPE7, TYPE8, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4, TYPE5 p5, TYPE6 p6, TYPE7 p7, TYPE8 p8) { \ - return SCOPE FUNCNAME(p1, p2, p3, p4, p5, p6, p7, p8); \ -})UNPACK OPTIONS)SEMICOLON +#define BIND_FUNC_RAW_PTR(JSNAME, FUNCNAME, MINARGS, MAXARGS, ...) \ + BIND_##MINARGS##_##MAXARGS(ems::function, JSNAME, , (), , FUNCNAME, \ + (, ems::allow_raw_pointers()), \ + ;, __VA_ARGS__) + +#define BIND_8(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, TYPE7, TYPE8, ...) \ + API(JSNAME, ems::optional_override([](SELF UNPACK SEP TYPE1 p1, TYPE2 p2, \ + TYPE3 p3, TYPE4 p4, TYPE5 p5, \ + TYPE6 p6, TYPE7 p7, TYPE8 p8) { \ + return SCOPE FUNCNAME(p1, p2, p3, p4, p5, p6, p7, p8); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 9 Macros for MAXARGS = 8 -#define BIND_8_8(...) \ -BIND_8(__VA_ARGS__) - -#define BIND_7_8(...) \ -BIND_8_8(__VA_ARGS__) \ -BIND_7(__VA_ARGS__) +#define BIND_8_8(...) BIND_8(__VA_ARGS__) -#define BIND_6_8(...) \ -BIND_7_8(__VA_ARGS__) \ -BIND_6(__VA_ARGS__) +#define BIND_7_8(...) \ + BIND_8_8(__VA_ARGS__) \ + BIND_7(__VA_ARGS__) -#define BIND_5_8(...) \ -BIND_6_8(__VA_ARGS__) \ -BIND_5(__VA_ARGS__) +#define BIND_6_8(...) \ + BIND_7_8(__VA_ARGS__) \ + BIND_6(__VA_ARGS__) -#define BIND_4_8(...) \ -BIND_5_8(__VA_ARGS__) \ -BIND_4(__VA_ARGS__) +#define BIND_5_8(...) \ + BIND_6_8(__VA_ARGS__) \ + BIND_5(__VA_ARGS__) -#define BIND_3_8(...) \ -BIND_4_8(__VA_ARGS__) \ -BIND_3(__VA_ARGS__) +#define BIND_4_8(...) \ + BIND_5_8(__VA_ARGS__) \ + BIND_4(__VA_ARGS__) -#define BIND_2_8(...) \ -BIND_3_8(__VA_ARGS__) \ -BIND_2(__VA_ARGS__) +#define BIND_3_8(...) \ + BIND_4_8(__VA_ARGS__) \ + BIND_3(__VA_ARGS__) -#define BIND_1_8(...) \ -BIND_2_8(__VA_ARGS__) \ -BIND_1(__VA_ARGS__) +#define BIND_2_8(...) \ + BIND_3_8(__VA_ARGS__) \ + BIND_2(__VA_ARGS__) -#define BIND_0_8(...) \ -BIND_1_8(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_1_8(...) \ + BIND_2_8(__VA_ARGS__) \ + BIND_1(__VA_ARGS__) +#define BIND_0_8(...) \ + BIND_1_8(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) -#define BIND_7(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ - TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, TYPE7, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4, TYPE5 p5, TYPE6 p6, TYPE7 p7) { \ - return SCOPE FUNCNAME(p1, p2, p3, p4, p5, p6, p7); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_7(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, TYPE7, ...) \ + API(JSNAME, \ + ems::optional_override([](SELF UNPACK SEP TYPE1 p1, TYPE2 p2, TYPE3 p3, \ + TYPE4 p4, TYPE5 p5, TYPE6 p6, TYPE7 p7) { \ + return SCOPE FUNCNAME(p1, p2, p3, p4, p5, p6, p7); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 8 Macros for MAXARGS = 7 -#define BIND_7_7(...) \ -BIND_7(__VA_ARGS__) - -#define BIND_6_7(...) \ -BIND_7_7(__VA_ARGS__) \ -BIND_6(__VA_ARGS__) +#define BIND_7_7(...) BIND_7(__VA_ARGS__) -#define BIND_5_7(...) \ -BIND_6_7(__VA_ARGS__) \ -BIND_5(__VA_ARGS__) +#define BIND_6_7(...) \ + BIND_7_7(__VA_ARGS__) \ + BIND_6(__VA_ARGS__) -#define BIND_4_7(...) \ -BIND_5_7(__VA_ARGS__) \ -BIND_4(__VA_ARGS__) +#define BIND_5_7(...) \ + BIND_6_7(__VA_ARGS__) \ + BIND_5(__VA_ARGS__) -#define BIND_3_7(...) \ -BIND_4_7(__VA_ARGS__) \ -BIND_3(__VA_ARGS__) +#define BIND_4_7(...) \ + BIND_5_7(__VA_ARGS__) \ + BIND_4(__VA_ARGS__) -#define BIND_2_7(...) \ -BIND_3_7(__VA_ARGS__) \ -BIND_2(__VA_ARGS__) +#define BIND_3_7(...) \ + BIND_4_7(__VA_ARGS__) \ + BIND_3(__VA_ARGS__) -#define BIND_1_7(...) \ -BIND_2_7(__VA_ARGS__) \ -BIND_1(__VA_ARGS__) +#define BIND_2_7(...) \ + BIND_3_7(__VA_ARGS__) \ + BIND_2(__VA_ARGS__) -#define BIND_0_7(...) \ -BIND_1_7(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_1_7(...) \ + BIND_2_7(__VA_ARGS__) \ + BIND_1(__VA_ARGS__) +#define BIND_0_7(...) \ + BIND_1_7(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) -#define BIND_6(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ - TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4, TYPE5 p5, TYPE6 p6) { \ - return SCOPE FUNCNAME(p1, p2, p3, p4, p5, p6); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_6(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, ...) \ + API(JSNAME, \ + ems::optional_override([](SELF UNPACK SEP TYPE1 p1, TYPE2 p2, TYPE3 p3, \ + TYPE4 p4, TYPE5 p5, TYPE6 p6) { \ + return SCOPE FUNCNAME(p1, p2, p3, p4, p5, p6); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 7 Macros for MAXARGS = 6 -#define BIND_6_6(...) \ -BIND_6(__VA_ARGS__) +#define BIND_6_6(...) BIND_6(__VA_ARGS__) -#define BIND_5_6(...) \ -BIND_6_6(__VA_ARGS__) \ -BIND_5(__VA_ARGS__) +#define BIND_5_6(...) \ + BIND_6_6(__VA_ARGS__) \ + BIND_5(__VA_ARGS__) -#define BIND_4_6(...) \ -BIND_5_6(__VA_ARGS__) \ -BIND_4(__VA_ARGS__) +#define BIND_4_6(...) \ + BIND_5_6(__VA_ARGS__) \ + BIND_4(__VA_ARGS__) -#define BIND_3_6(...) \ -BIND_4_6(__VA_ARGS__) \ -BIND_3(__VA_ARGS__) +#define BIND_3_6(...) \ + BIND_4_6(__VA_ARGS__) \ + BIND_3(__VA_ARGS__) -#define BIND_2_6(...) \ -BIND_3_6(__VA_ARGS__) \ -BIND_2(__VA_ARGS__) +#define BIND_2_6(...) \ + BIND_3_6(__VA_ARGS__) \ + BIND_2(__VA_ARGS__) -#define BIND_1_6(...) \ -BIND_2_6(__VA_ARGS__) \ -BIND_1(__VA_ARGS__) +#define BIND_1_6(...) \ + BIND_2_6(__VA_ARGS__) \ + BIND_1(__VA_ARGS__) -#define BIND_0_6(...) \ -BIND_1_6(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_0_6(...) \ + BIND_1_6(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) - -#define BIND_5(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4, TYPE5 p5) { \ - return SCOPE FUNCNAME(p1, p2, p3, p4, p5); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_5(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, ...) \ + API(JSNAME, ems::optional_override([](SELF UNPACK SEP TYPE1 p1, TYPE2 p2, \ + TYPE3 p3, TYPE4 p4, TYPE5 p5) { \ + return SCOPE FUNCNAME(p1, p2, p3, p4, p5); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 6 Macros for MAXARGS = 5 -#define BIND_5_5(...) \ -BIND_5(__VA_ARGS__) - -#define BIND_4_5(...) \ -BIND_5_5(__VA_ARGS__) \ -BIND_4(__VA_ARGS__) +#define BIND_5_5(...) BIND_5(__VA_ARGS__) -#define BIND_3_5(...) \ -BIND_4_5(__VA_ARGS__) \ -BIND_3(__VA_ARGS__) +#define BIND_4_5(...) \ + BIND_5_5(__VA_ARGS__) \ + BIND_4(__VA_ARGS__) -#define BIND_2_5(...) \ -BIND_3_5(__VA_ARGS__) \ -BIND_2(__VA_ARGS__) +#define BIND_3_5(...) \ + BIND_4_5(__VA_ARGS__) \ + BIND_3(__VA_ARGS__) -#define BIND_1_5(...) \ -BIND_2_5(__VA_ARGS__) \ -BIND_1(__VA_ARGS__) +#define BIND_2_5(...) \ + BIND_3_5(__VA_ARGS__) \ + BIND_2(__VA_ARGS__) -#define BIND_0_5(...) \ -BIND_1_5(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_1_5(...) \ + BIND_2_5(__VA_ARGS__) \ + BIND_1(__VA_ARGS__) +#define BIND_0_5(...) \ + BIND_1_5(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) -#define BIND_4(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, TYPE1, TYPE2, TYPE3, TYPE4, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4) { \ - return SCOPE FUNCNAME(p1, p2, p3, p4); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_4(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, TYPE2, TYPE3, TYPE4, ...) \ + API(JSNAME, ems::optional_override( \ + [](SELF UNPACK SEP TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4) { \ + return SCOPE FUNCNAME(p1, p2, p3, p4); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 5 Macros for MAXARGS = 4 -#define BIND_4_4(...) \ -BIND_4(__VA_ARGS__) - -#define BIND_3_4(...) \ -BIND_4_4(__VA_ARGS__) \ -BIND_3(__VA_ARGS__) +#define BIND_4_4(...) BIND_4(__VA_ARGS__) -#define BIND_2_4(...) \ -BIND_3_4(__VA_ARGS__) \ -BIND_2(__VA_ARGS__) +#define BIND_3_4(...) \ + BIND_4_4(__VA_ARGS__) \ + BIND_3(__VA_ARGS__) -#define BIND_1_4(...) \ -BIND_2_4(__VA_ARGS__) \ -BIND_1(__VA_ARGS__) +#define BIND_2_4(...) \ + BIND_3_4(__VA_ARGS__) \ + BIND_2(__VA_ARGS__) -#define BIND_0_4(...) \ -BIND_1_4(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_1_4(...) \ + BIND_2_4(__VA_ARGS__) \ + BIND_1(__VA_ARGS__) +#define BIND_0_4(...) \ + BIND_1_4(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) -#define BIND_3(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, TYPE1, TYPE2, TYPE3, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1, TYPE2 p2, TYPE3 p3) { \ - return SCOPE FUNCNAME(p1, p2, p3); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_3(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, TYPE2, TYPE3, ...) \ + API(JSNAME, ems::optional_override( \ + [](SELF UNPACK SEP TYPE1 p1, TYPE2 p2, TYPE3 p3) { \ + return SCOPE FUNCNAME(p1, p2, p3); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 4 Macros for MAXARGS = 3 -#define BIND_3_3(...) \ -BIND_3(__VA_ARGS__) +#define BIND_3_3(...) BIND_3(__VA_ARGS__) -#define BIND_2_3(...) \ -BIND_3_3(__VA_ARGS__) \ -BIND_2(__VA_ARGS__) +#define BIND_2_3(...) \ + BIND_3_3(__VA_ARGS__) \ + BIND_2(__VA_ARGS__) -#define BIND_1_3(...) \ -BIND_2_3(__VA_ARGS__) \ -BIND_1(__VA_ARGS__) +#define BIND_1_3(...) \ + BIND_2_3(__VA_ARGS__) \ + BIND_1(__VA_ARGS__) -#define BIND_0_3(...) \ -BIND_1_3(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_0_3(...) \ + BIND_1_3(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) - -#define BIND_2(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, TYPE1, TYPE2, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1, TYPE2 p2) { \ - return SCOPE FUNCNAME(p1, p2); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_2(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, TYPE2, ...) \ + API(JSNAME, ems::optional_override([](SELF UNPACK SEP TYPE1 p1, TYPE2 p2) { \ + return SCOPE FUNCNAME(p1, p2); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 3 Macros for MAXARGS = 2 -#define BIND_2_2(...) \ -BIND_2(__VA_ARGS__) - -#define BIND_1_2(...) \ -BIND_2_2(__VA_ARGS__) \ -BIND_1(__VA_ARGS__) +#define BIND_2_2(...) BIND_2(__VA_ARGS__) -#define BIND_0_2(...) \ -BIND_1_2(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_1_2(...) \ + BIND_2_2(__VA_ARGS__) \ + BIND_1(__VA_ARGS__) +#define BIND_0_2(...) \ + BIND_1_2(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) -#define BIND_1(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, TYPE1, ...) \ -API(JSNAME, ems::optional_override([](SELF UNPACK SEP \ - TYPE1 p1) { \ - return SCOPE FUNCNAME(p1); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_1(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + TYPE1, ...) \ + API(JSNAME, ems::optional_override([](SELF UNPACK SEP TYPE1 p1) { \ + return SCOPE FUNCNAME(p1); \ + }) UNPACK OPTIONS) \ + SEMICOLON // 2 Macros for MAXARGS = 1 -#define BIND_1_1(...) \ -BIND_1(__VA_ARGS__) - -#define BIND_0_1(...) \ -BIND_1_1(__VA_ARGS__) \ -BIND_0(__VA_ARGS__) +#define BIND_1_1(...) BIND_1(__VA_ARGS__) +#define BIND_0_1(...) \ + BIND_1_1(__VA_ARGS__) \ + BIND_0(__VA_ARGS__) -#define BIND_0(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, ...) \ -API(JSNAME, ems::optional_override([](SELF) { \ - return SCOPE FUNCNAME(); \ -}) UNPACK OPTIONS)SEMICOLON +#define BIND_0(API, JSNAME, SELF, SEP, SCOPE, FUNCNAME, OPTIONS, SEMICOLON, \ + ...) \ + API(JSNAME, ems::optional_override([](SELF) { return SCOPE FUNCNAME(); }) \ + UNPACK OPTIONS) \ + SEMICOLON // 1 Macros for MAXARGS = 0 -#define BIND_0_0(...) \ -BIND_0(__VA_ARGS__) - - -/* Creates a wrapper converting a member function returning a reference to one returning - a pointer. Emscripten converts references to copies and the wrapper emulates - the expected behavior */ -template struct ptrReturnHelper; -template< - typename Class, - typename RetType, - typename... ArgType, - RetType &(Class::*method)(ArgType...) -> struct ptrReturnHelper { - auto getWrapper()->auto(*)(Class &, ArgType...)->RetType * { - return [](Class &obj, ArgType ...arg) -> RetType * { - return &(obj.*method)(arg...); - }; - } +#define BIND_0_0(...) BIND_0(__VA_ARGS__) + +/* Creates a wrapper converting a member function returning a reference to one + returning a pointer. Emscripten converts references to copies and the wrapper + emulates the expected behavior */ +template struct ptrReturnHelper; +template +struct ptrReturnHelper { + auto getWrapper() -> auto (*)(Class &, ArgType...) -> RetType * { + return [](Class &obj, ArgType... arg) -> RetType * { + return &(obj.*method)(arg...); + }; + } }; /** - * Creates a wrapper converting a non-overloaded member function returning a reference to one returning a pointer. + * Creates a wrapper converting a non-overloaded member function returning a + * reference to one returning a pointer. * @param METHOD Function pointer to the member function */ -#define PTR_RETURN(METHOD) \ - (ptrReturnHelper().getWrapper()) +#define PTR_RETURN(METHOD) \ + (ptrReturnHelper().getWrapper()) /** - * Creates a wrapper converting an overloaded member function returning a reference to one returning a pointer. + * Creates a wrapper converting an overloaded member function returning a + * reference to one returning a pointer. * @param DECL Declaration of the function to wrap * @param METHOD Function pointer to the member function */ -#define PTR_RETURN_OVERLOAD(DECL, METHOD) \ - (ptrReturnHelper().getWrapper()) +#define PTR_RETURN_OVERLOAD(DECL, METHOD) \ + (ptrReturnHelper().getWrapper()) #endif // JSMATERIALX_HELPERS_H diff --git a/Sources/MaterialX/excluded/JsMXMapHelper.h b/Sources/MaterialX/excluded/JsMXMapHelper.h index 2e036bae..3f394415 100644 --- a/Sources/MaterialX/excluded/JsMXMapHelper.h +++ b/Sources/MaterialX/excluded/JsMXMapHelper.h @@ -4,11 +4,12 @@ // /** - * Include this in every file that defines Emscripten bindings for functions with - * std::unordered_map parameters or return types, to automatically convert them to / from JS objects. - * It actually doesn't hurt to include this in every binding file ;) - * Note that this only works for types that are known to Emscripten, i.e. primitive (built-in) types - * and types that have bindings defined. + * Include this in every file that defines Emscripten bindings for functions + * with std::unordered_map parameters or return types, to automatically convert + * them to / from JS objects. It actually doesn't hurt to include this in every + * binding file ;) Note that this only works for types that are known to + * Emscripten, i.e. primitive (built-in) types and types that have bindings + * defined. */ #ifndef JSMATERIALX_MAP_HELPER_H @@ -25,67 +26,54 @@ namespace emscripten { namespace internal { template -std::unordered_map unorderedMapFromJSObject(const val& m) { +std::unordered_map unorderedMapFromJSObject(const val &m) { - val keys = val::global("Object").call("entries", m); - size_t length = keys["length"].as(); - std::unordered_map rm; - for (size_t i = 0; i < length; ++i) { - rm.set(m[i][0].as(), m[i][1].as()); - } - - return rm; + val keys = val::global("Object").call("entries", m); + size_t length = keys["length"].as(); + std::unordered_map rm; + for (size_t i = 0; i < length; ++i) { + rm.set(m[i][0].as(), m[i][1].as()); + } + + return rm; } -template -struct TypeID> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template struct TypeID> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct TypeID> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template struct TypeID> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct TypeID&> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template struct TypeID &> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct TypeID&> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template +struct TypeID &> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct BindingType> { - using ValBinding = BindingType; - using WireType = ValBinding::WireType; - - static WireType toWireType(const std::unordered_map &map) { - val obj = val::object(); - for (std::pair element : map) - { - obj.set(element.first, element.second); - } - return ValBinding::toWireType(obj); - } +template struct BindingType> { + using ValBinding = BindingType; + using WireType = ValBinding::WireType; - static std::unordered_map fromWireType(WireType value) { - return unorderedMapFromJSObject(ValBinding::fromWireType(value)); + static WireType toWireType(const std::unordered_map &map) { + val obj = val::object(); + for (std::pair element : map) { + obj.set(element.first, element.second); } + return ValBinding::toWireType(obj); + } + + static std::unordered_map fromWireType(WireType value) { + return unorderedMapFromJSObject(ValBinding::fromWireType(value)); + } }; -} // namespace internal -} // namespace emscripten +} // namespace internal +} // namespace emscripten #endif // __EMSCRIPTEN__ #endif // JSMATERIALX_MAP_HELPER_H diff --git a/Sources/MaterialX/excluded/JsMXVectorHelper.h b/Sources/MaterialX/excluded/JsMXVectorHelper.h index c325a2bf..edfa367e 100644 --- a/Sources/MaterialX/excluded/JsMXVectorHelper.h +++ b/Sources/MaterialX/excluded/JsMXVectorHelper.h @@ -4,11 +4,11 @@ // /** - * Include this in every file that defines Emscripten bindings for functions with - * std::vector parameters or return types, to automatically convert them to / from JS arrays. - * It actually doesn't hurt to include this in every binding file ;) - * Note that this only works for types that are known to Emscripten, i.e. primitive (built-in) types - * and types that have bindings defined. + * Include this in every file that defines Emscripten bindings for functions + * with std::vector parameters or return types, to automatically convert them to + * / from JS arrays. It actually doesn't hurt to include this in every binding + * file ;) Note that this only works for types that are known to Emscripten, + * i.e. primitive (built-in) types and types that have bindings defined. */ #ifndef JSMATERIALX_VECTOR_HELPERS_H @@ -24,97 +24,84 @@ namespace emscripten { namespace internal { -template -struct TypeID> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template struct TypeID> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct TypeID> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template struct TypeID> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct TypeID&> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template struct TypeID &> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct TypeID&> { - static constexpr TYPEID get() { - return LightTypeID::get(); - } +template struct TypeID &> { + static constexpr TYPEID get() { return LightTypeID::get(); } }; -template -struct BindingType> { - using ValBinding = BindingType; - using WireType = ValBinding::WireType; +template struct BindingType> { + using ValBinding = BindingType; + using WireType = ValBinding::WireType; - static WireType toWireType(const std::vector &vec) { - WireType result = ValBinding::toWireType(val::array(vec)); - return result; - } + static WireType toWireType(const std::vector &vec) { + WireType result = ValBinding::toWireType(val::array(vec)); + return result; + } - static std::vector fromWireType(WireType value) { - return vecFromJSArray(ValBinding::fromWireType(value)); - } + static std::vector fromWireType(WireType value) { + return vecFromJSArray(ValBinding::fromWireType(value)); + } }; // std are stored using bits, therefore the default emscripten // implementation doesn't work for them and need to be specialized -template <> -struct BindingType> { - using ValBinding = BindingType; - using WireType = ValBinding::WireType; - - static WireType toWireType(const std::vector &vec) { - val out = val::array(); - for (auto i: vec) { - out.call("push", i == 1 ? true : false); - } - WireType result = ValBinding::toWireType(out); - return result; +template <> struct BindingType> { + using ValBinding = BindingType; + using WireType = ValBinding::WireType; + + static WireType toWireType(const std::vector &vec) { + val out = val::array(); + for (auto i : vec) { + out.call("push", i == 1 ? true : false); } + WireType result = ValBinding::toWireType(out); + return result; + } - static std::vector fromWireType(WireType value) { - return vecFromJSArray(ValBinding::fromWireType(value)); - } + static std::vector fromWireType(WireType value) { + return vecFromJSArray(ValBinding::fromWireType(value)); + } }; /** - * Vectors of smart pointers need special treatment. The above generic toWireType definition uses val::array(vec), - * which constructs a val::array using val::array.call("push", element). This leads to invalid (deleted) smart - * pointers on the JS side, since the generated code constructs the smart pointer object, pushes it into a JS array, - * and then deletes the smart pointer object (i.e. sets the ref count to 0). Using val::array.set() doesn't suffer from - * this issue. + * Vectors of smart pointers need special treatment. The above generic + * toWireType definition uses val::array(vec), which constructs a val::array + * using val::array.call("push", element). This leads to invalid (deleted) + * smart pointers on the JS side, since the generated code constructs the smart + * pointer object, pushes it into a JS array, and then deletes the smart pointer + * object (i.e. sets the ref count to 0). Using val::array.set() doesn't suffer + * from this issue. */ -template -struct BindingType>> { - using ValBinding = BindingType; - using WireType = ValBinding::WireType; - - static WireType toWireType(const std::vector> &vec) { - auto arr = val::array(); - for (int i = 0; i < vec.size(); ++i) { - arr.set(i, vec.at(i)); - } - return ValBinding::toWireType(arr); +template struct BindingType>> { + using ValBinding = BindingType; + using WireType = ValBinding::WireType; + + static WireType toWireType(const std::vector> &vec) { + auto arr = val::array(); + for (int i = 0; i < vec.size(); ++i) { + arr.set(i, vec.at(i)); } + return ValBinding::toWireType(arr); + } - static std::vector> fromWireType(WireType value) { - return vecFromJSArray>(ValBinding::fromWireType(value)); - } + static std::vector> fromWireType(WireType value) { + return vecFromJSArray>(ValBinding::fromWireType(value)); + } }; -} // namespace internal -} // namespace emscripten +} // namespace internal +} // namespace emscripten #endif // __EMSCRIPTEN__ #endif // JSMATERIALX_VECTOR_HELPERS_H \ No newline at end of file diff --git a/Sources/MaterialX/include/MaterialX/Cgltf.h b/Sources/MaterialX/include/MaterialX/Cgltf.h index 95b56ced..ff8905ab 100644 --- a/Sources/MaterialX/include/MaterialX/Cgltf.h +++ b/Sources/MaterialX/include/MaterialX/Cgltf.h @@ -52,42 +52,48 @@ * `cgltf_result cgltf_validate(cgltf_data*)` can be used to do additional * checks to make sure the parsed glTF data is valid. * - * `cgltf_node_transform_local` converts the translation / rotation / scale properties of a node - * into a mat4. + * `cgltf_node_transform_local` converts the translation / rotation / scale + * properties of a node into a mat4. * - * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every ancestor in order - * to compute the root-to-node transformation. + * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every + * ancestor in order to compute the root-to-node transformation. * - * `cgltf_accessor_unpack_floats` reads in the data from an accessor, applies sparse data (if any), - * and converts them to floating point. Assumes that `cgltf_load_buffers` has already been called. - * By passing null for the output pointer, users can find out how many floats are required in the - * output buffer. + * `cgltf_accessor_unpack_floats` reads in the data from an accessor, applies + * sparse data (if any), and converts them to floating point. Assumes that + * `cgltf_load_buffers` has already been called. By passing null for the output + * pointer, users can find out how many floats are required in the output + * buffer. * * `cgltf_num_components` is a tiny utility that tells you the dimensionality of - * a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate - * the necessary amount of memory. + * a certain accessor type. This can be used before + * `cgltf_accessor_unpack_floats` to help allocate the necessary amount of + * memory. * - * `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to - * floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element - * size is the number of floats in the output buffer, which should be in the range [1, 16]. Returns - * false if the passed-in element_size is too small, or if the accessor is sparse. + * `cgltf_accessor_read_float` reads a certain element from a non-sparse + * accessor and converts it to floating point, assuming that + * `cgltf_load_buffers` has already been called. The passed-in element size is + * the number of floats in the output buffer, which should be in the range [1, + * 16]. Returns false if the passed-in element_size is too small, or if the + * accessor is sparse. * - * `cgltf_accessor_read_uint` is similar to its floating-point counterpart, but limited to reading - * vector types and does not support matrix types. The passed-in element size is the number of uints - * in the output buffer, which should be in the range [1, 4]. Returns false if the passed-in - * element_size is too small, or if the accessor is sparse. + * `cgltf_accessor_read_uint` is similar to its floating-point counterpart, but + * limited to reading vector types and does not support matrix types. The + * passed-in element size is the number of uints in the output buffer, which + * should be in the range [1, 4]. Returns false if the passed-in element_size is + * too small, or if the accessor is sparse. * - * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t - * and only works with single-component data types. + * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but + * it returns size_t and only works with single-component data types. * * `cgltf_result cgltf_copy_extras_json(const cgltf_data*, const cgltf_extras*, - * char* dest, cgltf_size* dest_size)` allows users to retrieve the "extras" data that - * can be attached to many glTF objects (which can be arbitrary JSON data). The - * `cgltf_extras` struct stores the offsets of the start and end of the extras JSON data - * as it appears in the complete glTF JSON data. This function copies the extras data - * into the provided buffer. If `dest` is NULL, the length of the data is written into - * `dest_size`. You can then parse this data using your own JSON parser - * or, if you've included the cgltf implementation using the integrated JSMN JSON parser. + * char* dest, cgltf_size* dest_size)` allows users to retrieve the "extras" + * data that can be attached to many glTF objects (which can be arbitrary JSON + * data). The `cgltf_extras` struct stores the offsets of the start and end of + * the extras JSON data as it appears in the complete glTF JSON data. This + * function copies the extras data into the provided buffer. If `dest` is NULL, + * the length of the data is written into `dest_size`. You can then parse this + * data using your own JSON parser or, if you've included the cgltf + * implementation using the integrated JSMN JSON parser. */ #ifndef CGLTF_H_INCLUDED__ #define CGLTF_H_INCLUDED__ @@ -105,743 +111,716 @@ typedef int cgltf_int; typedef unsigned int cgltf_uint; typedef int cgltf_bool; -typedef enum cgltf_file_type -{ - cgltf_file_type_invalid, - cgltf_file_type_gltf, - cgltf_file_type_glb, - cgltf_file_type_max_enum +typedef enum cgltf_file_type { + cgltf_file_type_invalid, + cgltf_file_type_gltf, + cgltf_file_type_glb, + cgltf_file_type_max_enum } cgltf_file_type; -typedef enum cgltf_result -{ - cgltf_result_success, - cgltf_result_data_too_short, - cgltf_result_unknown_format, - cgltf_result_invalid_json, - cgltf_result_invalid_gltf, - cgltf_result_invalid_options, - cgltf_result_file_not_found, - cgltf_result_io_error, - cgltf_result_out_of_memory, - cgltf_result_legacy_gltf, - cgltf_result_max_enum +typedef enum cgltf_result { + cgltf_result_success, + cgltf_result_data_too_short, + cgltf_result_unknown_format, + cgltf_result_invalid_json, + cgltf_result_invalid_gltf, + cgltf_result_invalid_options, + cgltf_result_file_not_found, + cgltf_result_io_error, + cgltf_result_out_of_memory, + cgltf_result_legacy_gltf, + cgltf_result_max_enum } cgltf_result; -typedef struct cgltf_memory_options -{ - void* (*alloc_func)(void* user, cgltf_size size); - void (*free_func) (void* user, void* ptr); - void* user_data; +typedef struct cgltf_memory_options { + void *(*alloc_func)(void *user, cgltf_size size); + void (*free_func)(void *user, void *ptr); + void *user_data; } cgltf_memory_options; -typedef struct cgltf_file_options -{ - cgltf_result(*read)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data); - void (*release)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data); - void* user_data; +typedef struct cgltf_file_options { + cgltf_result (*read)(const struct cgltf_memory_options *memory_options, + const struct cgltf_file_options *file_options, + const char *path, cgltf_size *size, void **data); + void (*release)(const struct cgltf_memory_options *memory_options, + const struct cgltf_file_options *file_options, void *data); + void *user_data; } cgltf_file_options; -typedef struct cgltf_options -{ - cgltf_file_type type; /* invalid == auto detect */ - cgltf_size json_token_count; /* 0 == auto */ - cgltf_memory_options memory; - cgltf_file_options file; +typedef struct cgltf_options { + cgltf_file_type type; /* invalid == auto detect */ + cgltf_size json_token_count; /* 0 == auto */ + cgltf_memory_options memory; + cgltf_file_options file; } cgltf_options; -typedef enum cgltf_buffer_view_type -{ - cgltf_buffer_view_type_invalid, - cgltf_buffer_view_type_indices, - cgltf_buffer_view_type_vertices, - cgltf_buffer_view_type_max_enum +typedef enum cgltf_buffer_view_type { + cgltf_buffer_view_type_invalid, + cgltf_buffer_view_type_indices, + cgltf_buffer_view_type_vertices, + cgltf_buffer_view_type_max_enum } cgltf_buffer_view_type; -typedef enum cgltf_attribute_type -{ - cgltf_attribute_type_invalid, - cgltf_attribute_type_position, - cgltf_attribute_type_normal, - cgltf_attribute_type_tangent, - cgltf_attribute_type_texcoord, - cgltf_attribute_type_color, - cgltf_attribute_type_joints, - cgltf_attribute_type_weights, - cgltf_attribute_type_custom, - cgltf_attribute_type_max_enum +typedef enum cgltf_attribute_type { + cgltf_attribute_type_invalid, + cgltf_attribute_type_position, + cgltf_attribute_type_normal, + cgltf_attribute_type_tangent, + cgltf_attribute_type_texcoord, + cgltf_attribute_type_color, + cgltf_attribute_type_joints, + cgltf_attribute_type_weights, + cgltf_attribute_type_custom, + cgltf_attribute_type_max_enum } cgltf_attribute_type; -typedef enum cgltf_component_type -{ - cgltf_component_type_invalid, - cgltf_component_type_r_8, /* BYTE */ - cgltf_component_type_r_8u, /* UNSIGNED_BYTE */ - cgltf_component_type_r_16, /* SHORT */ - cgltf_component_type_r_16u, /* UNSIGNED_SHORT */ - cgltf_component_type_r_32u, /* UNSIGNED_INT */ - cgltf_component_type_r_32f, /* FLOAT */ - cgltf_component_type_max_enum +typedef enum cgltf_component_type { + cgltf_component_type_invalid, + cgltf_component_type_r_8, /* BYTE */ + cgltf_component_type_r_8u, /* UNSIGNED_BYTE */ + cgltf_component_type_r_16, /* SHORT */ + cgltf_component_type_r_16u, /* UNSIGNED_SHORT */ + cgltf_component_type_r_32u, /* UNSIGNED_INT */ + cgltf_component_type_r_32f, /* FLOAT */ + cgltf_component_type_max_enum } cgltf_component_type; -typedef enum cgltf_type -{ - cgltf_type_invalid, - cgltf_type_scalar, - cgltf_type_vec2, - cgltf_type_vec3, - cgltf_type_vec4, - cgltf_type_mat2, - cgltf_type_mat3, - cgltf_type_mat4, - cgltf_type_max_enum +typedef enum cgltf_type { + cgltf_type_invalid, + cgltf_type_scalar, + cgltf_type_vec2, + cgltf_type_vec3, + cgltf_type_vec4, + cgltf_type_mat2, + cgltf_type_mat3, + cgltf_type_mat4, + cgltf_type_max_enum } cgltf_type; -typedef enum cgltf_primitive_type -{ - cgltf_primitive_type_points, - cgltf_primitive_type_lines, - cgltf_primitive_type_line_loop, - cgltf_primitive_type_line_strip, - cgltf_primitive_type_triangles, - cgltf_primitive_type_triangle_strip, - cgltf_primitive_type_triangle_fan, - cgltf_primitive_type_max_enum +typedef enum cgltf_primitive_type { + cgltf_primitive_type_points, + cgltf_primitive_type_lines, + cgltf_primitive_type_line_loop, + cgltf_primitive_type_line_strip, + cgltf_primitive_type_triangles, + cgltf_primitive_type_triangle_strip, + cgltf_primitive_type_triangle_fan, + cgltf_primitive_type_max_enum } cgltf_primitive_type; -typedef enum cgltf_alpha_mode -{ - cgltf_alpha_mode_opaque, - cgltf_alpha_mode_mask, - cgltf_alpha_mode_blend, - cgltf_alpha_mode_max_enum +typedef enum cgltf_alpha_mode { + cgltf_alpha_mode_opaque, + cgltf_alpha_mode_mask, + cgltf_alpha_mode_blend, + cgltf_alpha_mode_max_enum } cgltf_alpha_mode; typedef enum cgltf_animation_path_type { - cgltf_animation_path_type_invalid, - cgltf_animation_path_type_translation, - cgltf_animation_path_type_rotation, - cgltf_animation_path_type_scale, - cgltf_animation_path_type_weights, - cgltf_animation_path_type_max_enum + cgltf_animation_path_type_invalid, + cgltf_animation_path_type_translation, + cgltf_animation_path_type_rotation, + cgltf_animation_path_type_scale, + cgltf_animation_path_type_weights, + cgltf_animation_path_type_max_enum } cgltf_animation_path_type; typedef enum cgltf_interpolation_type { - cgltf_interpolation_type_linear, - cgltf_interpolation_type_step, - cgltf_interpolation_type_cubic_spline, - cgltf_interpolation_type_max_enum + cgltf_interpolation_type_linear, + cgltf_interpolation_type_step, + cgltf_interpolation_type_cubic_spline, + cgltf_interpolation_type_max_enum } cgltf_interpolation_type; typedef enum cgltf_camera_type { - cgltf_camera_type_invalid, - cgltf_camera_type_perspective, - cgltf_camera_type_orthographic, - cgltf_camera_type_max_enum + cgltf_camera_type_invalid, + cgltf_camera_type_perspective, + cgltf_camera_type_orthographic, + cgltf_camera_type_max_enum } cgltf_camera_type; typedef enum cgltf_light_type { - cgltf_light_type_invalid, - cgltf_light_type_directional, - cgltf_light_type_point, - cgltf_light_type_spot, - cgltf_light_type_max_enum + cgltf_light_type_invalid, + cgltf_light_type_directional, + cgltf_light_type_point, + cgltf_light_type_spot, + cgltf_light_type_max_enum } cgltf_light_type; typedef enum cgltf_data_free_method { - cgltf_data_free_method_none, - cgltf_data_free_method_file_release, - cgltf_data_free_method_memory_free, - cgltf_data_free_method_max_enum + cgltf_data_free_method_none, + cgltf_data_free_method_file_release, + cgltf_data_free_method_memory_free, + cgltf_data_free_method_max_enum } cgltf_data_free_method; typedef struct cgltf_extras { - cgltf_size start_offset; - cgltf_size end_offset; + cgltf_size start_offset; + cgltf_size end_offset; } cgltf_extras; typedef struct cgltf_extension { - char* name; - char* data; + char *name; + char *data; } cgltf_extension; -typedef struct cgltf_buffer -{ - char* name; - cgltf_size size; - char* uri; - void* data; /* loaded by cgltf_load_buffers */ - cgltf_data_free_method data_free_method; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_buffer { + char *name; + cgltf_size size; + char *uri; + void *data; /* loaded by cgltf_load_buffers */ + cgltf_data_free_method data_free_method; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_buffer; typedef enum cgltf_meshopt_compression_mode { - cgltf_meshopt_compression_mode_invalid, - cgltf_meshopt_compression_mode_attributes, - cgltf_meshopt_compression_mode_triangles, - cgltf_meshopt_compression_mode_indices, - cgltf_meshopt_compression_mode_max_enum + cgltf_meshopt_compression_mode_invalid, + cgltf_meshopt_compression_mode_attributes, + cgltf_meshopt_compression_mode_triangles, + cgltf_meshopt_compression_mode_indices, + cgltf_meshopt_compression_mode_max_enum } cgltf_meshopt_compression_mode; typedef enum cgltf_meshopt_compression_filter { - cgltf_meshopt_compression_filter_none, - cgltf_meshopt_compression_filter_octahedral, - cgltf_meshopt_compression_filter_quaternion, - cgltf_meshopt_compression_filter_exponential, - cgltf_meshopt_compression_filter_max_enum + cgltf_meshopt_compression_filter_none, + cgltf_meshopt_compression_filter_octahedral, + cgltf_meshopt_compression_filter_quaternion, + cgltf_meshopt_compression_filter_exponential, + cgltf_meshopt_compression_filter_max_enum } cgltf_meshopt_compression_filter; -typedef struct cgltf_meshopt_compression -{ - cgltf_buffer* buffer; - cgltf_size offset; - cgltf_size size; - cgltf_size stride; - cgltf_size count; - cgltf_meshopt_compression_mode mode; - cgltf_meshopt_compression_filter filter; +typedef struct cgltf_meshopt_compression { + cgltf_buffer *buffer; + cgltf_size offset; + cgltf_size size; + cgltf_size stride; + cgltf_size count; + cgltf_meshopt_compression_mode mode; + cgltf_meshopt_compression_filter filter; } cgltf_meshopt_compression; -typedef struct cgltf_buffer_view -{ - char *name; - cgltf_buffer* buffer; - cgltf_size offset; - cgltf_size size; - cgltf_size stride; /* 0 == automatically determined by accessor */ - cgltf_buffer_view_type type; - void* data; /* overrides buffer->data if present, filled by extensions */ - cgltf_bool has_meshopt_compression; - cgltf_meshopt_compression meshopt_compression; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_buffer_view { + char *name; + cgltf_buffer *buffer; + cgltf_size offset; + cgltf_size size; + cgltf_size stride; /* 0 == automatically determined by accessor */ + cgltf_buffer_view_type type; + void *data; /* overrides buffer->data if present, filled by extensions */ + cgltf_bool has_meshopt_compression; + cgltf_meshopt_compression meshopt_compression; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_buffer_view; -typedef struct cgltf_accessor_sparse -{ - cgltf_size count; - cgltf_buffer_view* indices_buffer_view; - cgltf_size indices_byte_offset; - cgltf_component_type indices_component_type; - cgltf_buffer_view* values_buffer_view; - cgltf_size values_byte_offset; - cgltf_extras extras; - cgltf_extras indices_extras; - cgltf_extras values_extras; - cgltf_size extensions_count; - cgltf_extension* extensions; - cgltf_size indices_extensions_count; - cgltf_extension* indices_extensions; - cgltf_size values_extensions_count; - cgltf_extension* values_extensions; +typedef struct cgltf_accessor_sparse { + cgltf_size count; + cgltf_buffer_view *indices_buffer_view; + cgltf_size indices_byte_offset; + cgltf_component_type indices_component_type; + cgltf_buffer_view *values_buffer_view; + cgltf_size values_byte_offset; + cgltf_extras extras; + cgltf_extras indices_extras; + cgltf_extras values_extras; + cgltf_size extensions_count; + cgltf_extension *extensions; + cgltf_size indices_extensions_count; + cgltf_extension *indices_extensions; + cgltf_size values_extensions_count; + cgltf_extension *values_extensions; } cgltf_accessor_sparse; -typedef struct cgltf_accessor -{ - char* name; - cgltf_component_type component_type; - cgltf_bool normalized; - cgltf_type type; - cgltf_size offset; - cgltf_size count; - cgltf_size stride; - cgltf_buffer_view* buffer_view; - cgltf_bool has_min; - cgltf_float min[16]; - cgltf_bool has_max; - cgltf_float max[16]; - cgltf_bool is_sparse; - cgltf_accessor_sparse sparse; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_accessor { + char *name; + cgltf_component_type component_type; + cgltf_bool normalized; + cgltf_type type; + cgltf_size offset; + cgltf_size count; + cgltf_size stride; + cgltf_buffer_view *buffer_view; + cgltf_bool has_min; + cgltf_float min[16]; + cgltf_bool has_max; + cgltf_float max[16]; + cgltf_bool is_sparse; + cgltf_accessor_sparse sparse; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_accessor; -typedef struct cgltf_attribute -{ - char* name; - cgltf_attribute_type type; - cgltf_int index; - cgltf_accessor* data; +typedef struct cgltf_attribute { + char *name; + cgltf_attribute_type type; + cgltf_int index; + cgltf_accessor *data; } cgltf_attribute; -typedef struct cgltf_image -{ - char* name; - char* uri; - cgltf_buffer_view* buffer_view; - char* mime_type; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_image { + char *name; + char *uri; + cgltf_buffer_view *buffer_view; + char *mime_type; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_image; -typedef struct cgltf_sampler -{ - char* name; - cgltf_int mag_filter; - cgltf_int min_filter; - cgltf_int wrap_s; - cgltf_int wrap_t; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_sampler { + char *name; + cgltf_int mag_filter; + cgltf_int min_filter; + cgltf_int wrap_s; + cgltf_int wrap_t; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_sampler; -typedef struct cgltf_texture -{ - char* name; - cgltf_image* image; - cgltf_sampler* sampler; - cgltf_bool has_basisu; - cgltf_image* basisu_image; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_texture { + char *name; + cgltf_image *image; + cgltf_sampler *sampler; + cgltf_bool has_basisu; + cgltf_image *basisu_image; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_texture; -typedef struct cgltf_texture_transform -{ - cgltf_float offset[2]; - cgltf_float rotation; - cgltf_float scale[2]; - cgltf_bool has_texcoord; - cgltf_int texcoord; +typedef struct cgltf_texture_transform { + cgltf_float offset[2]; + cgltf_float rotation; + cgltf_float scale[2]; + cgltf_bool has_texcoord; + cgltf_int texcoord; } cgltf_texture_transform; -typedef struct cgltf_texture_view -{ - cgltf_texture* texture; - cgltf_int texcoord; - cgltf_float scale; /* equivalent to strength for occlusion_texture */ - cgltf_bool has_transform; - cgltf_texture_transform transform; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_texture_view { + cgltf_texture *texture; + cgltf_int texcoord; + cgltf_float scale; /* equivalent to strength for occlusion_texture */ + cgltf_bool has_transform; + cgltf_texture_transform transform; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_texture_view; -typedef struct cgltf_pbr_metallic_roughness -{ - cgltf_texture_view base_color_texture; - cgltf_texture_view metallic_roughness_texture; +typedef struct cgltf_pbr_metallic_roughness { + cgltf_texture_view base_color_texture; + cgltf_texture_view metallic_roughness_texture; - cgltf_float base_color_factor[4]; - cgltf_float metallic_factor; - cgltf_float roughness_factor; + cgltf_float base_color_factor[4]; + cgltf_float metallic_factor; + cgltf_float roughness_factor; - cgltf_extras extras; + cgltf_extras extras; } cgltf_pbr_metallic_roughness; -typedef struct cgltf_pbr_specular_glossiness -{ - cgltf_texture_view diffuse_texture; - cgltf_texture_view specular_glossiness_texture; +typedef struct cgltf_pbr_specular_glossiness { + cgltf_texture_view diffuse_texture; + cgltf_texture_view specular_glossiness_texture; - cgltf_float diffuse_factor[4]; - cgltf_float specular_factor[3]; - cgltf_float glossiness_factor; + cgltf_float diffuse_factor[4]; + cgltf_float specular_factor[3]; + cgltf_float glossiness_factor; } cgltf_pbr_specular_glossiness; -typedef struct cgltf_clearcoat -{ - cgltf_texture_view clearcoat_texture; - cgltf_texture_view clearcoat_roughness_texture; - cgltf_texture_view clearcoat_normal_texture; +typedef struct cgltf_clearcoat { + cgltf_texture_view clearcoat_texture; + cgltf_texture_view clearcoat_roughness_texture; + cgltf_texture_view clearcoat_normal_texture; - cgltf_float clearcoat_factor; - cgltf_float clearcoat_roughness_factor; + cgltf_float clearcoat_factor; + cgltf_float clearcoat_roughness_factor; } cgltf_clearcoat; -typedef struct cgltf_transmission -{ - cgltf_texture_view transmission_texture; - cgltf_float transmission_factor; +typedef struct cgltf_transmission { + cgltf_texture_view transmission_texture; + cgltf_float transmission_factor; } cgltf_transmission; -typedef struct cgltf_ior -{ - cgltf_float ior; +typedef struct cgltf_ior { + cgltf_float ior; } cgltf_ior; -typedef struct cgltf_specular -{ - cgltf_texture_view specular_texture; - cgltf_texture_view specular_color_texture; - cgltf_float specular_color_factor[3]; - cgltf_float specular_factor; +typedef struct cgltf_specular { + cgltf_texture_view specular_texture; + cgltf_texture_view specular_color_texture; + cgltf_float specular_color_factor[3]; + cgltf_float specular_factor; } cgltf_specular; -typedef struct cgltf_volume -{ - cgltf_texture_view thickness_texture; - cgltf_float thickness_factor; - cgltf_float attenuation_color[3]; - cgltf_float attenuation_distance; +typedef struct cgltf_volume { + cgltf_texture_view thickness_texture; + cgltf_float thickness_factor; + cgltf_float attenuation_color[3]; + cgltf_float attenuation_distance; } cgltf_volume; -typedef struct cgltf_sheen -{ - cgltf_texture_view sheen_color_texture; - cgltf_float sheen_color_factor[3]; - cgltf_texture_view sheen_roughness_texture; - cgltf_float sheen_roughness_factor; +typedef struct cgltf_sheen { + cgltf_texture_view sheen_color_texture; + cgltf_float sheen_color_factor[3]; + cgltf_texture_view sheen_roughness_texture; + cgltf_float sheen_roughness_factor; } cgltf_sheen; -typedef struct cgltf_emissive_strength -{ - cgltf_float emissive_strength; +typedef struct cgltf_emissive_strength { + cgltf_float emissive_strength; } cgltf_emissive_strength; -typedef struct cgltf_iridescence -{ - cgltf_float iridescence_factor; - cgltf_texture_view iridescence_texture; - cgltf_float iridescence_ior; - cgltf_float iridescence_thickness_min; - cgltf_float iridescence_thickness_max; - cgltf_texture_view iridescence_thickness_texture; +typedef struct cgltf_iridescence { + cgltf_float iridescence_factor; + cgltf_texture_view iridescence_texture; + cgltf_float iridescence_ior; + cgltf_float iridescence_thickness_min; + cgltf_float iridescence_thickness_max; + cgltf_texture_view iridescence_thickness_texture; } cgltf_iridescence; -typedef struct cgltf_material -{ - char* name; - cgltf_bool has_pbr_metallic_roughness; - cgltf_bool has_pbr_specular_glossiness; - cgltf_bool has_clearcoat; - cgltf_bool has_transmission; - cgltf_bool has_volume; - cgltf_bool has_ior; - cgltf_bool has_specular; - cgltf_bool has_sheen; - cgltf_bool has_emissive_strength; - cgltf_bool has_iridescence; - cgltf_pbr_metallic_roughness pbr_metallic_roughness; - cgltf_pbr_specular_glossiness pbr_specular_glossiness; - cgltf_clearcoat clearcoat; - cgltf_ior ior; - cgltf_specular specular; - cgltf_sheen sheen; - cgltf_transmission transmission; - cgltf_volume volume; - cgltf_emissive_strength emissive_strength; - cgltf_iridescence iridescence; - cgltf_texture_view normal_texture; - cgltf_texture_view occlusion_texture; - cgltf_texture_view emissive_texture; - cgltf_float emissive_factor[3]; - cgltf_alpha_mode alpha_mode; - cgltf_float alpha_cutoff; - cgltf_bool double_sided; - cgltf_bool unlit; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; +typedef struct cgltf_material { + char *name; + cgltf_bool has_pbr_metallic_roughness; + cgltf_bool has_pbr_specular_glossiness; + cgltf_bool has_clearcoat; + cgltf_bool has_transmission; + cgltf_bool has_volume; + cgltf_bool has_ior; + cgltf_bool has_specular; + cgltf_bool has_sheen; + cgltf_bool has_emissive_strength; + cgltf_bool has_iridescence; + cgltf_pbr_metallic_roughness pbr_metallic_roughness; + cgltf_pbr_specular_glossiness pbr_specular_glossiness; + cgltf_clearcoat clearcoat; + cgltf_ior ior; + cgltf_specular specular; + cgltf_sheen sheen; + cgltf_transmission transmission; + cgltf_volume volume; + cgltf_emissive_strength emissive_strength; + cgltf_iridescence iridescence; + cgltf_texture_view normal_texture; + cgltf_texture_view occlusion_texture; + cgltf_texture_view emissive_texture; + cgltf_float emissive_factor[3]; + cgltf_alpha_mode alpha_mode; + cgltf_float alpha_cutoff; + cgltf_bool double_sided; + cgltf_bool unlit; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_material; -typedef struct cgltf_material_mapping -{ - cgltf_size variant; - cgltf_material* material; - cgltf_extras extras; +typedef struct cgltf_material_mapping { + cgltf_size variant; + cgltf_material *material; + cgltf_extras extras; } cgltf_material_mapping; typedef struct cgltf_morph_target { - cgltf_attribute* attributes; - cgltf_size attributes_count; + cgltf_attribute *attributes; + cgltf_size attributes_count; } cgltf_morph_target; typedef struct cgltf_draco_mesh_compression { - cgltf_buffer_view* buffer_view; - cgltf_attribute* attributes; - cgltf_size attributes_count; + cgltf_buffer_view *buffer_view; + cgltf_attribute *attributes; + cgltf_size attributes_count; } cgltf_draco_mesh_compression; typedef struct cgltf_mesh_gpu_instancing { - cgltf_buffer_view* buffer_view; - cgltf_attribute* attributes; - cgltf_size attributes_count; + cgltf_buffer_view *buffer_view; + cgltf_attribute *attributes; + cgltf_size attributes_count; } cgltf_mesh_gpu_instancing; typedef struct cgltf_primitive { - cgltf_primitive_type type; - cgltf_accessor* indices; - cgltf_material* material; - cgltf_attribute* attributes; - cgltf_size attributes_count; - cgltf_morph_target* targets; - cgltf_size targets_count; - cgltf_extras extras; - cgltf_bool has_draco_mesh_compression; - cgltf_draco_mesh_compression draco_mesh_compression; - cgltf_material_mapping* mappings; - cgltf_size mappings_count; - cgltf_size extensions_count; - cgltf_extension* extensions; + cgltf_primitive_type type; + cgltf_accessor *indices; + cgltf_material *material; + cgltf_attribute *attributes; + cgltf_size attributes_count; + cgltf_morph_target *targets; + cgltf_size targets_count; + cgltf_extras extras; + cgltf_bool has_draco_mesh_compression; + cgltf_draco_mesh_compression draco_mesh_compression; + cgltf_material_mapping *mappings; + cgltf_size mappings_count; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_primitive; typedef struct cgltf_mesh { - char* name; - cgltf_primitive* primitives; - cgltf_size primitives_count; - cgltf_float* weights; - cgltf_size weights_count; - char** target_names; - cgltf_size target_names_count; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + char *name; + cgltf_primitive *primitives; + cgltf_size primitives_count; + cgltf_float *weights; + cgltf_size weights_count; + char **target_names; + cgltf_size target_names_count; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_mesh; typedef struct cgltf_node cgltf_node; typedef struct cgltf_skin { - char* name; - cgltf_node** joints; - cgltf_size joints_count; - cgltf_node* skeleton; - cgltf_accessor* inverse_bind_matrices; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + char *name; + cgltf_node **joints; + cgltf_size joints_count; + cgltf_node *skeleton; + cgltf_accessor *inverse_bind_matrices; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_skin; typedef struct cgltf_camera_perspective { - cgltf_bool has_aspect_ratio; - cgltf_float aspect_ratio; - cgltf_float yfov; - cgltf_bool has_zfar; - cgltf_float zfar; - cgltf_float znear; - cgltf_extras extras; + cgltf_bool has_aspect_ratio; + cgltf_float aspect_ratio; + cgltf_float yfov; + cgltf_bool has_zfar; + cgltf_float zfar; + cgltf_float znear; + cgltf_extras extras; } cgltf_camera_perspective; typedef struct cgltf_camera_orthographic { - cgltf_float xmag; - cgltf_float ymag; - cgltf_float zfar; - cgltf_float znear; - cgltf_extras extras; + cgltf_float xmag; + cgltf_float ymag; + cgltf_float zfar; + cgltf_float znear; + cgltf_extras extras; } cgltf_camera_orthographic; typedef struct cgltf_camera { - char* name; - cgltf_camera_type type; - union { - cgltf_camera_perspective perspective; - cgltf_camera_orthographic orthographic; - } data; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + char *name; + cgltf_camera_type type; + union { + cgltf_camera_perspective perspective; + cgltf_camera_orthographic orthographic; + } data; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_camera; typedef struct cgltf_light { - char* name; - cgltf_float color[3]; - cgltf_float intensity; - cgltf_light_type type; - cgltf_float range; - cgltf_float spot_inner_cone_angle; - cgltf_float spot_outer_cone_angle; - cgltf_extras extras; + char *name; + cgltf_float color[3]; + cgltf_float intensity; + cgltf_light_type type; + cgltf_float range; + cgltf_float spot_inner_cone_angle; + cgltf_float spot_outer_cone_angle; + cgltf_extras extras; } cgltf_light; struct cgltf_node { - char* name; - cgltf_node* parent; - cgltf_node** children; - cgltf_size children_count; - cgltf_skin* skin; - cgltf_mesh* mesh; - cgltf_camera* camera; - cgltf_light* light; - cgltf_float* weights; - cgltf_size weights_count; - cgltf_bool has_translation; - cgltf_bool has_rotation; - cgltf_bool has_scale; - cgltf_bool has_matrix; - cgltf_float translation[3]; - cgltf_float rotation[4]; - cgltf_float scale[3]; - cgltf_float matrix[16]; - cgltf_extras extras; - cgltf_bool has_mesh_gpu_instancing; - cgltf_mesh_gpu_instancing mesh_gpu_instancing; - cgltf_size extensions_count; - cgltf_extension* extensions; + char *name; + cgltf_node *parent; + cgltf_node **children; + cgltf_size children_count; + cgltf_skin *skin; + cgltf_mesh *mesh; + cgltf_camera *camera; + cgltf_light *light; + cgltf_float *weights; + cgltf_size weights_count; + cgltf_bool has_translation; + cgltf_bool has_rotation; + cgltf_bool has_scale; + cgltf_bool has_matrix; + cgltf_float translation[3]; + cgltf_float rotation[4]; + cgltf_float scale[3]; + cgltf_float matrix[16]; + cgltf_extras extras; + cgltf_bool has_mesh_gpu_instancing; + cgltf_mesh_gpu_instancing mesh_gpu_instancing; + cgltf_size extensions_count; + cgltf_extension *extensions; }; typedef struct cgltf_scene { - char* name; - cgltf_node** nodes; - cgltf_size nodes_count; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + char *name; + cgltf_node **nodes; + cgltf_size nodes_count; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_scene; typedef struct cgltf_animation_sampler { - cgltf_accessor* input; - cgltf_accessor* output; - cgltf_interpolation_type interpolation; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + cgltf_accessor *input; + cgltf_accessor *output; + cgltf_interpolation_type interpolation; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_animation_sampler; typedef struct cgltf_animation_channel { - cgltf_animation_sampler* sampler; - cgltf_node* target_node; - cgltf_animation_path_type target_path; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + cgltf_animation_sampler *sampler; + cgltf_node *target_node; + cgltf_animation_path_type target_path; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_animation_channel; typedef struct cgltf_animation { - char* name; - cgltf_animation_sampler* samplers; - cgltf_size samplers_count; - cgltf_animation_channel* channels; - cgltf_size channels_count; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + char *name; + cgltf_animation_sampler *samplers; + cgltf_size samplers_count; + cgltf_animation_channel *channels; + cgltf_size channels_count; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_animation; -typedef struct cgltf_material_variant -{ - char* name; - cgltf_extras extras; +typedef struct cgltf_material_variant { + char *name; + cgltf_extras extras; } cgltf_material_variant; typedef struct cgltf_asset { - char* copyright; - char* generator; - char* version; - char* min_version; - cgltf_extras extras; - cgltf_size extensions_count; - cgltf_extension* extensions; + char *copyright; + char *generator; + char *version; + char *min_version; + cgltf_extras extras; + cgltf_size extensions_count; + cgltf_extension *extensions; } cgltf_asset; -typedef struct cgltf_data -{ - cgltf_file_type file_type; - void* file_data; +typedef struct cgltf_data { + cgltf_file_type file_type; + void *file_data; - cgltf_asset asset; + cgltf_asset asset; - cgltf_mesh* meshes; - cgltf_size meshes_count; + cgltf_mesh *meshes; + cgltf_size meshes_count; - cgltf_material* materials; - cgltf_size materials_count; + cgltf_material *materials; + cgltf_size materials_count; - cgltf_accessor* accessors; - cgltf_size accessors_count; + cgltf_accessor *accessors; + cgltf_size accessors_count; - cgltf_buffer_view* buffer_views; - cgltf_size buffer_views_count; + cgltf_buffer_view *buffer_views; + cgltf_size buffer_views_count; - cgltf_buffer* buffers; - cgltf_size buffers_count; + cgltf_buffer *buffers; + cgltf_size buffers_count; - cgltf_image* images; - cgltf_size images_count; + cgltf_image *images; + cgltf_size images_count; - cgltf_texture* textures; - cgltf_size textures_count; + cgltf_texture *textures; + cgltf_size textures_count; - cgltf_sampler* samplers; - cgltf_size samplers_count; + cgltf_sampler *samplers; + cgltf_size samplers_count; - cgltf_skin* skins; - cgltf_size skins_count; + cgltf_skin *skins; + cgltf_size skins_count; - cgltf_camera* cameras; - cgltf_size cameras_count; + cgltf_camera *cameras; + cgltf_size cameras_count; - cgltf_light* lights; - cgltf_size lights_count; + cgltf_light *lights; + cgltf_size lights_count; - cgltf_node* nodes; - cgltf_size nodes_count; + cgltf_node *nodes; + cgltf_size nodes_count; - cgltf_scene* scenes; - cgltf_size scenes_count; + cgltf_scene *scenes; + cgltf_size scenes_count; - cgltf_scene* scene; + cgltf_scene *scene; - cgltf_animation* animations; - cgltf_size animations_count; + cgltf_animation *animations; + cgltf_size animations_count; - cgltf_material_variant* variants; - cgltf_size variants_count; + cgltf_material_variant *variants; + cgltf_size variants_count; - cgltf_extras extras; + cgltf_extras extras; - cgltf_size data_extensions_count; - cgltf_extension* data_extensions; + cgltf_size data_extensions_count; + cgltf_extension *data_extensions; - char** extensions_used; - cgltf_size extensions_used_count; + char **extensions_used; + cgltf_size extensions_used_count; - char** extensions_required; - cgltf_size extensions_required_count; + char **extensions_required; + cgltf_size extensions_required_count; - const char* json; - cgltf_size json_size; + const char *json; + cgltf_size json_size; - const void* bin; - cgltf_size bin_size; + const void *bin; + cgltf_size bin_size; - cgltf_memory_options memory; - cgltf_file_options file; + cgltf_memory_options memory; + cgltf_file_options file; } cgltf_data; -cgltf_result cgltf_parse( - const cgltf_options* options, - const void* data, - cgltf_size size, - cgltf_data** out_data); +cgltf_result cgltf_parse(const cgltf_options *options, const void *data, + cgltf_size size, cgltf_data **out_data); -cgltf_result cgltf_parse_file( - const cgltf_options* options, - const char* path, - cgltf_data** out_data); +cgltf_result cgltf_parse_file(const cgltf_options *options, const char *path, + cgltf_data **out_data); -cgltf_result cgltf_load_buffers( - const cgltf_options* options, - cgltf_data* data, - const char* gltf_path); +cgltf_result cgltf_load_buffers(const cgltf_options *options, cgltf_data *data, + const char *gltf_path); -cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data); +cgltf_result cgltf_load_buffer_base64(const cgltf_options *options, + cgltf_size size, const char *base64, + void **out_data); -cgltf_size cgltf_decode_string(char* string); -cgltf_size cgltf_decode_uri(char* uri); +cgltf_size cgltf_decode_string(char *string); +cgltf_size cgltf_decode_uri(char *uri); -cgltf_result cgltf_validate(cgltf_data* data); +cgltf_result cgltf_validate(cgltf_data *data); -void cgltf_free(cgltf_data* data); +void cgltf_free(cgltf_data *data); -void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix); -void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix); +void cgltf_node_transform_local(const cgltf_node *node, + cgltf_float *out_matrix); +void cgltf_node_transform_world(const cgltf_node *node, + cgltf_float *out_matrix); -cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size); -cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size); -cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index); +cgltf_bool cgltf_accessor_read_float(const cgltf_accessor *accessor, + cgltf_size index, cgltf_float *out, + cgltf_size element_size); +cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor *accessor, + cgltf_size index, cgltf_uint *out, + cgltf_size element_size); +cgltf_size cgltf_accessor_read_index(const cgltf_accessor *accessor, + cgltf_size index); cgltf_size cgltf_num_components(cgltf_type type); -cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count); +cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor *accessor, + cgltf_float *out, + cgltf_size float_count); -cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size); +cgltf_result cgltf_copy_extras_json(const cgltf_data *data, + const cgltf_extras *extras, char *dest, + cgltf_size *dest_size); #ifdef __cplusplus } @@ -863,13 +842,14 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* #ifdef CGLTF_IMPLEMENTATION +#include /* For FLT_MAX */ +#include /* For UINT_MAX etc */ #include /* For uint8_t, uint32_t */ -#include /* For strncpy */ #include /* For fopen */ -#include /* For UINT_MAX etc */ -#include /* For FLT_MAX */ +#include /* For strncpy */ -#if !defined(CGLTF_MALLOC) || !defined(CGLTF_FREE) || !defined(CGLTF_ATOI) || !defined(CGLTF_ATOF) || !defined(CGLTF_ATOLL) +#if !defined(CGLTF_MALLOC) || !defined(CGLTF_FREE) || !defined(CGLTF_ATOI) || \ + !defined(CGLTF_ATOF) || !defined(CGLTF_ATOLL) #include /* For malloc, free, atoi, atof */ #endif @@ -877,7 +857,8 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* #include #endif -/* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in input size */ +/* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in + * input size */ #define JSMN_PARENT_LINKS /* JSMN_STRICT is necessary to reject invalid JSON documents */ @@ -889,41 +870,41 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* * License: MIT */ typedef enum { - JSMN_UNDEFINED = 0, - JSMN_OBJECT = 1, - JSMN_ARRAY = 2, - JSMN_STRING = 3, - JSMN_PRIMITIVE = 4 + JSMN_UNDEFINED = 0, + JSMN_OBJECT = 1, + JSMN_ARRAY = 2, + JSMN_STRING = 3, + JSMN_PRIMITIVE = 4 } jsmntype_t; enum jsmnerr { - /* Not enough tokens were provided */ - JSMN_ERROR_NOMEM = -1, - /* Invalid character inside JSON string */ - JSMN_ERROR_INVAL = -2, - /* The string is not a full JSON packet, more bytes expected */ - JSMN_ERROR_PART = -3 + /* Not enough tokens were provided */ + JSMN_ERROR_NOMEM = -1, + /* Invalid character inside JSON string */ + JSMN_ERROR_INVAL = -2, + /* The string is not a full JSON packet, more bytes expected */ + JSMN_ERROR_PART = -3 }; typedef struct { - jsmntype_t type; - int start; - int end; - int size; + jsmntype_t type; + int start; + int end; + int size; #ifdef JSMN_PARENT_LINKS - int parent; + int parent; #endif } jsmntok_t; typedef struct { - unsigned int pos; /* offset in the JSON string */ - unsigned int toknext; /* next token to allocate */ - int toksuper; /* superior token node, e.g parent object or array */ + unsigned int pos; /* offset in the JSON string */ + unsigned int toknext; /* next token to allocate */ + int toksuper; /* superior token node, e.g parent object or array */ } jsmn_parser; static void jsmn_init(jsmn_parser *parser); -static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens); +static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, + jsmntok_t *tokens, size_t num_tokens); /* * -- jsmn.h end -- */ - static const cgltf_size GlbHeaderSize = 12; static const cgltf_size GlbChunkHeaderSize = 8; static const uint32_t GlbVersion = 2; @@ -950,5426 +931,5249 @@ static const uint32_t GlbMagicBinChunk = 0x004E4942; #define CGLTF_VALIDATE_ENABLE_ASSERTS 0 #endif -static void* cgltf_default_alloc(void* user, cgltf_size size) -{ - (void)user; - return CGLTF_MALLOC(size); +static void *cgltf_default_alloc(void *user, cgltf_size size) { + (void)user; + return CGLTF_MALLOC(size); } -static void cgltf_default_free(void* user, void* ptr) -{ - (void)user; - CGLTF_FREE(ptr); +static void cgltf_default_free(void *user, void *ptr) { + (void)user; + CGLTF_FREE(ptr); } -static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_size count) -{ - if (SIZE_MAX / element_size < count) - { - return NULL; - } - void* result = options->memory.alloc_func(options->memory.user_data, element_size * count); - if (!result) - { - return NULL; - } - memset(result, 0, element_size * count); - return result; +static void *cgltf_calloc(cgltf_options *options, size_t element_size, + cgltf_size count) { + if (SIZE_MAX / element_size < count) { + return NULL; + } + void *result = options->memory.alloc_func(options->memory.user_data, + element_size * count); + if (!result) { + return NULL; + } + memset(result, 0, element_size * count); + return result; } -static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data) -{ - (void)file_options; - void* (*memory_alloc)(void*, cgltf_size) = memory_options->alloc_func ? memory_options->alloc_func : &cgltf_default_alloc; - void (*memory_free)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free; +static cgltf_result +cgltf_default_file_read(const struct cgltf_memory_options *memory_options, + const struct cgltf_file_options *file_options, + const char *path, cgltf_size *size, void **data) { + (void)file_options; + void *(*memory_alloc)(void *, cgltf_size) = memory_options->alloc_func + ? memory_options->alloc_func + : &cgltf_default_alloc; + void (*memory_free)(void *, void *) = memory_options->free_func + ? memory_options->free_func + : &cgltf_default_free; - FILE* file = fopen(path, "rb"); - if (!file) - { - return cgltf_result_file_not_found; - } + FILE *file = fopen(path, "rb"); + if (!file) { + return cgltf_result_file_not_found; + } - cgltf_size file_size = size ? *size : 0; + cgltf_size file_size = size ? *size : 0; - if (file_size == 0) - { - fseek(file, 0, SEEK_END); + if (file_size == 0) { + fseek(file, 0, SEEK_END); #ifdef _WIN32 - __int64 length = _ftelli64(file); + __int64 length = _ftelli64(file); #else - long length = ftell(file); + long length = ftell(file); #endif - if (length < 0) - { - fclose(file); - return cgltf_result_io_error; - } - - fseek(file, 0, SEEK_SET); - file_size = (cgltf_size)length; - } - - char* file_data = (char*)memory_alloc(memory_options->user_data, file_size); - if (!file_data) - { - fclose(file); - return cgltf_result_out_of_memory; - } - - cgltf_size read_size = fread(file_data, 1, file_size, file); - - fclose(file); - - if (read_size != file_size) - { - memory_free(memory_options->user_data, file_data); - return cgltf_result_io_error; - } - - if (size) - { - *size = file_size; - } - if (data) - { - *data = file_data; - } - - return cgltf_result_success; -} - -static void cgltf_default_file_release(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data) -{ - (void)file_options; - void (*memfree)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free; - memfree(memory_options->user_data, data); -} - -static cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data); - -cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data) -{ - if (size < GlbHeaderSize) - { - return cgltf_result_data_too_short; - } - - if (options == NULL) - { - return cgltf_result_invalid_options; - } - - cgltf_options fixed_options = *options; - if (fixed_options.memory.alloc_func == NULL) - { - fixed_options.memory.alloc_func = &cgltf_default_alloc; - } - if (fixed_options.memory.free_func == NULL) - { - fixed_options.memory.free_func = &cgltf_default_free; - } - - uint32_t tmp; - // Magic - memcpy(&tmp, data, 4); - if (tmp != GlbMagic) - { - if (fixed_options.type == cgltf_file_type_invalid) - { - fixed_options.type = cgltf_file_type_gltf; - } - else if (fixed_options.type == cgltf_file_type_glb) - { - return cgltf_result_unknown_format; - } - } - - if (fixed_options.type == cgltf_file_type_gltf) - { - cgltf_result json_result = cgltf_parse_json(&fixed_options, (const uint8_t*)data, size, out_data); - if (json_result != cgltf_result_success) - { - return json_result; - } - - (*out_data)->file_type = cgltf_file_type_gltf; - - return cgltf_result_success; - } - - const uint8_t* ptr = (const uint8_t*)data; - // Version - memcpy(&tmp, ptr + 4, 4); - uint32_t version = tmp; - if (version != GlbVersion) - { - return version < GlbVersion ? cgltf_result_legacy_gltf : cgltf_result_unknown_format; - } - - // Total length - memcpy(&tmp, ptr + 8, 4); - if (tmp > size) - { - return cgltf_result_data_too_short; - } - - const uint8_t* json_chunk = ptr + GlbHeaderSize; - - if (GlbHeaderSize + GlbChunkHeaderSize > size) - { - return cgltf_result_data_too_short; - } - - // JSON chunk: length - uint32_t json_length; - memcpy(&json_length, json_chunk, 4); - if (GlbHeaderSize + GlbChunkHeaderSize + json_length > size) - { - return cgltf_result_data_too_short; - } - - // JSON chunk: magic - memcpy(&tmp, json_chunk + 4, 4); - if (tmp != GlbMagicJsonChunk) - { - return cgltf_result_unknown_format; - } - - json_chunk += GlbChunkHeaderSize; - - const void* bin = 0; - cgltf_size bin_size = 0; - - if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize <= size) - { - // We can read another chunk - const uint8_t* bin_chunk = json_chunk + json_length; - - // Bin chunk: length - uint32_t bin_length; - memcpy(&bin_length, bin_chunk, 4); - if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize + bin_length > size) - { - return cgltf_result_data_too_short; - } - - // Bin chunk: magic - memcpy(&tmp, bin_chunk + 4, 4); - if (tmp != GlbMagicBinChunk) - { - return cgltf_result_unknown_format; - } - - bin_chunk += GlbChunkHeaderSize; - - bin = bin_chunk; - bin_size = bin_length; - } - - cgltf_result json_result = cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data); - if (json_result != cgltf_result_success) - { - return json_result; - } - - (*out_data)->file_type = cgltf_file_type_glb; - (*out_data)->bin = bin; - (*out_data)->bin_size = bin_size; - - return cgltf_result_success; -} + if (length < 0) { + fclose(file); + return cgltf_result_io_error; + } -cgltf_result cgltf_parse_file(const cgltf_options* options, const char* path, cgltf_data** out_data) -{ - if (options == NULL) - { - return cgltf_result_invalid_options; - } + fseek(file, 0, SEEK_SET); + file_size = (cgltf_size)length; + } - cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read; - void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = options->file.release ? options->file.release : cgltf_default_file_release; + char *file_data = (char *)memory_alloc(memory_options->user_data, file_size); + if (!file_data) { + fclose(file); + return cgltf_result_out_of_memory; + } - void* file_data = NULL; - cgltf_size file_size = 0; - cgltf_result result = file_read(&options->memory, &options->file, path, &file_size, &file_data); - if (result != cgltf_result_success) - { - return result; - } + cgltf_size read_size = fread(file_data, 1, file_size, file); - result = cgltf_parse(options, file_data, file_size, out_data); + fclose(file); - if (result != cgltf_result_success) - { - file_release(&options->memory, &options->file, file_data); - return result; - } + if (read_size != file_size) { + memory_free(memory_options->user_data, file_data); + return cgltf_result_io_error; + } - (*out_data)->file_data = file_data; + if (size) { + *size = file_size; + } + if (data) { + *data = file_data; + } - return cgltf_result_success; + return cgltf_result_success; } -static void cgltf_combine_paths(char* path, const char* base, const char* uri) -{ - const char* s0 = strrchr(base, '/'); - const char* s1 = strrchr(base, '\\'); - const char* slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1; - - if (slash) - { - size_t prefix = slash - base + 1; - - strncpy(path, base, prefix); - strcpy(path + prefix, uri); - } - else - { - strcpy(path, uri); - } +static void +cgltf_default_file_release(const struct cgltf_memory_options *memory_options, + const struct cgltf_file_options *file_options, + void *data) { + (void)file_options; + void (*memfree)(void *, void *) = memory_options->free_func + ? memory_options->free_func + : &cgltf_default_free; + memfree(memory_options->user_data, data); } -static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* gltf_path, void** out_data) -{ - void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc; - void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free; - cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read; - - char* path = (char*)memory_alloc(options->memory.user_data, strlen(uri) + strlen(gltf_path) + 1); - if (!path) - { - return cgltf_result_out_of_memory; - } - - cgltf_combine_paths(path, gltf_path, uri); - - // after combining, the tail of the resulting path is a uri; decode_uri converts it into path - cgltf_decode_uri(path + strlen(path) - strlen(uri)); - - void* file_data = NULL; - cgltf_result result = file_read(&options->memory, &options->file, path, &size, &file_data); - - memory_free(options->memory.user_data, path); - - *out_data = (result == cgltf_result_success) ? file_data : NULL; - - return result; +static cgltf_result cgltf_parse_json(cgltf_options *options, + const uint8_t *json_chunk, cgltf_size size, + cgltf_data **out_data); + +cgltf_result cgltf_parse(const cgltf_options *options, const void *data, + cgltf_size size, cgltf_data **out_data) { + if (size < GlbHeaderSize) { + return cgltf_result_data_too_short; + } + + if (options == NULL) { + return cgltf_result_invalid_options; + } + + cgltf_options fixed_options = *options; + if (fixed_options.memory.alloc_func == NULL) { + fixed_options.memory.alloc_func = &cgltf_default_alloc; + } + if (fixed_options.memory.free_func == NULL) { + fixed_options.memory.free_func = &cgltf_default_free; + } + + uint32_t tmp; + // Magic + memcpy(&tmp, data, 4); + if (tmp != GlbMagic) { + if (fixed_options.type == cgltf_file_type_invalid) { + fixed_options.type = cgltf_file_type_gltf; + } else if (fixed_options.type == cgltf_file_type_glb) { + return cgltf_result_unknown_format; + } + } + + if (fixed_options.type == cgltf_file_type_gltf) { + cgltf_result json_result = + cgltf_parse_json(&fixed_options, (const uint8_t *)data, size, out_data); + if (json_result != cgltf_result_success) { + return json_result; + } + + (*out_data)->file_type = cgltf_file_type_gltf; + + return cgltf_result_success; + } + + const uint8_t *ptr = (const uint8_t *)data; + // Version + memcpy(&tmp, ptr + 4, 4); + uint32_t version = tmp; + if (version != GlbVersion) { + return version < GlbVersion ? cgltf_result_legacy_gltf + : cgltf_result_unknown_format; + } + + // Total length + memcpy(&tmp, ptr + 8, 4); + if (tmp > size) { + return cgltf_result_data_too_short; + } + + const uint8_t *json_chunk = ptr + GlbHeaderSize; + + if (GlbHeaderSize + GlbChunkHeaderSize > size) { + return cgltf_result_data_too_short; + } + + // JSON chunk: length + uint32_t json_length; + memcpy(&json_length, json_chunk, 4); + if (GlbHeaderSize + GlbChunkHeaderSize + json_length > size) { + return cgltf_result_data_too_short; + } + + // JSON chunk: magic + memcpy(&tmp, json_chunk + 4, 4); + if (tmp != GlbMagicJsonChunk) { + return cgltf_result_unknown_format; + } + + json_chunk += GlbChunkHeaderSize; + + const void *bin = 0; + cgltf_size bin_size = 0; + + if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize <= + size) { + // We can read another chunk + const uint8_t *bin_chunk = json_chunk + json_length; + + // Bin chunk: length + uint32_t bin_length; + memcpy(&bin_length, bin_chunk, 4); + if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize + + bin_length > + size) { + return cgltf_result_data_too_short; + } + + // Bin chunk: magic + memcpy(&tmp, bin_chunk + 4, 4); + if (tmp != GlbMagicBinChunk) { + return cgltf_result_unknown_format; + } + + bin_chunk += GlbChunkHeaderSize; + + bin = bin_chunk; + bin_size = bin_length; + } + + cgltf_result json_result = + cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data); + if (json_result != cgltf_result_success) { + return json_result; + } + + (*out_data)->file_type = cgltf_file_type_glb; + (*out_data)->bin = bin; + (*out_data)->bin_size = bin_size; + + return cgltf_result_success; } -cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data) -{ - void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc; - void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free; - - unsigned char* data = (unsigned char*)memory_alloc(options->memory.user_data, size); - if (!data) - { - return cgltf_result_out_of_memory; - } - - unsigned int buffer = 0; - unsigned int buffer_bits = 0; - - for (cgltf_size i = 0; i < size; ++i) - { - while (buffer_bits < 8) - { - char ch = *base64++; - - int index = - (unsigned)(ch - 'A') < 26 ? (ch - 'A') : - (unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 : - (unsigned)(ch - '0') < 10 ? (ch - '0') + 52 : - ch == '+' ? 62 : - ch == '/' ? 63 : - -1; - - if (index < 0) - { - memory_free(options->memory.user_data, data); - return cgltf_result_io_error; - } - - buffer = (buffer << 6) | index; - buffer_bits += 6; - } - - data[i] = (unsigned char)(buffer >> (buffer_bits - 8)); - buffer_bits -= 8; - } - - *out_data = data; - - return cgltf_result_success; +cgltf_result cgltf_parse_file(const cgltf_options *options, const char *path, + cgltf_data **out_data) { + if (options == NULL) { + return cgltf_result_invalid_options; + } + + cgltf_result (*file_read)(const struct cgltf_memory_options *, + const struct cgltf_file_options *, const char *, + cgltf_size *, void **) = + options->file.read ? options->file.read : &cgltf_default_file_read; + void (*file_release)(const struct cgltf_memory_options *, + const struct cgltf_file_options *, void *data) = + options->file.release ? options->file.release + : cgltf_default_file_release; + + void *file_data = NULL; + cgltf_size file_size = 0; + cgltf_result result = + file_read(&options->memory, &options->file, path, &file_size, &file_data); + if (result != cgltf_result_success) { + return result; + } + + result = cgltf_parse(options, file_data, file_size, out_data); + + if (result != cgltf_result_success) { + file_release(&options->memory, &options->file, file_data); + return result; + } + + (*out_data)->file_data = file_data; + + return cgltf_result_success; } -static int cgltf_unhex(char ch) -{ - return - (unsigned)(ch - '0') < 10 ? (ch - '0') : - (unsigned)(ch - 'A') < 6 ? (ch - 'A') + 10 : - (unsigned)(ch - 'a') < 6 ? (ch - 'a') + 10 : - -1; -} +static void cgltf_combine_paths(char *path, const char *base, const char *uri) { + const char *s0 = strrchr(base, '/'); + const char *s1 = strrchr(base, '\\'); + const char *slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1; -cgltf_size cgltf_decode_string(char* string) -{ - char* read = string + strcspn(string, "\\"); - if (*read == 0) - { - return read - string; - } - char* write = string; - char* last = string; - - for (;;) - { - // Copy characters since last escaped sequence - cgltf_size written = read - last; - memmove(write, last, written); - write += written; - - if (*read++ == 0) - { - break; - } - - // jsmn already checked that all escape sequences are valid - switch (*read++) - { - case '\"': *write++ = '\"'; break; - case '/': *write++ = '/'; break; - case '\\': *write++ = '\\'; break; - case 'b': *write++ = '\b'; break; - case 'f': *write++ = '\f'; break; - case 'r': *write++ = '\r'; break; - case 'n': *write++ = '\n'; break; - case 't': *write++ = '\t'; break; - case 'u': - { - // UCS-2 codepoint \uXXXX to UTF-8 - int character = 0; - for (cgltf_size i = 0; i < 4; ++i) - { - character = (character << 4) + cgltf_unhex(*read++); - } - - if (character <= 0x7F) - { - *write++ = character & 0xFF; - } - else if (character <= 0x7FF) - { - *write++ = 0xC0 | ((character >> 6) & 0xFF); - *write++ = 0x80 | (character & 0x3F); - } - else - { - *write++ = 0xE0 | ((character >> 12) & 0xFF); - *write++ = 0x80 | ((character >> 6) & 0x3F); - *write++ = 0x80 | (character & 0x3F); - } - break; - } - default: - break; - } - - last = read; - read += strcspn(read, "\\"); - } - - *write = 0; - return write - string; -} + if (slash) { + size_t prefix = slash - base + 1; -cgltf_size cgltf_decode_uri(char* uri) -{ - char* write = uri; - char* i = uri; - - while (*i) - { - if (*i == '%') - { - int ch1 = cgltf_unhex(i[1]); - - if (ch1 >= 0) - { - int ch2 = cgltf_unhex(i[2]); - - if (ch2 >= 0) - { - *write++ = (char)(ch1 * 16 + ch2); - i += 3; - continue; - } - } - } - - *write++ = *i++; - } - - *write = 0; - return write - uri; + strncpy(path, base, prefix); + strcpy(path + prefix, uri); + } else { + strcpy(path, uri); + } } -cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* gltf_path) -{ - if (options == NULL) - { - return cgltf_result_invalid_options; - } - - if (data->buffers_count && data->buffers[0].data == NULL && data->buffers[0].uri == NULL && data->bin) - { - if (data->bin_size < data->buffers[0].size) - { - return cgltf_result_data_too_short; - } - - data->buffers[0].data = (void*)data->bin; - data->buffers[0].data_free_method = cgltf_data_free_method_none; - } - - for (cgltf_size i = 0; i < data->buffers_count; ++i) - { - if (data->buffers[i].data) - { - continue; - } - - const char* uri = data->buffers[i].uri; - - if (uri == NULL) - { - continue; - } - - if (strncmp(uri, "data:", 5) == 0) - { - const char* comma = strchr(uri, ','); - - if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0) - { - cgltf_result res = cgltf_load_buffer_base64(options, data->buffers[i].size, comma + 1, &data->buffers[i].data); - data->buffers[i].data_free_method = cgltf_data_free_method_memory_free; - - if (res != cgltf_result_success) - { - return res; - } - } - else - { - return cgltf_result_unknown_format; - } - } - else if (strstr(uri, "://") == NULL && gltf_path) - { - cgltf_result res = cgltf_load_buffer_file(options, data->buffers[i].size, uri, gltf_path, &data->buffers[i].data); - data->buffers[i].data_free_method = cgltf_data_free_method_file_release; - - if (res != cgltf_result_success) - { - return res; - } - } - else - { - return cgltf_result_unknown_format; - } - } - - return cgltf_result_success; +static cgltf_result cgltf_load_buffer_file(const cgltf_options *options, + cgltf_size size, const char *uri, + const char *gltf_path, + void **out_data) { + void *(*memory_alloc)(void *, cgltf_size) = options->memory.alloc_func + ? options->memory.alloc_func + : &cgltf_default_alloc; + void (*memory_free)(void *, void *) = options->memory.free_func + ? options->memory.free_func + : &cgltf_default_free; + cgltf_result (*file_read)(const struct cgltf_memory_options *, + const struct cgltf_file_options *, const char *, + cgltf_size *, void **) = + options->file.read ? options->file.read : &cgltf_default_file_read; + + char *path = (char *)memory_alloc(options->memory.user_data, + strlen(uri) + strlen(gltf_path) + 1); + if (!path) { + return cgltf_result_out_of_memory; + } + + cgltf_combine_paths(path, gltf_path, uri); + + // after combining, the tail of the resulting path is a uri; decode_uri + // converts it into path + cgltf_decode_uri(path + strlen(path) - strlen(uri)); + + void *file_data = NULL; + cgltf_result result = + file_read(&options->memory, &options->file, path, &size, &file_data); + + memory_free(options->memory.user_data, path); + + *out_data = (result == cgltf_result_success) ? file_data : NULL; + + return result; } -static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type); - -static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count) -{ - char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset; - cgltf_size bound = 0; - - switch (component_type) - { - case cgltf_component_type_r_8u: - for (size_t i = 0; i < count; ++i) - { - cgltf_size v = ((unsigned char*)data)[i]; - bound = bound > v ? bound : v; - } - break; - - case cgltf_component_type_r_16u: - for (size_t i = 0; i < count; ++i) - { - cgltf_size v = ((unsigned short*)data)[i]; - bound = bound > v ? bound : v; - } - break; - - case cgltf_component_type_r_32u: - for (size_t i = 0; i < count; ++i) - { - cgltf_size v = ((unsigned int*)data)[i]; - bound = bound > v ? bound : v; - } - break; - - default: - ; - } - - return bound; +cgltf_result cgltf_load_buffer_base64(const cgltf_options *options, + cgltf_size size, const char *base64, + void **out_data) { + void *(*memory_alloc)(void *, cgltf_size) = options->memory.alloc_func + ? options->memory.alloc_func + : &cgltf_default_alloc; + void (*memory_free)(void *, void *) = options->memory.free_func + ? options->memory.free_func + : &cgltf_default_free; + + unsigned char *data = + (unsigned char *)memory_alloc(options->memory.user_data, size); + if (!data) { + return cgltf_result_out_of_memory; + } + + unsigned int buffer = 0; + unsigned int buffer_bits = 0; + + for (cgltf_size i = 0; i < size; ++i) { + while (buffer_bits < 8) { + char ch = *base64++; + + int index = (unsigned)(ch - 'A') < 26 ? (ch - 'A') + : (unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 + : (unsigned)(ch - '0') < 10 ? (ch - '0') + 52 + : ch == '+' ? 62 + : ch == '/' ? 63 + : -1; + + if (index < 0) { + memory_free(options->memory.user_data, data); + return cgltf_result_io_error; + } + + buffer = (buffer << 6) | index; + buffer_bits += 6; + } + + data[i] = (unsigned char)(buffer >> (buffer_bits - 8)); + buffer_bits -= 8; + } + + *out_data = data; + + return cgltf_result_success; } -#if CGLTF_VALIDATE_ENABLE_ASSERTS -#define CGLTF_ASSERT_IF(cond, result) assert(!(cond)); if (cond) return result; -#else -#define CGLTF_ASSERT_IF(cond, result) if (cond) return result; -#endif - -cgltf_result cgltf_validate(cgltf_data* data) -{ - for (cgltf_size i = 0; i < data->accessors_count; ++i) - { - cgltf_accessor* accessor = &data->accessors[i]; - - cgltf_size element_size = cgltf_calc_size(accessor->type, accessor->component_type); - - if (accessor->buffer_view) - { - cgltf_size req_size = accessor->offset + accessor->stride * (accessor->count - 1) + element_size; - - CGLTF_ASSERT_IF(accessor->buffer_view->size < req_size, cgltf_result_data_too_short); - } - - if (accessor->is_sparse) - { - cgltf_accessor_sparse* sparse = &accessor->sparse; - - cgltf_size indices_component_size = cgltf_calc_size(cgltf_type_scalar, sparse->indices_component_type); - cgltf_size indices_req_size = sparse->indices_byte_offset + indices_component_size * sparse->count; - cgltf_size values_req_size = sparse->values_byte_offset + element_size * sparse->count; - - CGLTF_ASSERT_IF(sparse->indices_buffer_view->size < indices_req_size || - sparse->values_buffer_view->size < values_req_size, cgltf_result_data_too_short); - - CGLTF_ASSERT_IF(sparse->indices_component_type != cgltf_component_type_r_8u && - sparse->indices_component_type != cgltf_component_type_r_16u && - sparse->indices_component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf); - - if (sparse->indices_buffer_view->buffer->data) - { - cgltf_size index_bound = cgltf_calc_index_bound(sparse->indices_buffer_view, sparse->indices_byte_offset, sparse->indices_component_type, sparse->count); - - CGLTF_ASSERT_IF(index_bound >= accessor->count, cgltf_result_data_too_short); - } - } - } - - for (cgltf_size i = 0; i < data->buffer_views_count; ++i) - { - cgltf_size req_size = data->buffer_views[i].offset + data->buffer_views[i].size; - - CGLTF_ASSERT_IF(data->buffer_views[i].buffer && data->buffer_views[i].buffer->size < req_size, cgltf_result_data_too_short); - - if (data->buffer_views[i].has_meshopt_compression) - { - cgltf_meshopt_compression* mc = &data->buffer_views[i].meshopt_compression; - - CGLTF_ASSERT_IF(mc->buffer == NULL || mc->buffer->size < mc->offset + mc->size, cgltf_result_data_too_short); - - CGLTF_ASSERT_IF(data->buffer_views[i].stride && mc->stride != data->buffer_views[i].stride, cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF(data->buffer_views[i].size != mc->stride * mc->count, cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_invalid, cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_attributes && !(mc->stride % 4 == 0 && mc->stride <= 256), cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0, cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->stride != 2 && mc->stride != 4, cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->filter != cgltf_meshopt_compression_filter_none, cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_octahedral && mc->stride != 4 && mc->stride != 8, cgltf_result_invalid_gltf); - - CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_quaternion && mc->stride != 8, cgltf_result_invalid_gltf); - } - } - - for (cgltf_size i = 0; i < data->meshes_count; ++i) - { - if (data->meshes[i].weights) - { - CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].weights_count, cgltf_result_invalid_gltf); - } - - if (data->meshes[i].target_names) - { - CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].target_names_count, cgltf_result_invalid_gltf); - } - - for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) - { - CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets_count != data->meshes[i].primitives[0].targets_count, cgltf_result_invalid_gltf); - - if (data->meshes[i].primitives[j].attributes_count) - { - cgltf_accessor* first = data->meshes[i].primitives[j].attributes[0].data; - - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) - { - CGLTF_ASSERT_IF(data->meshes[i].primitives[j].attributes[k].data->count != first->count, cgltf_result_invalid_gltf); - } - - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) - { - for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) - { - CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets[k].attributes[m].data->count != first->count, cgltf_result_invalid_gltf); - } - } - - cgltf_accessor* indices = data->meshes[i].primitives[j].indices; - - CGLTF_ASSERT_IF(indices && - indices->component_type != cgltf_component_type_r_8u && - indices->component_type != cgltf_component_type_r_16u && - indices->component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf); - - if (indices && indices->buffer_view && indices->buffer_view->buffer->data) - { - cgltf_size index_bound = cgltf_calc_index_bound(indices->buffer_view, indices->offset, indices->component_type, indices->count); +static int cgltf_unhex(char ch) { + return (unsigned)(ch - '0') < 10 ? (ch - '0') + : (unsigned)(ch - 'A') < 6 ? (ch - 'A') + 10 + : (unsigned)(ch - 'a') < 6 ? (ch - 'a') + 10 + : -1; +} - CGLTF_ASSERT_IF(index_bound >= first->count, cgltf_result_data_too_short); - } +cgltf_size cgltf_decode_string(char *string) { + char *read = string + strcspn(string, "\\"); + if (*read == 0) { + return read - string; + } + char *write = string; + char *last = string; + + for (;;) { + // Copy characters since last escaped sequence + cgltf_size written = read - last; + memmove(write, last, written); + write += written; + + if (*read++ == 0) { + break; + } + + // jsmn already checked that all escape sequences are valid + switch (*read++) { + case '\"': + *write++ = '\"'; + break; + case '/': + *write++ = '/'; + break; + case '\\': + *write++ = '\\'; + break; + case 'b': + *write++ = '\b'; + break; + case 'f': + *write++ = '\f'; + break; + case 'r': + *write++ = '\r'; + break; + case 'n': + *write++ = '\n'; + break; + case 't': + *write++ = '\t'; + break; + case 'u': { + // UCS-2 codepoint \uXXXX to UTF-8 + int character = 0; + for (cgltf_size i = 0; i < 4; ++i) { + character = (character << 4) + cgltf_unhex(*read++); + } + + if (character <= 0x7F) { + *write++ = character & 0xFF; + } else if (character <= 0x7FF) { + *write++ = 0xC0 | ((character >> 6) & 0xFF); + *write++ = 0x80 | (character & 0x3F); + } else { + *write++ = 0xE0 | ((character >> 12) & 0xFF); + *write++ = 0x80 | ((character >> 6) & 0x3F); + *write++ = 0x80 | (character & 0x3F); + } + break; + } + default: + break; + } + + last = read; + read += strcspn(read, "\\"); + } + + *write = 0; + return write - string; +} - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k) - { - CGLTF_ASSERT_IF(data->meshes[i].primitives[j].mappings[k].variant >= data->variants_count, cgltf_result_invalid_gltf); - } - } - } - } +cgltf_size cgltf_decode_uri(char *uri) { + char *write = uri; + char *i = uri; - for (cgltf_size i = 0; i < data->nodes_count; ++i) - { - if (data->nodes[i].weights && data->nodes[i].mesh) - { - CGLTF_ASSERT_IF (data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf); - } - } + while (*i) { + if (*i == '%') { + int ch1 = cgltf_unhex(i[1]); - for (cgltf_size i = 0; i < data->nodes_count; ++i) - { - cgltf_node* p1 = data->nodes[i].parent; - cgltf_node* p2 = p1 ? p1->parent : NULL; + if (ch1 >= 0) { + int ch2 = cgltf_unhex(i[2]); - while (p1 && p2) - { - CGLTF_ASSERT_IF(p1 == p2, cgltf_result_invalid_gltf); + if (ch2 >= 0) { + *write++ = (char)(ch1 * 16 + ch2); + i += 3; + continue; + } + } + } - p1 = p1->parent; - p2 = p2->parent ? p2->parent->parent : NULL; - } - } + *write++ = *i++; + } - for (cgltf_size i = 0; i < data->scenes_count; ++i) - { - for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j) - { - CGLTF_ASSERT_IF(data->scenes[i].nodes[j]->parent, cgltf_result_invalid_gltf); - } - } - - for (cgltf_size i = 0; i < data->animations_count; ++i) - { - for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) - { - cgltf_animation_channel* channel = &data->animations[i].channels[j]; - - if (!channel->target_node) - { - continue; - } - - cgltf_size components = 1; - - if (channel->target_path == cgltf_animation_path_type_weights) - { - CGLTF_ASSERT_IF(!channel->target_node->mesh || !channel->target_node->mesh->primitives_count, cgltf_result_invalid_gltf); - - components = channel->target_node->mesh->primitives[0].targets_count; - } - - cgltf_size values = channel->sampler->interpolation == cgltf_interpolation_type_cubic_spline ? 3 : 1; - - CGLTF_ASSERT_IF(channel->sampler->input->count * components * values != channel->sampler->output->count, cgltf_result_data_too_short); - } - } - - return cgltf_result_success; + *write = 0; + return write - uri; } -cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size) -{ - cgltf_size json_size = extras->end_offset - extras->start_offset; - - if (!dest) - { - if (dest_size) - { - *dest_size = json_size + 1; - return cgltf_result_success; - } - return cgltf_result_invalid_options; - } - - if (*dest_size + 1 < json_size) - { - strncpy(dest, data->json + extras->start_offset, *dest_size - 1); - dest[*dest_size - 1] = 0; - } - else - { - strncpy(dest, data->json + extras->start_offset, json_size); - dest[json_size] = 0; - } - - return cgltf_result_success; +cgltf_result cgltf_load_buffers(const cgltf_options *options, cgltf_data *data, + const char *gltf_path) { + if (options == NULL) { + return cgltf_result_invalid_options; + } + + if (data->buffers_count && data->buffers[0].data == NULL && + data->buffers[0].uri == NULL && data->bin) { + if (data->bin_size < data->buffers[0].size) { + return cgltf_result_data_too_short; + } + + data->buffers[0].data = (void *)data->bin; + data->buffers[0].data_free_method = cgltf_data_free_method_none; + } + + for (cgltf_size i = 0; i < data->buffers_count; ++i) { + if (data->buffers[i].data) { + continue; + } + + const char *uri = data->buffers[i].uri; + + if (uri == NULL) { + continue; + } + + if (strncmp(uri, "data:", 5) == 0) { + const char *comma = strchr(uri, ','); + + if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0) { + cgltf_result res = cgltf_load_buffer_base64( + options, data->buffers[i].size, comma + 1, &data->buffers[i].data); + data->buffers[i].data_free_method = cgltf_data_free_method_memory_free; + + if (res != cgltf_result_success) { + return res; + } + } else { + return cgltf_result_unknown_format; + } + } else if (strstr(uri, "://") == NULL && gltf_path) { + cgltf_result res = + cgltf_load_buffer_file(options, data->buffers[i].size, uri, gltf_path, + &data->buffers[i].data); + data->buffers[i].data_free_method = cgltf_data_free_method_file_release; + + if (res != cgltf_result_success) { + return res; + } + } else { + return cgltf_result_unknown_format; + } + } + + return cgltf_result_success; } -void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count) -{ - for (cgltf_size i = 0; i < extensions_count; ++i) - { - data->memory.free_func(data->memory.user_data, extensions[i].name); - data->memory.free_func(data->memory.user_data, extensions[i].data); - } - data->memory.free_func(data->memory.user_data, extensions); +static cgltf_size cgltf_calc_size(cgltf_type type, + cgltf_component_type component_type); + +static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view *buffer_view, + cgltf_size offset, + cgltf_component_type component_type, + cgltf_size count) { + char *data = (char *)buffer_view->buffer->data + offset + buffer_view->offset; + cgltf_size bound = 0; + + switch (component_type) { + case cgltf_component_type_r_8u: + for (size_t i = 0; i < count; ++i) { + cgltf_size v = ((unsigned char *)data)[i]; + bound = bound > v ? bound : v; + } + break; + + case cgltf_component_type_r_16u: + for (size_t i = 0; i < count; ++i) { + cgltf_size v = ((unsigned short *)data)[i]; + bound = bound > v ? bound : v; + } + break; + + case cgltf_component_type_r_32u: + for (size_t i = 0; i < count; ++i) { + cgltf_size v = ((unsigned int *)data)[i]; + bound = bound > v ? bound : v; + } + break; + + default:; + } + + return bound; } -void cgltf_free(cgltf_data* data) -{ - if (!data) - { - return; - } - - void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = data->file.release ? data->file.release : cgltf_default_file_release; +#if CGLTF_VALIDATE_ENABLE_ASSERTS +#define CGLTF_ASSERT_IF(cond, result) \ + assert(!(cond)); \ + if (cond) \ + return result; +#else +#define CGLTF_ASSERT_IF(cond, result) \ + if (cond) \ + return result; +#endif - data->memory.free_func(data->memory.user_data, data->asset.copyright); - data->memory.free_func(data->memory.user_data, data->asset.generator); - data->memory.free_func(data->memory.user_data, data->asset.version); - data->memory.free_func(data->memory.user_data, data->asset.min_version); +cgltf_result cgltf_validate(cgltf_data *data) { + for (cgltf_size i = 0; i < data->accessors_count; ++i) { + cgltf_accessor *accessor = &data->accessors[i]; + + cgltf_size element_size = + cgltf_calc_size(accessor->type, accessor->component_type); + + if (accessor->buffer_view) { + cgltf_size req_size = accessor->offset + + accessor->stride * (accessor->count - 1) + + element_size; + + CGLTF_ASSERT_IF(accessor->buffer_view->size < req_size, + cgltf_result_data_too_short); + } + + if (accessor->is_sparse) { + cgltf_accessor_sparse *sparse = &accessor->sparse; + + cgltf_size indices_component_size = + cgltf_calc_size(cgltf_type_scalar, sparse->indices_component_type); + cgltf_size indices_req_size = + sparse->indices_byte_offset + indices_component_size * sparse->count; + cgltf_size values_req_size = + sparse->values_byte_offset + element_size * sparse->count; + + CGLTF_ASSERT_IF(sparse->indices_buffer_view->size < indices_req_size || + sparse->values_buffer_view->size < values_req_size, + cgltf_result_data_too_short); + + CGLTF_ASSERT_IF( + sparse->indices_component_type != cgltf_component_type_r_8u && + sparse->indices_component_type != cgltf_component_type_r_16u && + sparse->indices_component_type != cgltf_component_type_r_32u, + cgltf_result_invalid_gltf); + + if (sparse->indices_buffer_view->buffer->data) { + cgltf_size index_bound = cgltf_calc_index_bound( + sparse->indices_buffer_view, sparse->indices_byte_offset, + sparse->indices_component_type, sparse->count); + + CGLTF_ASSERT_IF(index_bound >= accessor->count, + cgltf_result_data_too_short); + } + } + } + + for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { + cgltf_size req_size = + data->buffer_views[i].offset + data->buffer_views[i].size; + + CGLTF_ASSERT_IF(data->buffer_views[i].buffer && + data->buffer_views[i].buffer->size < req_size, + cgltf_result_data_too_short); + + if (data->buffer_views[i].has_meshopt_compression) { + cgltf_meshopt_compression *mc = + &data->buffer_views[i].meshopt_compression; + + CGLTF_ASSERT_IF(mc->buffer == NULL || + mc->buffer->size < mc->offset + mc->size, + cgltf_result_data_too_short); + + CGLTF_ASSERT_IF(data->buffer_views[i].stride && + mc->stride != data->buffer_views[i].stride, + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF(data->buffer_views[i].size != mc->stride * mc->count, + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_invalid, + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_attributes && + !(mc->stride % 4 == 0 && mc->stride <= 256), + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_triangles && + mc->count % 3 != 0, + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || + mc->mode == cgltf_meshopt_compression_mode_indices) && + mc->stride != 2 && mc->stride != 4, + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || + mc->mode == cgltf_meshopt_compression_mode_indices) && + mc->filter != cgltf_meshopt_compression_filter_none, + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF(mc->filter == + cgltf_meshopt_compression_filter_octahedral && + mc->stride != 4 && mc->stride != 8, + cgltf_result_invalid_gltf); + + CGLTF_ASSERT_IF(mc->filter == + cgltf_meshopt_compression_filter_quaternion && + mc->stride != 8, + cgltf_result_invalid_gltf); + } + } + + for (cgltf_size i = 0; i < data->meshes_count; ++i) { + if (data->meshes[i].weights) { + CGLTF_ASSERT_IF(data->meshes[i].primitives_count && + data->meshes[i].primitives[0].targets_count != + data->meshes[i].weights_count, + cgltf_result_invalid_gltf); + } + + if (data->meshes[i].target_names) { + CGLTF_ASSERT_IF(data->meshes[i].primitives_count && + data->meshes[i].primitives[0].targets_count != + data->meshes[i].target_names_count, + cgltf_result_invalid_gltf); + } + + for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { + CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets_count != + data->meshes[i].primitives[0].targets_count, + cgltf_result_invalid_gltf); + + if (data->meshes[i].primitives[j].attributes_count) { + cgltf_accessor *first = + data->meshes[i].primitives[j].attributes[0].data; + + for (cgltf_size k = 0; + k < data->meshes[i].primitives[j].attributes_count; ++k) { + CGLTF_ASSERT_IF( + data->meshes[i].primitives[j].attributes[k].data->count != + first->count, + cgltf_result_invalid_gltf); + } + + for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; + ++k) { + for (cgltf_size m = 0; + m < data->meshes[i].primitives[j].targets[k].attributes_count; + ++m) { + CGLTF_ASSERT_IF(data->meshes[i] + .primitives[j] + .targets[k] + .attributes[m] + .data->count != first->count, + cgltf_result_invalid_gltf); + } + } + + cgltf_accessor *indices = data->meshes[i].primitives[j].indices; + + CGLTF_ASSERT_IF( + indices && indices->component_type != cgltf_component_type_r_8u && + indices->component_type != cgltf_component_type_r_16u && + indices->component_type != cgltf_component_type_r_32u, + cgltf_result_invalid_gltf); + + if (indices && indices->buffer_view && + indices->buffer_view->buffer->data) { + cgltf_size index_bound = + cgltf_calc_index_bound(indices->buffer_view, indices->offset, + indices->component_type, indices->count); + + CGLTF_ASSERT_IF(index_bound >= first->count, + cgltf_result_data_too_short); + } + + for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; + ++k) { + CGLTF_ASSERT_IF(data->meshes[i].primitives[j].mappings[k].variant >= + data->variants_count, + cgltf_result_invalid_gltf); + } + } + } + } + + for (cgltf_size i = 0; i < data->nodes_count; ++i) { + if (data->nodes[i].weights && data->nodes[i].mesh) { + CGLTF_ASSERT_IF(data->nodes[i].mesh->primitives_count && + data->nodes[i].mesh->primitives[0].targets_count != + data->nodes[i].weights_count, + cgltf_result_invalid_gltf); + } + } + + for (cgltf_size i = 0; i < data->nodes_count; ++i) { + cgltf_node *p1 = data->nodes[i].parent; + cgltf_node *p2 = p1 ? p1->parent : NULL; + + while (p1 && p2) { + CGLTF_ASSERT_IF(p1 == p2, cgltf_result_invalid_gltf); + + p1 = p1->parent; + p2 = p2->parent ? p2->parent->parent : NULL; + } + } + + for (cgltf_size i = 0; i < data->scenes_count; ++i) { + for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j) { + CGLTF_ASSERT_IF(data->scenes[i].nodes[j]->parent, + cgltf_result_invalid_gltf); + } + } + + for (cgltf_size i = 0; i < data->animations_count; ++i) { + for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) { + cgltf_animation_channel *channel = &data->animations[i].channels[j]; + + if (!channel->target_node) { + continue; + } + + cgltf_size components = 1; + + if (channel->target_path == cgltf_animation_path_type_weights) { + CGLTF_ASSERT_IF(!channel->target_node->mesh || + !channel->target_node->mesh->primitives_count, + cgltf_result_invalid_gltf); + + components = channel->target_node->mesh->primitives[0].targets_count; + } + + cgltf_size values = channel->sampler->interpolation == + cgltf_interpolation_type_cubic_spline + ? 3 + : 1; + + CGLTF_ASSERT_IF(channel->sampler->input->count * components * values != + channel->sampler->output->count, + cgltf_result_data_too_short); + } + } + + return cgltf_result_success; +} - cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count); +cgltf_result cgltf_copy_extras_json(const cgltf_data *data, + const cgltf_extras *extras, char *dest, + cgltf_size *dest_size) { + cgltf_size json_size = extras->end_offset - extras->start_offset; + + if (!dest) { + if (dest_size) { + *dest_size = json_size + 1; + return cgltf_result_success; + } + return cgltf_result_invalid_options; + } + + if (*dest_size + 1 < json_size) { + strncpy(dest, data->json + extras->start_offset, *dest_size - 1); + dest[*dest_size - 1] = 0; + } else { + strncpy(dest, data->json + extras->start_offset, json_size); + dest[json_size] = 0; + } + + return cgltf_result_success; +} - for (cgltf_size i = 0; i < data->accessors_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->accessors[i].name); +void cgltf_free_extensions(cgltf_data *data, cgltf_extension *extensions, + cgltf_size extensions_count) { + for (cgltf_size i = 0; i < extensions_count; ++i) { + data->memory.free_func(data->memory.user_data, extensions[i].name); + data->memory.free_func(data->memory.user_data, extensions[i].data); + } + data->memory.free_func(data->memory.user_data, extensions); +} - if(data->accessors[i].is_sparse) - { - cgltf_free_extensions(data, data->accessors[i].sparse.extensions, data->accessors[i].sparse.extensions_count); - cgltf_free_extensions(data, data->accessors[i].sparse.indices_extensions, data->accessors[i].sparse.indices_extensions_count); - cgltf_free_extensions(data, data->accessors[i].sparse.values_extensions, data->accessors[i].sparse.values_extensions_count); - } - cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count); - } - data->memory.free_func(data->memory.user_data, data->accessors); - - for (cgltf_size i = 0; i < data->buffer_views_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->buffer_views[i].name); - data->memory.free_func(data->memory.user_data, data->buffer_views[i].data); - - cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count); - } - data->memory.free_func(data->memory.user_data, data->buffer_views); - - for (cgltf_size i = 0; i < data->buffers_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->buffers[i].name); - - if (data->buffers[i].data_free_method == cgltf_data_free_method_file_release) - { - file_release(&data->memory, &data->file, data->buffers[i].data); - } - else if (data->buffers[i].data_free_method == cgltf_data_free_method_memory_free) - { - data->memory.free_func(data->memory.user_data, data->buffers[i].data); - } - - data->memory.free_func(data->memory.user_data, data->buffers[i].uri); - - cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->buffers); - - for (cgltf_size i = 0; i < data->meshes_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->meshes[i].name); - - for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) - { - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) - { - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes[k].name); - } - - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes); - - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) - { - for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) - { - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name); - } - - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes); - } - - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets); - - if (data->meshes[i].primitives[j].has_draco_mesh_compression) - { - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++k) - { - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes[k].name); - } - - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes); - } - - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].mappings); - - cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->meshes[i].primitives); - data->memory.free_func(data->memory.user_data, data->meshes[i].weights); - - for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j) - { - data->memory.free_func(data->memory.user_data, data->meshes[i].target_names[j]); - } - - cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count); - - data->memory.free_func(data->memory.user_data, data->meshes[i].target_names); - } - - data->memory.free_func(data->memory.user_data, data->meshes); - - for (cgltf_size i = 0; i < data->materials_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->materials[i].name); - - if(data->materials[i].has_pbr_metallic_roughness) - { - cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions_count); - } - if(data->materials[i].has_pbr_specular_glossiness) - { - cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions_count); - } - if(data->materials[i].has_clearcoat) - { - cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_texture.extensions, data->materials[i].clearcoat.clearcoat_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_normal_texture.extensions, data->materials[i].clearcoat.clearcoat_normal_texture.extensions_count); - } - if(data->materials[i].has_specular) - { - cgltf_free_extensions(data, data->materials[i].specular.specular_texture.extensions, data->materials[i].specular.specular_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].specular.specular_color_texture.extensions, data->materials[i].specular.specular_color_texture.extensions_count); - } - if(data->materials[i].has_transmission) - { - cgltf_free_extensions(data, data->materials[i].transmission.transmission_texture.extensions, data->materials[i].transmission.transmission_texture.extensions_count); - } - if (data->materials[i].has_volume) - { - cgltf_free_extensions(data, data->materials[i].volume.thickness_texture.extensions, data->materials[i].volume.thickness_texture.extensions_count); - } - if(data->materials[i].has_sheen) - { - cgltf_free_extensions(data, data->materials[i].sheen.sheen_color_texture.extensions, data->materials[i].sheen.sheen_color_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].sheen.sheen_roughness_texture.extensions, data->materials[i].sheen.sheen_roughness_texture.extensions_count); - } - if(data->materials[i].has_iridescence) - { - cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_texture.extensions, data->materials[i].iridescence.iridescence_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_thickness_texture.extensions, data->materials[i].iridescence.iridescence_thickness_texture.extensions_count); - } - - cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, data->materials[i].normal_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].occlusion_texture.extensions, data->materials[i].occlusion_texture.extensions_count); - cgltf_free_extensions(data, data->materials[i].emissive_texture.extensions, data->materials[i].emissive_texture.extensions_count); - - cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->materials); - - for (cgltf_size i = 0; i < data->images_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->images[i].name); - data->memory.free_func(data->memory.user_data, data->images[i].uri); - data->memory.free_func(data->memory.user_data, data->images[i].mime_type); - - cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->images); - - for (cgltf_size i = 0; i < data->textures_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->textures[i].name); - cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->textures); - - for (cgltf_size i = 0; i < data->samplers_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->samplers[i].name); - cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->samplers); - - for (cgltf_size i = 0; i < data->skins_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->skins[i].name); - data->memory.free_func(data->memory.user_data, data->skins[i].joints); - - cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->skins); - - for (cgltf_size i = 0; i < data->cameras_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->cameras[i].name); - cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->cameras); - - for (cgltf_size i = 0; i < data->lights_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->lights[i].name); - } - - data->memory.free_func(data->memory.user_data, data->lights); - - for (cgltf_size i = 0; i < data->nodes_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->nodes[i].name); - data->memory.free_func(data->memory.user_data, data->nodes[i].children); - data->memory.free_func(data->memory.user_data, data->nodes[i].weights); - cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->nodes); - - for (cgltf_size i = 0; i < data->scenes_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->scenes[i].name); - data->memory.free_func(data->memory.user_data, data->scenes[i].nodes); - - cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count); - } - - data->memory.free_func(data->memory.user_data, data->scenes); - - for (cgltf_size i = 0; i < data->animations_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->animations[i].name); - for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j) - { - cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count); - } - data->memory.free_func(data->memory.user_data, data->animations[i].samplers); +void cgltf_free(cgltf_data *data) { + if (!data) { + return; + } + + void (*file_release)(const struct cgltf_memory_options *, + const struct cgltf_file_options *, void *data) = + data->file.release ? data->file.release : cgltf_default_file_release; + + data->memory.free_func(data->memory.user_data, data->asset.copyright); + data->memory.free_func(data->memory.user_data, data->asset.generator); + data->memory.free_func(data->memory.user_data, data->asset.version); + data->memory.free_func(data->memory.user_data, data->asset.min_version); + + cgltf_free_extensions(data, data->asset.extensions, + data->asset.extensions_count); + + for (cgltf_size i = 0; i < data->accessors_count; ++i) { + data->memory.free_func(data->memory.user_data, data->accessors[i].name); + + if (data->accessors[i].is_sparse) { + cgltf_free_extensions(data, data->accessors[i].sparse.extensions, + data->accessors[i].sparse.extensions_count); + cgltf_free_extensions(data, data->accessors[i].sparse.indices_extensions, + data->accessors[i].sparse.indices_extensions_count); + cgltf_free_extensions(data, data->accessors[i].sparse.values_extensions, + data->accessors[i].sparse.values_extensions_count); + } + cgltf_free_extensions(data, data->accessors[i].extensions, + data->accessors[i].extensions_count); + } + data->memory.free_func(data->memory.user_data, data->accessors); + + for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { + data->memory.free_func(data->memory.user_data, data->buffer_views[i].name); + data->memory.free_func(data->memory.user_data, data->buffer_views[i].data); + + cgltf_free_extensions(data, data->buffer_views[i].extensions, + data->buffer_views[i].extensions_count); + } + data->memory.free_func(data->memory.user_data, data->buffer_views); + + for (cgltf_size i = 0; i < data->buffers_count; ++i) { + data->memory.free_func(data->memory.user_data, data->buffers[i].name); + + if (data->buffers[i].data_free_method == + cgltf_data_free_method_file_release) { + file_release(&data->memory, &data->file, data->buffers[i].data); + } else if (data->buffers[i].data_free_method == + cgltf_data_free_method_memory_free) { + data->memory.free_func(data->memory.user_data, data->buffers[i].data); + } + + data->memory.free_func(data->memory.user_data, data->buffers[i].uri); + + cgltf_free_extensions(data, data->buffers[i].extensions, + data->buffers[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->buffers); + + for (cgltf_size i = 0; i < data->meshes_count; ++i) { + data->memory.free_func(data->memory.user_data, data->meshes[i].name); + + for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { + for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; + ++k) { + data->memory.free_func( + data->memory.user_data, + data->meshes[i].primitives[j].attributes[k].name); + } + + data->memory.free_func(data->memory.user_data, + data->meshes[i].primitives[j].attributes); + + for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; + ++k) { + for (cgltf_size m = 0; + m < data->meshes[i].primitives[j].targets[k].attributes_count; + ++m) { + data->memory.free_func( + data->memory.user_data, + data->meshes[i].primitives[j].targets[k].attributes[m].name); + } + + data->memory.free_func( + data->memory.user_data, + data->meshes[i].primitives[j].targets[k].attributes); + } + + data->memory.free_func(data->memory.user_data, + data->meshes[i].primitives[j].targets); + + if (data->meshes[i].primitives[j].has_draco_mesh_compression) { + for (cgltf_size k = 0; k < data->meshes[i] + .primitives[j] + .draco_mesh_compression.attributes_count; + ++k) { + data->memory.free_func(data->memory.user_data, + data->meshes[i] + .primitives[j] + .draco_mesh_compression.attributes[k] + .name); + } + + data->memory.free_func( + data->memory.user_data, + data->meshes[i].primitives[j].draco_mesh_compression.attributes); + } + + data->memory.free_func(data->memory.user_data, + data->meshes[i].primitives[j].mappings); + + cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, + data->meshes[i].primitives[j].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->meshes[i].primitives); + data->memory.free_func(data->memory.user_data, data->meshes[i].weights); + + for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j) { + data->memory.free_func(data->memory.user_data, + data->meshes[i].target_names[j]); + } + + cgltf_free_extensions(data, data->meshes[i].extensions, + data->meshes[i].extensions_count); + + data->memory.free_func(data->memory.user_data, + data->meshes[i].target_names); + } + + data->memory.free_func(data->memory.user_data, data->meshes); + + for (cgltf_size i = 0; i < data->materials_count; ++i) { + data->memory.free_func(data->memory.user_data, data->materials[i].name); + + if (data->materials[i].has_pbr_metallic_roughness) { + cgltf_free_extensions( + data, + data->materials[i] + .pbr_metallic_roughness.metallic_roughness_texture.extensions, + data->materials[i] + .pbr_metallic_roughness.metallic_roughness_texture + .extensions_count); + cgltf_free_extensions( + data, + data->materials[i] + .pbr_metallic_roughness.base_color_texture.extensions, + data->materials[i] + .pbr_metallic_roughness.base_color_texture.extensions_count); + } + if (data->materials[i].has_pbr_specular_glossiness) { + cgltf_free_extensions( + data, + data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions, + data->materials[i] + .pbr_specular_glossiness.diffuse_texture.extensions_count); + cgltf_free_extensions( + data, + data->materials[i] + .pbr_specular_glossiness.specular_glossiness_texture.extensions, + data->materials[i] + .pbr_specular_glossiness.specular_glossiness_texture + .extensions_count); + } + if (data->materials[i].has_clearcoat) { + cgltf_free_extensions( + data, data->materials[i].clearcoat.clearcoat_texture.extensions, + data->materials[i].clearcoat.clearcoat_texture.extensions_count); + cgltf_free_extensions( + data, + data->materials[i].clearcoat.clearcoat_roughness_texture.extensions, + data->materials[i] + .clearcoat.clearcoat_roughness_texture.extensions_count); + cgltf_free_extensions( + data, + data->materials[i].clearcoat.clearcoat_normal_texture.extensions, + data->materials[i] + .clearcoat.clearcoat_normal_texture.extensions_count); + } + if (data->materials[i].has_specular) { + cgltf_free_extensions( + data, data->materials[i].specular.specular_texture.extensions, + data->materials[i].specular.specular_texture.extensions_count); + cgltf_free_extensions( + data, data->materials[i].specular.specular_color_texture.extensions, + data->materials[i].specular.specular_color_texture.extensions_count); + } + if (data->materials[i].has_transmission) { + cgltf_free_extensions( + data, data->materials[i].transmission.transmission_texture.extensions, + data->materials[i] + .transmission.transmission_texture.extensions_count); + } + if (data->materials[i].has_volume) { + cgltf_free_extensions( + data, data->materials[i].volume.thickness_texture.extensions, + data->materials[i].volume.thickness_texture.extensions_count); + } + if (data->materials[i].has_sheen) { + cgltf_free_extensions( + data, data->materials[i].sheen.sheen_color_texture.extensions, + data->materials[i].sheen.sheen_color_texture.extensions_count); + cgltf_free_extensions( + data, data->materials[i].sheen.sheen_roughness_texture.extensions, + data->materials[i].sheen.sheen_roughness_texture.extensions_count); + } + if (data->materials[i].has_iridescence) { + cgltf_free_extensions( + data, data->materials[i].iridescence.iridescence_texture.extensions, + data->materials[i].iridescence.iridescence_texture.extensions_count); + cgltf_free_extensions( + data, + data->materials[i] + .iridescence.iridescence_thickness_texture.extensions, + data->materials[i] + .iridescence.iridescence_thickness_texture.extensions_count); + } + + cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, + data->materials[i].normal_texture.extensions_count); + cgltf_free_extensions( + data, data->materials[i].occlusion_texture.extensions, + data->materials[i].occlusion_texture.extensions_count); + cgltf_free_extensions(data, data->materials[i].emissive_texture.extensions, + data->materials[i].emissive_texture.extensions_count); + + cgltf_free_extensions(data, data->materials[i].extensions, + data->materials[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->materials); + + for (cgltf_size i = 0; i < data->images_count; ++i) { + data->memory.free_func(data->memory.user_data, data->images[i].name); + data->memory.free_func(data->memory.user_data, data->images[i].uri); + data->memory.free_func(data->memory.user_data, data->images[i].mime_type); + + cgltf_free_extensions(data, data->images[i].extensions, + data->images[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->images); + + for (cgltf_size i = 0; i < data->textures_count; ++i) { + data->memory.free_func(data->memory.user_data, data->textures[i].name); + cgltf_free_extensions(data, data->textures[i].extensions, + data->textures[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->textures); + + for (cgltf_size i = 0; i < data->samplers_count; ++i) { + data->memory.free_func(data->memory.user_data, data->samplers[i].name); + cgltf_free_extensions(data, data->samplers[i].extensions, + data->samplers[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->samplers); + + for (cgltf_size i = 0; i < data->skins_count; ++i) { + data->memory.free_func(data->memory.user_data, data->skins[i].name); + data->memory.free_func(data->memory.user_data, data->skins[i].joints); + + cgltf_free_extensions(data, data->skins[i].extensions, + data->skins[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->skins); + + for (cgltf_size i = 0; i < data->cameras_count; ++i) { + data->memory.free_func(data->memory.user_data, data->cameras[i].name); + cgltf_free_extensions(data, data->cameras[i].extensions, + data->cameras[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->cameras); + + for (cgltf_size i = 0; i < data->lights_count; ++i) { + data->memory.free_func(data->memory.user_data, data->lights[i].name); + } + + data->memory.free_func(data->memory.user_data, data->lights); + + for (cgltf_size i = 0; i < data->nodes_count; ++i) { + data->memory.free_func(data->memory.user_data, data->nodes[i].name); + data->memory.free_func(data->memory.user_data, data->nodes[i].children); + data->memory.free_func(data->memory.user_data, data->nodes[i].weights); + cgltf_free_extensions(data, data->nodes[i].extensions, + data->nodes[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->nodes); + + for (cgltf_size i = 0; i < data->scenes_count; ++i) { + data->memory.free_func(data->memory.user_data, data->scenes[i].name); + data->memory.free_func(data->memory.user_data, data->scenes[i].nodes); + + cgltf_free_extensions(data, data->scenes[i].extensions, + data->scenes[i].extensions_count); + } + + data->memory.free_func(data->memory.user_data, data->scenes); + + for (cgltf_size i = 0; i < data->animations_count; ++i) { + data->memory.free_func(data->memory.user_data, data->animations[i].name); + for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j) { + cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, + data->animations[i].samplers[j].extensions_count); + } + data->memory.free_func(data->memory.user_data, + data->animations[i].samplers); - for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) - { - cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count); - } - data->memory.free_func(data->memory.user_data, data->animations[i].channels); + for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) { + cgltf_free_extensions(data, data->animations[i].channels[j].extensions, + data->animations[i].channels[j].extensions_count); + } + data->memory.free_func(data->memory.user_data, + data->animations[i].channels); - cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count); - } + cgltf_free_extensions(data, data->animations[i].extensions, + data->animations[i].extensions_count); + } - data->memory.free_func(data->memory.user_data, data->animations); + data->memory.free_func(data->memory.user_data, data->animations); - for (cgltf_size i = 0; i < data->variants_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->variants[i].name); - } + for (cgltf_size i = 0; i < data->variants_count; ++i) { + data->memory.free_func(data->memory.user_data, data->variants[i].name); + } - data->memory.free_func(data->memory.user_data, data->variants); + data->memory.free_func(data->memory.user_data, data->variants); - cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count); + cgltf_free_extensions(data, data->data_extensions, + data->data_extensions_count); - for (cgltf_size i = 0; i < data->extensions_used_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->extensions_used[i]); - } + for (cgltf_size i = 0; i < data->extensions_used_count; ++i) { + data->memory.free_func(data->memory.user_data, data->extensions_used[i]); + } - data->memory.free_func(data->memory.user_data, data->extensions_used); + data->memory.free_func(data->memory.user_data, data->extensions_used); - for (cgltf_size i = 0; i < data->extensions_required_count; ++i) - { - data->memory.free_func(data->memory.user_data, data->extensions_required[i]); - } + for (cgltf_size i = 0; i < data->extensions_required_count; ++i) { + data->memory.free_func(data->memory.user_data, + data->extensions_required[i]); + } - data->memory.free_func(data->memory.user_data, data->extensions_required); + data->memory.free_func(data->memory.user_data, data->extensions_required); - file_release(&data->memory, &data->file, data->file_data); + file_release(&data->memory, &data->file, data->file_data); - data->memory.free_func(data->memory.user_data, data); + data->memory.free_func(data->memory.user_data, data); } -void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix) -{ - cgltf_float* lm = out_matrix; - - if (node->has_matrix) - { - memcpy(lm, node->matrix, sizeof(float) * 16); - } - else - { - float tx = node->translation[0]; - float ty = node->translation[1]; - float tz = node->translation[2]; - - float qx = node->rotation[0]; - float qy = node->rotation[1]; - float qz = node->rotation[2]; - float qw = node->rotation[3]; - - float sx = node->scale[0]; - float sy = node->scale[1]; - float sz = node->scale[2]; - - lm[0] = (1 - 2 * qy*qy - 2 * qz*qz) * sx; - lm[1] = (2 * qx*qy + 2 * qz*qw) * sx; - lm[2] = (2 * qx*qz - 2 * qy*qw) * sx; - lm[3] = 0.f; - - lm[4] = (2 * qx*qy - 2 * qz*qw) * sy; - lm[5] = (1 - 2 * qx*qx - 2 * qz*qz) * sy; - lm[6] = (2 * qy*qz + 2 * qx*qw) * sy; - lm[7] = 0.f; - - lm[8] = (2 * qx*qz + 2 * qy*qw) * sz; - lm[9] = (2 * qy*qz - 2 * qx*qw) * sz; - lm[10] = (1 - 2 * qx*qx - 2 * qy*qy) * sz; - lm[11] = 0.f; - - lm[12] = tx; - lm[13] = ty; - lm[14] = tz; - lm[15] = 1.f; - } +void cgltf_node_transform_local(const cgltf_node *node, + cgltf_float *out_matrix) { + cgltf_float *lm = out_matrix; + + if (node->has_matrix) { + memcpy(lm, node->matrix, sizeof(float) * 16); + } else { + float tx = node->translation[0]; + float ty = node->translation[1]; + float tz = node->translation[2]; + + float qx = node->rotation[0]; + float qy = node->rotation[1]; + float qz = node->rotation[2]; + float qw = node->rotation[3]; + + float sx = node->scale[0]; + float sy = node->scale[1]; + float sz = node->scale[2]; + + lm[0] = (1 - 2 * qy * qy - 2 * qz * qz) * sx; + lm[1] = (2 * qx * qy + 2 * qz * qw) * sx; + lm[2] = (2 * qx * qz - 2 * qy * qw) * sx; + lm[3] = 0.f; + + lm[4] = (2 * qx * qy - 2 * qz * qw) * sy; + lm[5] = (1 - 2 * qx * qx - 2 * qz * qz) * sy; + lm[6] = (2 * qy * qz + 2 * qx * qw) * sy; + lm[7] = 0.f; + + lm[8] = (2 * qx * qz + 2 * qy * qw) * sz; + lm[9] = (2 * qy * qz - 2 * qx * qw) * sz; + lm[10] = (1 - 2 * qx * qx - 2 * qy * qy) * sz; + lm[11] = 0.f; + + lm[12] = tx; + lm[13] = ty; + lm[14] = tz; + lm[15] = 1.f; + } } -void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix) -{ - cgltf_float* lm = out_matrix; - cgltf_node_transform_local(node, lm); +void cgltf_node_transform_world(const cgltf_node *node, + cgltf_float *out_matrix) { + cgltf_float *lm = out_matrix; + cgltf_node_transform_local(node, lm); - const cgltf_node* parent = node->parent; + const cgltf_node *parent = node->parent; - while (parent) - { - float pm[16]; - cgltf_node_transform_local(parent, pm); + while (parent) { + float pm[16]; + cgltf_node_transform_local(parent, pm); - for (int i = 0; i < 4; ++i) - { - float l0 = lm[i * 4 + 0]; - float l1 = lm[i * 4 + 1]; - float l2 = lm[i * 4 + 2]; + for (int i = 0; i < 4; ++i) { + float l0 = lm[i * 4 + 0]; + float l1 = lm[i * 4 + 1]; + float l2 = lm[i * 4 + 2]; - float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8]; - float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9]; - float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10]; + float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8]; + float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9]; + float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10]; - lm[i * 4 + 0] = r0; - lm[i * 4 + 1] = r1; - lm[i * 4 + 2] = r2; - } + lm[i * 4 + 0] = r0; + lm[i * 4 + 1] = r1; + lm[i * 4 + 2] = r2; + } - lm[12] += pm[12]; - lm[13] += pm[13]; - lm[14] += pm[14]; + lm[12] += pm[12]; + lm[13] += pm[13]; + lm[14] += pm[14]; - parent = parent->parent; - } + parent = parent->parent; + } } -static cgltf_ssize cgltf_component_read_integer(const void* in, cgltf_component_type component_type) -{ - switch (component_type) - { - case cgltf_component_type_r_16: - return *((const int16_t*) in); - case cgltf_component_type_r_16u: - return *((const uint16_t*) in); - case cgltf_component_type_r_32u: - return *((const uint32_t*) in); - case cgltf_component_type_r_32f: - return (cgltf_ssize)*((const float*) in); - case cgltf_component_type_r_8: - return *((const int8_t*) in); - case cgltf_component_type_r_8u: - return *((const uint8_t*) in); - default: - return 0; - } +static cgltf_ssize +cgltf_component_read_integer(const void *in, + cgltf_component_type component_type) { + switch (component_type) { + case cgltf_component_type_r_16: + return *((const int16_t *)in); + case cgltf_component_type_r_16u: + return *((const uint16_t *)in); + case cgltf_component_type_r_32u: + return *((const uint32_t *)in); + case cgltf_component_type_r_32f: + return (cgltf_ssize) * ((const float *)in); + case cgltf_component_type_r_8: + return *((const int8_t *)in); + case cgltf_component_type_r_8u: + return *((const uint8_t *)in); + default: + return 0; + } } -static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type) -{ - switch (component_type) - { - case cgltf_component_type_r_16u: - return *((const uint16_t*) in); - case cgltf_component_type_r_32u: - return *((const uint32_t*) in); - case cgltf_component_type_r_32f: - return (cgltf_size)*((const float*) in); - case cgltf_component_type_r_8u: - return *((const uint8_t*) in); - default: - return 0; - } +static cgltf_size +cgltf_component_read_index(const void *in, + cgltf_component_type component_type) { + switch (component_type) { + case cgltf_component_type_r_16u: + return *((const uint16_t *)in); + case cgltf_component_type_r_32u: + return *((const uint32_t *)in); + case cgltf_component_type_r_32f: + return (cgltf_size) * ((const float *)in); + case cgltf_component_type_r_8u: + return *((const uint8_t *)in); + default: + return 0; + } } -static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized) -{ - if (component_type == cgltf_component_type_r_32f) - { - return *((const float*) in); - } - - if (normalized) - { - switch (component_type) - { - // note: glTF spec doesn't currently define normalized conversions for 32-bit integers - case cgltf_component_type_r_16: - return *((const int16_t*) in) / (cgltf_float)32767; - case cgltf_component_type_r_16u: - return *((const uint16_t*) in) / (cgltf_float)65535; - case cgltf_component_type_r_8: - return *((const int8_t*) in) / (cgltf_float)127; - case cgltf_component_type_r_8u: - return *((const uint8_t*) in) / (cgltf_float)255; - default: - return 0; - } - } - - return (cgltf_float)cgltf_component_read_integer(in, component_type); +static cgltf_float +cgltf_component_read_float(const void *in, cgltf_component_type component_type, + cgltf_bool normalized) { + if (component_type == cgltf_component_type_r_32f) { + return *((const float *)in); + } + + if (normalized) { + switch (component_type) { + // note: glTF spec doesn't currently define normalized conversions for + // 32-bit integers + case cgltf_component_type_r_16: + return *((const int16_t *)in) / (cgltf_float)32767; + case cgltf_component_type_r_16u: + return *((const uint16_t *)in) / (cgltf_float)65535; + case cgltf_component_type_r_8: + return *((const int8_t *)in) / (cgltf_float)127; + case cgltf_component_type_r_8u: + return *((const uint8_t *)in) / (cgltf_float)255; + default: + return 0; + } + } + + return (cgltf_float)cgltf_component_read_integer(in, component_type); } static cgltf_size cgltf_component_size(cgltf_component_type component_type); -static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size) -{ - cgltf_size num_components = cgltf_num_components(type); - - if (element_size < num_components) { - return 0; - } - - // There are three special cases for component extraction, see #data-alignment in the 2.0 spec. - - cgltf_size component_size = cgltf_component_size(component_type); - - if (type == cgltf_type_mat2 && component_size == 1) - { - out[0] = cgltf_component_read_float(element, component_type, normalized); - out[1] = cgltf_component_read_float(element + 1, component_type, normalized); - out[2] = cgltf_component_read_float(element + 4, component_type, normalized); - out[3] = cgltf_component_read_float(element + 5, component_type, normalized); - return 1; - } - - if (type == cgltf_type_mat3 && component_size == 1) - { - out[0] = cgltf_component_read_float(element, component_type, normalized); - out[1] = cgltf_component_read_float(element + 1, component_type, normalized); - out[2] = cgltf_component_read_float(element + 2, component_type, normalized); - out[3] = cgltf_component_read_float(element + 4, component_type, normalized); - out[4] = cgltf_component_read_float(element + 5, component_type, normalized); - out[5] = cgltf_component_read_float(element + 6, component_type, normalized); - out[6] = cgltf_component_read_float(element + 8, component_type, normalized); - out[7] = cgltf_component_read_float(element + 9, component_type, normalized); - out[8] = cgltf_component_read_float(element + 10, component_type, normalized); - return 1; - } - - if (type == cgltf_type_mat3 && component_size == 2) - { - out[0] = cgltf_component_read_float(element, component_type, normalized); - out[1] = cgltf_component_read_float(element + 2, component_type, normalized); - out[2] = cgltf_component_read_float(element + 4, component_type, normalized); - out[3] = cgltf_component_read_float(element + 8, component_type, normalized); - out[4] = cgltf_component_read_float(element + 10, component_type, normalized); - out[5] = cgltf_component_read_float(element + 12, component_type, normalized); - out[6] = cgltf_component_read_float(element + 16, component_type, normalized); - out[7] = cgltf_component_read_float(element + 18, component_type, normalized); - out[8] = cgltf_component_read_float(element + 20, component_type, normalized); - return 1; - } - - for (cgltf_size i = 0; i < num_components; ++i) - { - out[i] = cgltf_component_read_float(element + component_size * i, component_type, normalized); - } - return 1; +static cgltf_bool cgltf_element_read_float(const uint8_t *element, + cgltf_type type, + cgltf_component_type component_type, + cgltf_bool normalized, + cgltf_float *out, + cgltf_size element_size) { + cgltf_size num_components = cgltf_num_components(type); + + if (element_size < num_components) { + return 0; + } + + // There are three special cases for component extraction, see #data-alignment + // in the 2.0 spec. + + cgltf_size component_size = cgltf_component_size(component_type); + + if (type == cgltf_type_mat2 && component_size == 1) { + out[0] = cgltf_component_read_float(element, component_type, normalized); + out[1] = + cgltf_component_read_float(element + 1, component_type, normalized); + out[2] = + cgltf_component_read_float(element + 4, component_type, normalized); + out[3] = + cgltf_component_read_float(element + 5, component_type, normalized); + return 1; + } + + if (type == cgltf_type_mat3 && component_size == 1) { + out[0] = cgltf_component_read_float(element, component_type, normalized); + out[1] = + cgltf_component_read_float(element + 1, component_type, normalized); + out[2] = + cgltf_component_read_float(element + 2, component_type, normalized); + out[3] = + cgltf_component_read_float(element + 4, component_type, normalized); + out[4] = + cgltf_component_read_float(element + 5, component_type, normalized); + out[5] = + cgltf_component_read_float(element + 6, component_type, normalized); + out[6] = + cgltf_component_read_float(element + 8, component_type, normalized); + out[7] = + cgltf_component_read_float(element + 9, component_type, normalized); + out[8] = + cgltf_component_read_float(element + 10, component_type, normalized); + return 1; + } + + if (type == cgltf_type_mat3 && component_size == 2) { + out[0] = cgltf_component_read_float(element, component_type, normalized); + out[1] = + cgltf_component_read_float(element + 2, component_type, normalized); + out[2] = + cgltf_component_read_float(element + 4, component_type, normalized); + out[3] = + cgltf_component_read_float(element + 8, component_type, normalized); + out[4] = + cgltf_component_read_float(element + 10, component_type, normalized); + out[5] = + cgltf_component_read_float(element + 12, component_type, normalized); + out[6] = + cgltf_component_read_float(element + 16, component_type, normalized); + out[7] = + cgltf_component_read_float(element + 18, component_type, normalized); + out[8] = + cgltf_component_read_float(element + 20, component_type, normalized); + return 1; + } + + for (cgltf_size i = 0; i < num_components; ++i) { + out[i] = cgltf_component_read_float(element + component_size * i, + component_type, normalized); + } + return 1; } -const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view) -{ - if (view->data) - return (const uint8_t*)view->data; +const uint8_t *cgltf_buffer_view_data(const cgltf_buffer_view *view) { + if (view->data) + return (const uint8_t *)view->data; - if (!view->buffer->data) - return NULL; + if (!view->buffer->data) + return NULL; - const uint8_t* result = (const uint8_t*)view->buffer->data; - result += view->offset; - return result; + const uint8_t *result = (const uint8_t *)view->buffer->data; + result += view->offset; + return result; } -cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size) -{ - if (accessor->is_sparse) - { - return 0; - } - if (accessor->buffer_view == NULL) - { - memset(out, 0, element_size * sizeof(cgltf_float)); - return 1; - } - const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view); - if (element == NULL) - { - return 0; - } - element += accessor->offset + accessor->stride * index; - return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size); +cgltf_bool cgltf_accessor_read_float(const cgltf_accessor *accessor, + cgltf_size index, cgltf_float *out, + cgltf_size element_size) { + if (accessor->is_sparse) { + return 0; + } + if (accessor->buffer_view == NULL) { + memset(out, 0, element_size * sizeof(cgltf_float)); + return 1; + } + const uint8_t *element = cgltf_buffer_view_data(accessor->buffer_view); + if (element == NULL) { + return 0; + } + element += accessor->offset + accessor->stride * index; + return cgltf_element_read_float(element, accessor->type, + accessor->component_type, + accessor->normalized, out, element_size); } -cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count) -{ - cgltf_size floats_per_element = cgltf_num_components(accessor->type); - cgltf_size available_floats = accessor->count * floats_per_element; - if (out == NULL) - { - return available_floats; - } - - float_count = available_floats < float_count ? available_floats : float_count; - cgltf_size element_count = float_count / floats_per_element; - - // First pass: convert each element in the base accessor. - cgltf_float* dest = out; - cgltf_accessor dense = *accessor; - dense.is_sparse = 0; - for (cgltf_size index = 0; index < element_count; index++, dest += floats_per_element) - { - if (!cgltf_accessor_read_float(&dense, index, dest, floats_per_element)) - { - return 0; - } - } - - // Second pass: write out each element in the sparse accessor. - if (accessor->is_sparse) - { - const cgltf_accessor_sparse* sparse = &dense.sparse; - - const uint8_t* index_data = cgltf_buffer_view_data(sparse->indices_buffer_view); - const uint8_t* reader_head = cgltf_buffer_view_data(sparse->values_buffer_view); - - if (index_data == NULL || reader_head == NULL) - { - return 0; - } - - index_data += sparse->indices_byte_offset; - reader_head += sparse->values_byte_offset; - - cgltf_size index_stride = cgltf_component_size(sparse->indices_component_type); - for (cgltf_size reader_index = 0; reader_index < sparse->count; reader_index++, index_data += index_stride) - { - size_t writer_index = cgltf_component_read_index(index_data, sparse->indices_component_type); - float* writer_head = out + writer_index * floats_per_element; - - if (!cgltf_element_read_float(reader_head, dense.type, dense.component_type, dense.normalized, writer_head, floats_per_element)) - { - return 0; - } - - reader_head += dense.stride; - } - } - - return element_count * floats_per_element; +cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor *accessor, + cgltf_float *out, + cgltf_size float_count) { + cgltf_size floats_per_element = cgltf_num_components(accessor->type); + cgltf_size available_floats = accessor->count * floats_per_element; + if (out == NULL) { + return available_floats; + } + + float_count = available_floats < float_count ? available_floats : float_count; + cgltf_size element_count = float_count / floats_per_element; + + // First pass: convert each element in the base accessor. + cgltf_float *dest = out; + cgltf_accessor dense = *accessor; + dense.is_sparse = 0; + for (cgltf_size index = 0; index < element_count; + index++, dest += floats_per_element) { + if (!cgltf_accessor_read_float(&dense, index, dest, floats_per_element)) { + return 0; + } + } + + // Second pass: write out each element in the sparse accessor. + if (accessor->is_sparse) { + const cgltf_accessor_sparse *sparse = &dense.sparse; + + const uint8_t *index_data = + cgltf_buffer_view_data(sparse->indices_buffer_view); + const uint8_t *reader_head = + cgltf_buffer_view_data(sparse->values_buffer_view); + + if (index_data == NULL || reader_head == NULL) { + return 0; + } + + index_data += sparse->indices_byte_offset; + reader_head += sparse->values_byte_offset; + + cgltf_size index_stride = + cgltf_component_size(sparse->indices_component_type); + for (cgltf_size reader_index = 0; reader_index < sparse->count; + reader_index++, index_data += index_stride) { + size_t writer_index = cgltf_component_read_index( + index_data, sparse->indices_component_type); + float *writer_head = out + writer_index * floats_per_element; + + if (!cgltf_element_read_float(reader_head, dense.type, + dense.component_type, dense.normalized, + writer_head, floats_per_element)) { + return 0; + } + + reader_head += dense.stride; + } + } + + return element_count * floats_per_element; } -static cgltf_uint cgltf_component_read_uint(const void* in, cgltf_component_type component_type) -{ - switch (component_type) - { - case cgltf_component_type_r_8: - return *((const int8_t*) in); +static cgltf_uint +cgltf_component_read_uint(const void *in, cgltf_component_type component_type) { + switch (component_type) { + case cgltf_component_type_r_8: + return *((const int8_t *)in); - case cgltf_component_type_r_8u: - return *((const uint8_t*) in); + case cgltf_component_type_r_8u: + return *((const uint8_t *)in); - case cgltf_component_type_r_16: - return *((const int16_t*) in); + case cgltf_component_type_r_16: + return *((const int16_t *)in); - case cgltf_component_type_r_16u: - return *((const uint16_t*) in); + case cgltf_component_type_r_16u: + return *((const uint16_t *)in); - case cgltf_component_type_r_32u: - return *((const uint32_t*) in); + case cgltf_component_type_r_32u: + return *((const uint32_t *)in); - default: - return 0; - } + default: + return 0; + } } -static cgltf_bool cgltf_element_read_uint(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_uint* out, cgltf_size element_size) -{ - cgltf_size num_components = cgltf_num_components(type); - - if (element_size < num_components) - { - return 0; - } - - // Reading integer matrices is not a valid use case - if (type == cgltf_type_mat2 || type == cgltf_type_mat3 || type == cgltf_type_mat4) - { - return 0; - } - - cgltf_size component_size = cgltf_component_size(component_type); - - for (cgltf_size i = 0; i < num_components; ++i) - { - out[i] = cgltf_component_read_uint(element + component_size * i, component_type); - } - return 1; +static cgltf_bool cgltf_element_read_uint(const uint8_t *element, + cgltf_type type, + cgltf_component_type component_type, + cgltf_uint *out, + cgltf_size element_size) { + cgltf_size num_components = cgltf_num_components(type); + + if (element_size < num_components) { + return 0; + } + + // Reading integer matrices is not a valid use case + if (type == cgltf_type_mat2 || type == cgltf_type_mat3 || + type == cgltf_type_mat4) { + return 0; + } + + cgltf_size component_size = cgltf_component_size(component_type); + + for (cgltf_size i = 0; i < num_components; ++i) { + out[i] = + cgltf_component_read_uint(element + component_size * i, component_type); + } + return 1; } -cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size) -{ - if (accessor->is_sparse) - { - return 0; - } - if (accessor->buffer_view == NULL) - { - memset(out, 0, element_size * sizeof( cgltf_uint )); - return 1; - } - const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view); - if (element == NULL) - { - return 0; - } - element += accessor->offset + accessor->stride * index; - return cgltf_element_read_uint(element, accessor->type, accessor->component_type, out, element_size); +cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor *accessor, + cgltf_size index, cgltf_uint *out, + cgltf_size element_size) { + if (accessor->is_sparse) { + return 0; + } + if (accessor->buffer_view == NULL) { + memset(out, 0, element_size * sizeof(cgltf_uint)); + return 1; + } + const uint8_t *element = cgltf_buffer_view_data(accessor->buffer_view); + if (element == NULL) { + return 0; + } + element += accessor->offset + accessor->stride * index; + return cgltf_element_read_uint(element, accessor->type, + accessor->component_type, out, element_size); } -cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index) -{ - if (accessor->is_sparse) - { - return 0; // This is an error case, but we can't communicate the error with existing interface. - } - if (accessor->buffer_view == NULL) - { - return 0; - } - const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view); - if (element == NULL) - { - return 0; // This is an error case, but we can't communicate the error with existing interface. - } - element += accessor->offset + accessor->stride * index; - return cgltf_component_read_index(element, accessor->component_type); +cgltf_size cgltf_accessor_read_index(const cgltf_accessor *accessor, + cgltf_size index) { + if (accessor->is_sparse) { + return 0; // This is an error case, but we can't communicate the error with + // existing interface. + } + if (accessor->buffer_view == NULL) { + return 0; + } + const uint8_t *element = cgltf_buffer_view_data(accessor->buffer_view); + if (element == NULL) { + return 0; // This is an error case, but we can't communicate the error with + // existing interface. + } + element += accessor->offset + accessor->stride * index; + return cgltf_component_read_index(element, accessor->component_type); } #define CGLTF_ERROR_JSON -1 #define CGLTF_ERROR_NOMEM -2 #define CGLTF_ERROR_LEGACY -3 -#define CGLTF_CHECK_TOKTYPE(tok_, type_) if ((tok_).type != (type_)) { return CGLTF_ERROR_JSON; } -#define CGLTF_CHECK_TOKTYPE_RETTYPE(tok_, type_, ret_) if ((tok_).type != (type_)) { return (ret_)CGLTF_ERROR_JSON; } -#define CGLTF_CHECK_KEY(tok_) if ((tok_).type != JSMN_STRING || (tok_).size == 0) { return CGLTF_ERROR_JSON; } /* checking size for 0 verifies that a value follows the key */ - -#define CGLTF_PTRINDEX(type, idx) (type*)((cgltf_size)idx + 1) -#define CGLTF_PTRFIXUP(var, data, size) if (var) { if ((cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; } -#define CGLTF_PTRFIXUP_REQ(var, data, size) if (!var || (cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; - -static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, const char* str) -{ - CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING); - size_t const str_len = strlen(str); - size_t const name_length = tok->end - tok->start; - return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128; +#define CGLTF_CHECK_TOKTYPE(tok_, type_) \ + if ((tok_).type != (type_)) { \ + return CGLTF_ERROR_JSON; \ + } +#define CGLTF_CHECK_TOKTYPE_RETTYPE(tok_, type_, ret_) \ + if ((tok_).type != (type_)) { \ + return (ret_)CGLTF_ERROR_JSON; \ + } +#define CGLTF_CHECK_KEY(tok_) \ + if ((tok_).type != JSMN_STRING || (tok_).size == 0) { \ + return CGLTF_ERROR_JSON; \ + } /* checking size for 0 verifies that a value follows the key */ + +#define CGLTF_PTRINDEX(type, idx) (type *)((cgltf_size)idx + 1) +#define CGLTF_PTRFIXUP(var, data, size) \ + if (var) { \ + if ((cgltf_size)var > size) { \ + return CGLTF_ERROR_JSON; \ + } \ + var = &data[(cgltf_size)var - 1]; \ + } +#define CGLTF_PTRFIXUP_REQ(var, data, size) \ + if (!var || (cgltf_size)var > size) { \ + return CGLTF_ERROR_JSON; \ + } \ + var = &data[(cgltf_size)var - 1]; + +static int cgltf_json_strcmp(jsmntok_t const *tok, const uint8_t *json_chunk, + const char *str) { + CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING); + size_t const str_len = strlen(str); + size_t const name_length = tok->end - tok->start; + return (str_len == name_length) + ? strncmp((const char *)json_chunk + tok->start, str, str_len) + : 128; } -static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk) -{ - CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); - char tmp[128]; - int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1); - strncpy(tmp, (const char*)json_chunk + tok->start, size); - tmp[size] = 0; - return CGLTF_ATOI(tmp); +static int cgltf_json_to_int(jsmntok_t const *tok, const uint8_t *json_chunk) { + CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); + char tmp[128]; + int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) + ? tok->end - tok->start + : (int)(sizeof(tmp) - 1); + strncpy(tmp, (const char *)json_chunk + tok->start, size); + tmp[size] = 0; + return CGLTF_ATOI(tmp); } -static cgltf_size cgltf_json_to_size(jsmntok_t const* tok, const uint8_t* json_chunk) -{ - CGLTF_CHECK_TOKTYPE_RETTYPE(*tok, JSMN_PRIMITIVE, cgltf_size); - char tmp[128]; - int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1); - strncpy(tmp, (const char*)json_chunk + tok->start, size); - tmp[size] = 0; - return (cgltf_size)CGLTF_ATOLL(tmp); +static cgltf_size cgltf_json_to_size(jsmntok_t const *tok, + const uint8_t *json_chunk) { + CGLTF_CHECK_TOKTYPE_RETTYPE(*tok, JSMN_PRIMITIVE, cgltf_size); + char tmp[128]; + int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) + ? tok->end - tok->start + : (int)(sizeof(tmp) - 1); + strncpy(tmp, (const char *)json_chunk + tok->start, size); + tmp[size] = 0; + return (cgltf_size)CGLTF_ATOLL(tmp); } -static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json_chunk) -{ - CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); - char tmp[128]; - int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1); - strncpy(tmp, (const char*)json_chunk + tok->start, size); - tmp[size] = 0; - return (cgltf_float)CGLTF_ATOF(tmp); +static cgltf_float cgltf_json_to_float(jsmntok_t const *tok, + const uint8_t *json_chunk) { + CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE); + char tmp[128]; + int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) + ? tok->end - tok->start + : (int)(sizeof(tmp) - 1); + strncpy(tmp, (const char *)json_chunk + tok->start, size); + tmp[size] = 0; + return (cgltf_float)CGLTF_ATOF(tmp); } -static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk) -{ - int size = tok->end - tok->start; - return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0; +static cgltf_bool cgltf_json_to_bool(jsmntok_t const *tok, + const uint8_t *json_chunk) { + int size = tok->end - tok->start; + return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0; } -static int cgltf_skip_json(jsmntok_t const* tokens, int i) -{ - int end = i + 1; +static int cgltf_skip_json(jsmntok_t const *tokens, int i) { + int end = i + 1; - while (i < end) - { - switch (tokens[i].type) - { - case JSMN_OBJECT: - end += tokens[i].size * 2; - break; + while (i < end) { + switch (tokens[i].type) { + case JSMN_OBJECT: + end += tokens[i].size * 2; + break; - case JSMN_ARRAY: - end += tokens[i].size; - break; + case JSMN_ARRAY: + end += tokens[i].size; + break; - case JSMN_PRIMITIVE: - case JSMN_STRING: - break; + case JSMN_PRIMITIVE: + case JSMN_STRING: + break; - default: - return -1; - } + default: + return -1; + } - i++; - } + i++; + } - return i; + return i; } -static void cgltf_fill_float_array(float* out_array, int size, float value) -{ - for (int j = 0; j < size; ++j) - { - out_array[j] = value; - } +static void cgltf_fill_float_array(float *out_array, int size, float value) { + for (int j = 0; j < size; ++j) { + out_array[j] = value; + } } -static int cgltf_parse_json_float_array(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, float* out_array, int size) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); - if (tokens[i].size != size) - { - return CGLTF_ERROR_JSON; - } - ++i; - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); - out_array[j] = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - return i; +static int cgltf_parse_json_float_array(jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + float *out_array, int size) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); + if (tokens[i].size != size) { + return CGLTF_ERROR_JSON; + } + ++i; + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); + out_array[j] = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } + return i; } -static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char** out_string) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING); - if (*out_string) - { - return CGLTF_ERROR_JSON; - } - int size = tokens[i].end - tokens[i].start; - char* result = (char*)options->memory.alloc_func(options->memory.user_data, size + 1); - if (!result) - { - return CGLTF_ERROR_NOMEM; - } - strncpy(result, (const char*)json_chunk + tokens[i].start, size); - result[size] = 0; - *out_string = result; - return i + 1; +static int cgltf_parse_json_string(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + char **out_string) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING); + if (*out_string) { + return CGLTF_ERROR_JSON; + } + int size = tokens[i].end - tokens[i].start; + char *result = + (char *)options->memory.alloc_func(options->memory.user_data, size + 1); + if (!result) { + return CGLTF_ERROR_NOMEM; + } + strncpy(result, (const char *)json_chunk + tokens[i].start, size); + result[size] = 0; + *out_string = result; + return i + 1; } -static int cgltf_parse_json_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, size_t element_size, void** out_array, cgltf_size* out_size) -{ - (void)json_chunk; - if (tokens[i].type != JSMN_ARRAY) - { - return tokens[i].type == JSMN_OBJECT ? CGLTF_ERROR_LEGACY : CGLTF_ERROR_JSON; - } - if (*out_array) - { - return CGLTF_ERROR_JSON; - } - int size = tokens[i].size; - void* result = cgltf_calloc(options, element_size, size); - if (!result) - { - return CGLTF_ERROR_NOMEM; - } - *out_array = result; - *out_size = size; - return i + 1; +static int cgltf_parse_json_array(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + size_t element_size, void **out_array, + cgltf_size *out_size) { + (void)json_chunk; + if (tokens[i].type != JSMN_ARRAY) { + return tokens[i].type == JSMN_OBJECT ? CGLTF_ERROR_LEGACY + : CGLTF_ERROR_JSON; + } + if (*out_array) { + return CGLTF_ERROR_JSON; + } + int size = tokens[i].size; + void *result = cgltf_calloc(options, element_size, size); + if (!result) { + return CGLTF_ERROR_NOMEM; + } + *out_array = result; + *out_size = size; + return i + 1; } -static int cgltf_parse_json_string_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char*** out_array, cgltf_size* out_size) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(char*), (void**)out_array, out_size); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < *out_size; ++j) - { - i = cgltf_parse_json_string(options, tokens, i, json_chunk, j + (*out_array)); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_string_array(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + char ***out_array, + cgltf_size *out_size) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); + i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(char *), + (void **)out_array, out_size); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < *out_size; ++j) { + i = cgltf_parse_json_string(options, tokens, i, json_chunk, + j + (*out_array)); + if (i < 0) { + return i; + } + } + return i; } -static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index) -{ - if (*name == '_') - { - *out_type = cgltf_attribute_type_custom; - return; - } - - const char* us = strchr(name, '_'); - size_t len = us ? (size_t)(us - name) : strlen(name); - - if (len == 8 && strncmp(name, "POSITION", 8) == 0) - { - *out_type = cgltf_attribute_type_position; - } - else if (len == 6 && strncmp(name, "NORMAL", 6) == 0) - { - *out_type = cgltf_attribute_type_normal; - } - else if (len == 7 && strncmp(name, "TANGENT", 7) == 0) - { - *out_type = cgltf_attribute_type_tangent; - } - else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0) - { - *out_type = cgltf_attribute_type_texcoord; - } - else if (len == 5 && strncmp(name, "COLOR", 5) == 0) - { - *out_type = cgltf_attribute_type_color; - } - else if (len == 6 && strncmp(name, "JOINTS", 6) == 0) - { - *out_type = cgltf_attribute_type_joints; - } - else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0) - { - *out_type = cgltf_attribute_type_weights; - } - else - { - *out_type = cgltf_attribute_type_invalid; - } - - if (us && *out_type != cgltf_attribute_type_invalid) - { - *out_index = CGLTF_ATOI(us + 1); - } +static void cgltf_parse_attribute_type(const char *name, + cgltf_attribute_type *out_type, + int *out_index) { + if (*name == '_') { + *out_type = cgltf_attribute_type_custom; + return; + } + + const char *us = strchr(name, '_'); + size_t len = us ? (size_t)(us - name) : strlen(name); + + if (len == 8 && strncmp(name, "POSITION", 8) == 0) { + *out_type = cgltf_attribute_type_position; + } else if (len == 6 && strncmp(name, "NORMAL", 6) == 0) { + *out_type = cgltf_attribute_type_normal; + } else if (len == 7 && strncmp(name, "TANGENT", 7) == 0) { + *out_type = cgltf_attribute_type_tangent; + } else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0) { + *out_type = cgltf_attribute_type_texcoord; + } else if (len == 5 && strncmp(name, "COLOR", 5) == 0) { + *out_type = cgltf_attribute_type_color; + } else if (len == 6 && strncmp(name, "JOINTS", 6) == 0) { + *out_type = cgltf_attribute_type_joints; + } else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0) { + *out_type = cgltf_attribute_type_weights; + } else { + *out_type = cgltf_attribute_type_invalid; + } + + if (us && *out_type != cgltf_attribute_type_invalid) { + *out_index = CGLTF_ATOI(us + 1); + } } -static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_attribute** out_attributes, cgltf_size* out_attributes_count) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - if (*out_attributes) - { - return CGLTF_ERROR_JSON; - } - - *out_attributes_count = tokens[i].size; - *out_attributes = (cgltf_attribute*)cgltf_calloc(options, sizeof(cgltf_attribute), *out_attributes_count); - ++i; - - if (!*out_attributes) - { - return CGLTF_ERROR_NOMEM; - } - - for (cgltf_size j = 0; j < *out_attributes_count; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - i = cgltf_parse_json_string(options, tokens, i, json_chunk, &(*out_attributes)[j].name); - if (i < 0) - { - return CGLTF_ERROR_JSON; - } - - cgltf_parse_attribute_type((*out_attributes)[j].name, &(*out_attributes)[j].type, &(*out_attributes)[j].index); - - (*out_attributes)[j].data = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - - return i; +static int cgltf_parse_json_attribute_list(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_attribute **out_attributes, + cgltf_size *out_attributes_count) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + if (*out_attributes) { + return CGLTF_ERROR_JSON; + } + + *out_attributes_count = tokens[i].size; + *out_attributes = (cgltf_attribute *)cgltf_calloc( + options, sizeof(cgltf_attribute), *out_attributes_count); + ++i; + + if (!*out_attributes) { + return CGLTF_ERROR_NOMEM; + } + + for (cgltf_size j = 0; j < *out_attributes_count; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + i = cgltf_parse_json_string(options, tokens, i, json_chunk, + &(*out_attributes)[j].name); + if (i < 0) { + return CGLTF_ERROR_JSON; + } + + cgltf_parse_attribute_type((*out_attributes)[j].name, + &(*out_attributes)[j].type, + &(*out_attributes)[j].index); + + (*out_attributes)[j].data = CGLTF_PTRINDEX( + cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } + + return i; } -static int cgltf_parse_json_extras(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras) -{ - (void)json_chunk; - out_extras->start_offset = tokens[i].start; - out_extras->end_offset = tokens[i].end; - i = cgltf_skip_json(tokens, i); - return i; +static int cgltf_parse_json_extras(jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_extras *out_extras) { + (void)json_chunk; + out_extras->start_offset = tokens[i].start; + out_extras->end_offset = tokens[i].end; + i = cgltf_skip_json(tokens, i); + return i; } -static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extension* out_extension) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING); - CGLTF_CHECK_TOKTYPE(tokens[i+1], JSMN_OBJECT); - if (out_extension->name) - { - return CGLTF_ERROR_JSON; - } - - cgltf_size name_length = tokens[i].end - tokens[i].start; - out_extension->name = (char*)options->memory.alloc_func(options->memory.user_data, name_length + 1); - if (!out_extension->name) - { - return CGLTF_ERROR_NOMEM; - } - strncpy(out_extension->name, (const char*)json_chunk + tokens[i].start, name_length); - out_extension->name[name_length] = 0; - i++; - - size_t start = tokens[i].start; - size_t size = tokens[i].end - start; - out_extension->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1); - if (!out_extension->data) - { - return CGLTF_ERROR_NOMEM; - } - strncpy(out_extension->data, (const char*)json_chunk + start, size); - out_extension->data[size] = '\0'; - - i = cgltf_skip_json(tokens, i); - - return i; +static int cgltf_parse_json_unprocessed_extension( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_extension *out_extension) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING); + CGLTF_CHECK_TOKTYPE(tokens[i + 1], JSMN_OBJECT); + if (out_extension->name) { + return CGLTF_ERROR_JSON; + } + + cgltf_size name_length = tokens[i].end - tokens[i].start; + out_extension->name = (char *)options->memory.alloc_func( + options->memory.user_data, name_length + 1); + if (!out_extension->name) { + return CGLTF_ERROR_NOMEM; + } + strncpy(out_extension->name, (const char *)json_chunk + tokens[i].start, + name_length); + out_extension->name[name_length] = 0; + i++; + + size_t start = tokens[i].start; + size_t size = tokens[i].end - start; + out_extension->data = + (char *)options->memory.alloc_func(options->memory.user_data, size + 1); + if (!out_extension->data) { + return CGLTF_ERROR_NOMEM; + } + strncpy(out_extension->data, (const char *)json_chunk + start, size); + out_extension->data[size] = '\0'; + + i = cgltf_skip_json(tokens, i); + + return i; } -static int cgltf_parse_json_unprocessed_extensions(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_size* out_extensions_count, cgltf_extension** out_extensions) -{ - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if(*out_extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - *out_extensions_count = 0; - *out_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - - if (!*out_extensions) - { - return CGLTF_ERROR_NOMEM; - } - - ++i; - - for (int j = 0; j < extensions_size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - cgltf_size extension_index = (*out_extensions_count)++; - cgltf_extension* extension = &((*out_extensions)[extension_index]); - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, extension); - - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_unprocessed_extensions( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_size *out_extensions_count, + cgltf_extension **out_extensions) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (*out_extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + *out_extensions_count = 0; + *out_extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + + if (!*out_extensions) { + return CGLTF_ERROR_NOMEM; + } + + ++i; + + for (int j = 0; j < extensions_size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + cgltf_size extension_index = (*out_extensions_count)++; + cgltf_extension *extension = &((*out_extensions)[extension_index]); + i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, + extension); + + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_draco_mesh_compression* out_draco_mesh_compression) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0) - { - i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_draco_mesh_compression->attributes, &out_draco_mesh_compression->attributes_count); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) - { - ++i; - out_draco_mesh_compression->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_draco_mesh_compression( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_draco_mesh_compression *out_draco_mesh_compression) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0) { + i = cgltf_parse_json_attribute_list( + options, tokens, i + 1, json_chunk, + &out_draco_mesh_compression->attributes, + &out_draco_mesh_compression->attributes_count); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) { + ++i; + out_draco_mesh_compression->buffer_view = CGLTF_PTRINDEX( + cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_mesh_gpu_instancing(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh_gpu_instancing* out_mesh_gpu_instancing) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0) - { - i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_mesh_gpu_instancing->attributes, &out_mesh_gpu_instancing->attributes_count); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) - { - ++i; - out_mesh_gpu_instancing->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_mesh_gpu_instancing( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_mesh_gpu_instancing *out_mesh_gpu_instancing) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0) { + i = cgltf_parse_json_attribute_list( + options, tokens, i + 1, json_chunk, + &out_mesh_gpu_instancing->attributes, + &out_mesh_gpu_instancing->attributes_count); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) { + ++i; + out_mesh_gpu_instancing->buffer_view = CGLTF_PTRINDEX( + cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_mapping* out_mappings, cgltf_size* offset) -{ - (void)options; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int obj_size = tokens[i].size; - ++i; - - int material = -1; - int variants_tok = -1; - cgltf_extras extras = {0, 0}; - - for (int k = 0; k < obj_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "material") == 0) - { - ++i; - material = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0) - { - variants_tok = i+1; - CGLTF_CHECK_TOKTYPE(tokens[variants_tok], JSMN_ARRAY); - - i = cgltf_skip_json(tokens, i+1); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &extras); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - if (material < 0 || variants_tok < 0) - { - return CGLTF_ERROR_JSON; - } - - if (out_mappings) - { - for (int k = 0; k < tokens[variants_tok].size; ++k) - { - int variant = cgltf_json_to_int(&tokens[variants_tok + 1 + k], json_chunk); - if (variant < 0) - return variant; - - out_mappings[*offset].material = CGLTF_PTRINDEX(cgltf_material, material); - out_mappings[*offset].variant = variant; - out_mappings[*offset].extras = extras; - - (*offset)++; - } - } - else - { - (*offset) += tokens[variants_tok].size; - } - } - - return i; +static int cgltf_parse_json_material_mapping_data( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_material_mapping *out_mappings, + cgltf_size *offset) { + (void)options; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int obj_size = tokens[i].size; + ++i; + + int material = -1; + int variants_tok = -1; + cgltf_extras extras = {0, 0}; + + for (int k = 0; k < obj_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "material") == 0) { + ++i; + material = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0) { + variants_tok = i + 1; + CGLTF_CHECK_TOKTYPE(tokens[variants_tok], JSMN_ARRAY); + + i = cgltf_skip_json(tokens, i + 1); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &extras); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + if (material < 0 || variants_tok < 0) { + return CGLTF_ERROR_JSON; + } + + if (out_mappings) { + for (int k = 0; k < tokens[variants_tok].size; ++k) { + int variant = + cgltf_json_to_int(&tokens[variants_tok + 1 + k], json_chunk); + if (variant < 0) + return variant; + + out_mappings[*offset].material = + CGLTF_PTRINDEX(cgltf_material, material); + out_mappings[*offset].variant = variant; + out_mappings[*offset].extras = extras; + + (*offset)++; + } + } else { + (*offset) += tokens[variants_tok].size; + } + } + + return i; } -static int cgltf_parse_json_material_mappings(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "mappings") == 0) - { - if (out_prim->mappings) - { - return CGLTF_ERROR_JSON; - } - - cgltf_size mappings_offset = 0; - int k = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, NULL, &mappings_offset); - if (k < 0) - { - return k; - } - - out_prim->mappings_count = mappings_offset; - out_prim->mappings = (cgltf_material_mapping*)cgltf_calloc(options, sizeof(cgltf_material_mapping), out_prim->mappings_count); - - mappings_offset = 0; - i = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, out_prim->mappings, &mappings_offset); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_material_mappings(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_primitive *out_prim) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "mappings") == 0) { + if (out_prim->mappings) { + return CGLTF_ERROR_JSON; + } + + cgltf_size mappings_offset = 0; + int k = cgltf_parse_json_material_mapping_data( + options, tokens, i + 1, json_chunk, NULL, &mappings_offset); + if (k < 0) { + return k; + } + + out_prim->mappings_count = mappings_offset; + out_prim->mappings = (cgltf_material_mapping *)cgltf_calloc( + options, sizeof(cgltf_material_mapping), out_prim->mappings_count); + + mappings_offset = 0; + i = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, + json_chunk, out_prim->mappings, + &mappings_offset); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - out_prim->type = cgltf_primitive_type_triangles; - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0) - { - ++i; - out_prim->type - = (cgltf_primitive_type) - cgltf_json_to_int(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0) - { - ++i; - out_prim->indices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "material") == 0) - { - ++i; - out_prim->material = CGLTF_PTRINDEX(cgltf_material, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "attributes") == 0) - { - i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_prim->attributes, &out_prim->attributes_count); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "targets") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), (void**)&out_prim->targets, &out_prim->targets_count); - if (i < 0) - { - return i; - } - - for (cgltf_size k = 0; k < out_prim->targets_count; ++k) - { - i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim->targets[k].attributes, &out_prim->targets[k].attributes_count); - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_prim->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if(out_prim->extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - out_prim->extensions_count = 0; - out_prim->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - - if (!out_prim->extensions) - { - return CGLTF_ERROR_NOMEM; - } - - ++i; - for (int k = 0; k < extensions_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_draco_mesh_compression") == 0) - { - out_prim->has_draco_mesh_compression = 1; - i = cgltf_parse_json_draco_mesh_compression(options, tokens, i + 1, json_chunk, &out_prim->draco_mesh_compression); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0) - { - i = cgltf_parse_json_material_mappings(options, tokens, i + 1, json_chunk, out_prim); - } - else - { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_prim->extensions[out_prim->extensions_count++])); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_primitive(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_primitive *out_prim) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + out_prim->type = cgltf_primitive_type_triangles; + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "mode") == 0) { + ++i; + out_prim->type = + (cgltf_primitive_type)cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "indices") == 0) { + ++i; + out_prim->indices = CGLTF_PTRINDEX( + cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "material") == 0) { + ++i; + out_prim->material = CGLTF_PTRINDEX( + cgltf_material, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0) { + i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, + &out_prim->attributes, + &out_prim->attributes_count); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "targets") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), + (void **)&out_prim->targets, &out_prim->targets_count); + if (i < 0) { + return i; + } + + for (cgltf_size k = 0; k < out_prim->targets_count; ++k) { + i = cgltf_parse_json_attribute_list( + options, tokens, i, json_chunk, &out_prim->targets[k].attributes, + &out_prim->targets[k].attributes_count); + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_prim->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (out_prim->extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + out_prim->extensions_count = 0; + out_prim->extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + + if (!out_prim->extensions) { + return CGLTF_ERROR_NOMEM; + } + + ++i; + for (int k = 0; k < extensions_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_draco_mesh_compression") == 0) { + out_prim->has_draco_mesh_compression = 1; + i = cgltf_parse_json_draco_mesh_compression( + options, tokens, i + 1, json_chunk, + &out_prim->draco_mesh_compression); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_variants") == 0) { + i = cgltf_parse_json_material_mappings(options, tokens, i + 1, + json_chunk, out_prim); + } else { + i = cgltf_parse_json_unprocessed_extension( + options, tokens, i, json_chunk, + &(out_prim->extensions[out_prim->extensions_count++])); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_mesh(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh* out_mesh) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_mesh->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "primitives") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), (void**)&out_mesh->primitives, &out_mesh->primitives_count); - if (i < 0) - { - return i; - } - - for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; ++prim_index) - { - i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh->primitives[prim_index]); - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_mesh->weights, &out_mesh->weights_count); - if (i < 0) - { - return i; - } - - i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_mesh->weights, (int)out_mesh->weights_count); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - ++i; - - out_mesh->extras.start_offset = tokens[i].start; - out_mesh->extras.end_offset = tokens[i].end; - - if (tokens[i].type == JSMN_OBJECT) - { - int extras_size = tokens[i].size; - ++i; - - for (int k = 0; k < extras_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "targetNames") == 0 && tokens[i+1].type == JSMN_ARRAY) - { - i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_mesh->target_names, &out_mesh->target_names_count); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i); - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_mesh->extensions_count, &out_mesh->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_mesh(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_mesh *out_mesh) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_mesh->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "primitives") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), + (void **)&out_mesh->primitives, &out_mesh->primitives_count); + if (i < 0) { + return i; + } + + for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; + ++prim_index) { + i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, + &out_mesh->primitives[prim_index]); + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_float), + (void **)&out_mesh->weights, &out_mesh->weights_count); + if (i < 0) { + return i; + } + + i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, + out_mesh->weights, + (int)out_mesh->weights_count); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + ++i; + + out_mesh->extras.start_offset = tokens[i].start; + out_mesh->extras.end_offset = tokens[i].end; + + if (tokens[i].type == JSMN_OBJECT) { + int extras_size = tokens[i].size; + ++i; + + for (int k = 0; k < extras_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "targetNames") == 0 && + tokens[i + 1].type == JSMN_ARRAY) { + i = cgltf_parse_json_string_array( + options, tokens, i + 1, json_chunk, &out_mesh->target_names, + &out_mesh->target_names_count); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i); + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_mesh->extensions_count, + &out_mesh->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_meshes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), (void**)&out_data->meshes, &out_data->meshes_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->meshes_count; ++j) - { - i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data->meshes[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_meshes(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), + (void **)&out_data->meshes, + &out_data->meshes_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->meshes_count; ++j) { + i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, + &out_data->meshes[j]); + if (i < 0) { + return i; + } + } + return i; } -static cgltf_component_type cgltf_json_to_component_type(jsmntok_t const* tok, const uint8_t* json_chunk) -{ - int type = cgltf_json_to_int(tok, json_chunk); - - switch (type) - { - case 5120: - return cgltf_component_type_r_8; - case 5121: - return cgltf_component_type_r_8u; - case 5122: - return cgltf_component_type_r_16; - case 5123: - return cgltf_component_type_r_16u; - case 5125: - return cgltf_component_type_r_32u; - case 5126: - return cgltf_component_type_r_32f; - default: - return cgltf_component_type_invalid; - } +static cgltf_component_type +cgltf_json_to_component_type(jsmntok_t const *tok, const uint8_t *json_chunk) { + int type = cgltf_json_to_int(tok, json_chunk); + + switch (type) { + case 5120: + return cgltf_component_type_r_8; + case 5121: + return cgltf_component_type_r_8u; + case 5122: + return cgltf_component_type_r_16; + case 5123: + return cgltf_component_type_r_16u; + case 5125: + return cgltf_component_type_r_32u; + case 5126: + return cgltf_component_type_r_32f; + default: + return cgltf_component_type_invalid; + } } -static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor_sparse* out_sparse) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) - { - ++i; - out_sparse->count = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int indices_size = tokens[i].size; - ++i; - - for (int k = 0; k < indices_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) - { - ++i; - out_sparse->indices_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) - { - ++i; - out_sparse->indices_byte_offset = cgltf_json_to_size(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0) - { - ++i; - out_sparse->indices_component_type = cgltf_json_to_component_type(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->indices_extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->indices_extensions_count, &out_sparse->indices_extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "values") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int values_size = tokens[i].size; - ++i; - - for (int k = 0; k < values_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) - { - ++i; - out_sparse->values_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) - { - ++i; - out_sparse->values_byte_offset = cgltf_json_to_size(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->values_extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->values_extensions_count, &out_sparse->values_extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->extensions_count, &out_sparse->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_accessor_sparse(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_accessor_sparse *out_sparse) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "count") == 0) { + ++i; + out_sparse->count = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "indices") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int indices_size = tokens[i].size; + ++i; + + for (int k = 0; k < indices_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) { + ++i; + out_sparse->indices_buffer_view = CGLTF_PTRINDEX( + cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteOffset") == + 0) { + ++i; + out_sparse->indices_byte_offset = + cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "componentType") == + 0) { + ++i; + out_sparse->indices_component_type = + cgltf_json_to_component_type(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_sparse->indices_extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == + 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, + &out_sparse->indices_extensions_count, + &out_sparse->indices_extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "values") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int values_size = tokens[i].size; + ++i; + + for (int k = 0; k < values_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) { + ++i; + out_sparse->values_buffer_view = CGLTF_PTRINDEX( + cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteOffset") == + 0) { + ++i; + out_sparse->values_byte_offset = + cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_sparse->values_extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == + 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, + &out_sparse->values_extensions_count, + &out_sparse->values_extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_sparse->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_sparse->extensions_count, + &out_sparse->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor* out_accessor) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_accessor->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) - { - ++i; - out_accessor->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) - { - ++i; - out_accessor->offset = - cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0) - { - ++i; - out_accessor->component_type = cgltf_json_to_component_type(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "normalized") == 0) - { - ++i; - out_accessor->normalized = cgltf_json_to_bool(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) - { - ++i; - out_accessor->count = - cgltf_json_to_int(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens+i, json_chunk, "SCALAR") == 0) - { - out_accessor->type = cgltf_type_scalar; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC2") == 0) - { - out_accessor->type = cgltf_type_vec2; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC3") == 0) - { - out_accessor->type = cgltf_type_vec3; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC4") == 0) - { - out_accessor->type = cgltf_type_vec4; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT2") == 0) - { - out_accessor->type = cgltf_type_mat2; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT3") == 0) - { - out_accessor->type = cgltf_type_mat3; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT4") == 0) - { - out_accessor->type = cgltf_type_mat4; - } - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0) - { - ++i; - out_accessor->has_min = 1; - // note: we can't parse the precise number of elements since type may not have been computed yet - int min_size = tokens[i].size > 16 ? 16 : tokens[i].size; - i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, min_size); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0) - { - ++i; - out_accessor->has_max = 1; - // note: we can't parse the precise number of elements since type may not have been computed yet - int max_size = tokens[i].size > 16 ? 16 : tokens[i].size; - i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, max_size); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0) - { - out_accessor->is_sparse = 1; - i = cgltf_parse_json_accessor_sparse(options, tokens, i + 1, json_chunk, &out_accessor->sparse); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_accessor->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_accessor->extensions_count, &out_accessor->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_accessor(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_accessor *out_accessor) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_accessor->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) { + ++i; + out_accessor->buffer_view = CGLTF_PTRINDEX( + cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteOffset") == 0) { + ++i; + out_accessor->offset = cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "componentType") == + 0) { + ++i; + out_accessor->component_type = + cgltf_json_to_component_type(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalized") == 0) { + ++i; + out_accessor->normalized = cgltf_json_to_bool(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "count") == 0) { + ++i; + out_accessor->count = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "type") == 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "SCALAR") == 0) { + out_accessor->type = cgltf_type_scalar; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "VEC2") == 0) { + out_accessor->type = cgltf_type_vec2; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "VEC3") == 0) { + out_accessor->type = cgltf_type_vec3; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "VEC4") == 0) { + out_accessor->type = cgltf_type_vec4; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "MAT2") == 0) { + out_accessor->type = cgltf_type_mat2; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "MAT3") == 0) { + out_accessor->type = cgltf_type_mat3; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "MAT4") == 0) { + out_accessor->type = cgltf_type_mat4; + } + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0) { + ++i; + out_accessor->has_min = 1; + // note: we can't parse the precise number of elements since type may not + // have been computed yet + int min_size = tokens[i].size > 16 ? 16 : tokens[i].size; + i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, + min_size); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0) { + ++i; + out_accessor->has_max = 1; + // note: we can't parse the precise number of elements since type may not + // have been computed yet + int max_size = tokens[i].size > 16 ? 16 : tokens[i].size; + i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, + max_size); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0) { + out_accessor->is_sparse = 1; + i = cgltf_parse_json_accessor_sparse(options, tokens, i + 1, json_chunk, + &out_accessor->sparse); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_accessor->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_accessor->extensions_count, + &out_accessor->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_texture_transform(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_transform* out_texture_transform) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->offset, 2); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0) - { - ++i; - out_texture_transform->rotation = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->scale, 2); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) - { - ++i; - out_texture_transform->has_texcoord = 1; - out_texture_transform->texcoord = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_texture_transform( + jsmntok_t const *tokens, int i, const uint8_t *json_chunk, + cgltf_texture_transform *out_texture_transform) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_texture_transform->offset, 2); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0) { + ++i; + out_texture_transform->rotation = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_texture_transform->scale, 2); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) { + ++i; + out_texture_transform->has_texcoord = 1; + out_texture_transform->texcoord = + cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_view* out_texture_view) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - out_texture_view->scale = 1.0f; - cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0) - { - ++i; - out_texture_view->texture = CGLTF_PTRINDEX(cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) - { - ++i; - out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) - { - ++i; - out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0) - { - ++i; - out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture_view->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if(out_texture_view->extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - out_texture_view->extensions_count = 0; - out_texture_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - - if (!out_texture_view->extensions) - { - return CGLTF_ERROR_NOMEM; - } - - ++i; - - for (int k = 0; k < extensions_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_texture_transform") == 0) - { - out_texture_view->has_transform = 1; - i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, &out_texture_view->transform); - } - else - { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture_view->extensions[out_texture_view->extensions_count++])); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_texture_view(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_texture_view *out_texture_view) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + out_texture_view->scale = 1.0f; + cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0) { + ++i; + out_texture_view->texture = CGLTF_PTRINDEX( + cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0) { + ++i; + out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { + ++i; + out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0) { + ++i; + out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_texture_view->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (out_texture_view->extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + out_texture_view->extensions_count = 0; + out_texture_view->extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + + if (!out_texture_view->extensions) { + return CGLTF_ERROR_NOMEM; + } + + ++i; + + for (int k = 0; k < extensions_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_texture_transform") == 0) { + out_texture_view->has_transform = 1; + i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, + &out_texture_view->transform); + } else { + i = cgltf_parse_json_unprocessed_extension( + options, tokens, i, json_chunk, + &(out_texture_view + ->extensions[out_texture_view->extensions_count++])); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_metallic_roughness* out_pbr) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "metallicFactor") == 0) - { - ++i; - out_pbr->metallic_factor = - cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "roughnessFactor") == 0) - { - ++i; - out_pbr->roughness_factor = - cgltf_json_to_float(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorFactor") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->base_color_factor, 4); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, - &out_pbr->base_color_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicRoughnessTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, - &out_pbr->metallic_roughness_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_pbr->extras); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_pbr_metallic_roughness( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_pbr_metallic_roughness *out_pbr) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicFactor") == 0) { + ++i; + out_pbr->metallic_factor = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "roughnessFactor") == + 0) { + ++i; + out_pbr->roughness_factor = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "baseColorFactor") == + 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_pbr->base_color_factor, 4); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "baseColorTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_pbr->base_color_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "metallicRoughnessTexture") == 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_pbr->metallic_roughness_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_pbr->extras); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_pbr_specular_glossiness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_specular_glossiness* out_pbr) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseFactor") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->diffuse_factor, 4); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->specular_factor, 3); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "glossinessFactor") == 0) - { - ++i; - out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->diffuse_texture); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularGlossinessTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->specular_glossiness_texture); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_pbr_specular_glossiness( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_pbr_specular_glossiness *out_pbr) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "diffuseFactor") == 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_pbr->diffuse_factor, 4); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "specularFactor") == + 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_pbr->specular_factor, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "glossinessFactor") == + 0) { + ++i; + out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "diffuseTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_pbr->diffuse_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "specularGlossinessTexture") == 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_pbr->specular_glossiness_texture); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_clearcoat(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_clearcoat* out_clearcoat) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatFactor") == 0) - { - ++i; - out_clearcoat->clearcoat_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessFactor") == 0) - { - ++i; - out_clearcoat->clearcoat_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_texture); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_roughness_texture); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatNormalTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_normal_texture); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_clearcoat(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_clearcoat *out_clearcoat) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "clearcoatFactor") == 0) { + ++i; + out_clearcoat->clearcoat_factor = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "clearcoatRoughnessFactor") == 0) { + ++i; + out_clearcoat->clearcoat_roughness_factor = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "clearcoatTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_clearcoat->clearcoat_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "clearcoatRoughnessTexture") == 0) { + i = cgltf_parse_json_texture_view( + options, tokens, i + 1, json_chunk, + &out_clearcoat->clearcoat_roughness_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "clearcoatNormalTexture") == 0) { + i = cgltf_parse_json_texture_view( + options, tokens, i + 1, json_chunk, + &out_clearcoat->clearcoat_normal_texture); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_ior(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_ior* out_ior) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - // Default values - out_ior->ior = 1.5f; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "ior") == 0) - { - ++i; - out_ior->ior = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_ior(jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_ior *out_ior) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + // Default values + out_ior->ior = 1.5f; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "ior") == 0) { + ++i; + out_ior->ior = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_specular(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_specular* out_specular) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - // Default values - out_specular->specular_factor = 1.0f; - cgltf_fill_float_array(out_specular->specular_color_factor, 3, 1.0f); - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0) - { - ++i; - out_specular->specular_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularColorFactor") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_specular->specular_color_factor, 3); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "specularColorTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_color_texture); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_specular(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_specular *out_specular) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + // Default values + out_specular->specular_factor = 1.0f; + cgltf_fill_float_array(out_specular->specular_color_factor, 3, 1.0f); + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "specularFactor") == 0) { + ++i; + out_specular->specular_factor = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "specularColorFactor") == 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_specular->specular_color_factor, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "specularTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_specular->specular_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "specularColorTexture") == 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_specular->specular_color_texture); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_transmission(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_transmission* out_transmission) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionFactor") == 0) - { - ++i; - out_transmission->transmission_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_transmission->transmission_texture); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_transmission(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_transmission *out_transmission) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "transmissionFactor") == 0) { + ++i; + out_transmission->transmission_factor = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "transmissionTexture") == 0) { + i = cgltf_parse_json_texture_view( + options, tokens, i + 1, json_chunk, + &out_transmission->transmission_texture); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_volume(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_volume* out_volume) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessFactor") == 0) - { - ++i; - out_volume->thickness_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_volume->thickness_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationColor") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_volume->attenuation_color, 3); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationDistance") == 0) - { - ++i; - out_volume->attenuation_distance = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_volume(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_volume *out_volume) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessFactor") == 0) { + ++i; + out_volume->thickness_factor = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_volume->thickness_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationColor") == + 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_volume->attenuation_color, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "attenuationDistance") == 0) { + ++i; + out_volume->attenuation_distance = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_sheen(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sheen* out_sheen) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorFactor") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_sheen->sheen_color_factor, 3); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_color_texture); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessFactor") == 0) - { - ++i; - out_sheen->sheen_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_roughness_texture); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_sheen(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_sheen *out_sheen) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "sheenColorFactor") == 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_sheen->sheen_color_factor, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "sheenColorTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_sheen->sheen_color_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "sheenRoughnessFactor") == 0) { + ++i; + out_sheen->sheen_roughness_factor = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "sheenRoughnessTexture") == 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_sheen->sheen_roughness_texture); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_emissive_strength(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_emissive_strength* out_emissive_strength) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - // Default - out_emissive_strength->emissive_strength = 1.f; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveStrength") == 0) - { - ++i; - out_emissive_strength->emissive_strength = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_emissive_strength( + jsmntok_t const *tokens, int i, const uint8_t *json_chunk, + cgltf_emissive_strength *out_emissive_strength) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + // Default + out_emissive_strength->emissive_strength = 1.f; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveStrength") == 0) { + ++i; + out_emissive_strength->emissive_strength = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_iridescence(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_iridescence* out_iridescence) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int size = tokens[i].size; - ++i; - - // Default - out_iridescence->iridescence_ior = 1.3f; - out_iridescence->iridescence_thickness_min = 100.f; - out_iridescence->iridescence_thickness_max = 400.f; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceFactor") == 0) - { - ++i; - out_iridescence->iridescence_factor = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceIor") == 0) - { - ++i; - out_iridescence->iridescence_ior = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMinimum") == 0) - { - ++i; - out_iridescence->iridescence_thickness_min = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMaximum") == 0) - { - ++i; - out_iridescence->iridescence_thickness_max = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_thickness_texture); - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_iridescence(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_iridescence *out_iridescence) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int size = tokens[i].size; + ++i; + + // Default + out_iridescence->iridescence_ior = 1.3f; + out_iridescence->iridescence_thickness_min = 100.f; + out_iridescence->iridescence_thickness_max = 400.f; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceFactor") == 0) { + ++i; + out_iridescence->iridescence_factor = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "iridescenceTexture") == 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_iridescence->iridescence_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceIor") == + 0) { + ++i; + out_iridescence->iridescence_ior = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "iridescenceThicknessMinimum") == 0) { + ++i; + out_iridescence->iridescence_thickness_min = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "iridescenceThicknessMaximum") == 0) { + ++i; + out_iridescence->iridescence_thickness_max = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "iridescenceThicknessTexture") == 0) { + i = cgltf_parse_json_texture_view( + options, tokens, i + 1, json_chunk, + &out_iridescence->iridescence_thickness_texture); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->uri); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0) - { - ++i; - out_image->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->mime_type); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->name); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_image->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_image->extensions_count, &out_image->extensions); - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_image(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_image *out_image) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_image->uri); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0) { + ++i; + out_image->buffer_view = CGLTF_PTRINDEX( + cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_image->mime_type); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_image->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_image->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_image->extensions_count, + &out_image->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sampler* out_sampler) -{ - (void)options; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - out_sampler->wrap_s = 10497; - out_sampler->wrap_t = 10497; - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_sampler->name); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0) - { - ++i; - out_sampler->mag_filter - = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0) - { - ++i; - out_sampler->min_filter - = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0) - { - ++i; - out_sampler->wrap_s - = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0) - { - ++i; - out_sampler->wrap_t - = cgltf_json_to_int(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions); - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_sampler(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_sampler *out_sampler) { + (void)options; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + out_sampler->wrap_s = 10497; + out_sampler->wrap_t = 10497; + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_sampler->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0) { + ++i; + out_sampler->mag_filter = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0) { + ++i; + out_sampler->min_filter = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0) { + ++i; + out_sampler->wrap_s = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0) { + ++i; + out_sampler->wrap_t = cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_sampler->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_sampler->extensions_count, + &out_sampler->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture* out_texture) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_texture->name); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0) - { - ++i; - out_texture->sampler = CGLTF_PTRINDEX(cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) - { - ++i; - out_texture->image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if (out_texture->extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - ++i; - out_texture->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - out_texture->extensions_count = 0; - - if (!out_texture->extensions) - { - return CGLTF_ERROR_NOMEM; - } - - for (int k = 0; k < extensions_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_texture_basisu") == 0) - { - out_texture->has_basisu = 1; - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - int num_properties = tokens[i].size; - ++i; - - for (int t = 0; t < num_properties; ++t) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) - { - ++i; - out_texture->basisu_image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture->extensions[out_texture->extensions_count++])); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_texture(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_texture *out_texture) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_texture->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0) { + ++i; + out_texture->sampler = CGLTF_PTRINDEX( + cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) { + ++i; + out_texture->image = CGLTF_PTRINDEX( + cgltf_image, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_texture->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (out_texture->extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + ++i; + out_texture->extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + out_texture->extensions_count = 0; + + if (!out_texture->extensions) { + return CGLTF_ERROR_NOMEM; + } + + for (int k = 0; k < extensions_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_texture_basisu") == + 0) { + out_texture->has_basisu = 1; + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + int num_properties = tokens[i].size; + ++i; + + for (int t = 0; t < num_properties; ++t) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) { + ++i; + out_texture->basisu_image = CGLTF_PTRINDEX( + cgltf_image, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + if (i < 0) { + return i; + } + } + } else { + i = cgltf_parse_json_unprocessed_extension( + options, tokens, i, json_chunk, + &(out_texture->extensions[out_texture->extensions_count++])); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material* out_material) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, 4, 1.0f); - out_material->pbr_metallic_roughness.metallic_factor = 1.0f; - out_material->pbr_metallic_roughness.roughness_factor = 1.0f; - - cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, 4, 1.0f); - cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, 3, 1.0f); - out_material->pbr_specular_glossiness.glossiness_factor = 1.0f; - - cgltf_fill_float_array(out_material->volume.attenuation_color, 3, 1.0f); - out_material->volume.attenuation_distance = FLT_MAX; - - out_material->alpha_cutoff = 0.5f; - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_material->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "pbrMetallicRoughness") == 0) - { - out_material->has_pbr_metallic_roughness = 1; - i = cgltf_parse_json_pbr_metallic_roughness(options, tokens, i + 1, json_chunk, &out_material->pbr_metallic_roughness); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "emissiveFactor") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_material->emissive_factor, 3); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, - &out_material->normal_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, - &out_material->occlusion_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == 0) - { - i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, - &out_material->emissive_texture); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0) - { - out_material->alpha_mode = cgltf_alpha_mode_opaque; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0) - { - out_material->alpha_mode = cgltf_alpha_mode_mask; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0) - { - out_material->alpha_mode = cgltf_alpha_mode_blend; - } - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0) - { - ++i; - out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0) - { - ++i; - out_material->double_sided = - cgltf_json_to_bool(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_material->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if(out_material->extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - ++i; - out_material->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - out_material->extensions_count= 0; - - if (!out_material->extensions) - { - return CGLTF_ERROR_NOMEM; - } - - for (int k = 0; k < extensions_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_pbrSpecularGlossiness") == 0) - { - out_material->has_pbr_specular_glossiness = 1; - i = cgltf_parse_json_pbr_specular_glossiness(options, tokens, i + 1, json_chunk, &out_material->pbr_specular_glossiness); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_unlit") == 0) - { - out_material->unlit = 1; - i = cgltf_skip_json(tokens, i+1); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_clearcoat") == 0) - { - out_material->has_clearcoat = 1; - i = cgltf_parse_json_clearcoat(options, tokens, i + 1, json_chunk, &out_material->clearcoat); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_ior") == 0) - { - out_material->has_ior = 1; - i = cgltf_parse_json_ior(tokens, i + 1, json_chunk, &out_material->ior); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_specular") == 0) - { - out_material->has_specular = 1; - i = cgltf_parse_json_specular(options, tokens, i + 1, json_chunk, &out_material->specular); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_transmission") == 0) - { - out_material->has_transmission = 1; - i = cgltf_parse_json_transmission(options, tokens, i + 1, json_chunk, &out_material->transmission); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_volume") == 0) - { - out_material->has_volume = 1; - i = cgltf_parse_json_volume(options, tokens, i + 1, json_chunk, &out_material->volume); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_sheen") == 0) - { - out_material->has_sheen = 1; - i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, &out_material->sheen); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_emissive_strength") == 0) - { - out_material->has_emissive_strength = 1; - i = cgltf_parse_json_emissive_strength(tokens, i + 1, json_chunk, &out_material->emissive_strength); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_iridescence") == 0) - { - out_material->has_iridescence = 1; - i = cgltf_parse_json_iridescence(options, tokens, i + 1, json_chunk, &out_material->iridescence); - } - else - { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++])); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_material(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_material *out_material) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, + 4, 1.0f); + out_material->pbr_metallic_roughness.metallic_factor = 1.0f; + out_material->pbr_metallic_roughness.roughness_factor = 1.0f; + + cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, + 4, 1.0f); + cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, + 3, 1.0f); + out_material->pbr_specular_glossiness.glossiness_factor = 1.0f; + + cgltf_fill_float_array(out_material->volume.attenuation_color, 3, 1.0f); + out_material->volume.attenuation_distance = FLT_MAX; + + out_material->alpha_cutoff = 0.5f; + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_material->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "pbrMetallicRoughness") == 0) { + out_material->has_pbr_metallic_roughness = 1; + i = cgltf_parse_json_pbr_metallic_roughness( + options, tokens, i + 1, json_chunk, + &out_material->pbr_metallic_roughness); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveFactor") == + 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_material->emissive_factor, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_material->normal_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_material->occlusion_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == + 0) { + i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, + &out_material->emissive_texture); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0) { + out_material->alpha_mode = cgltf_alpha_mode_opaque; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0) { + out_material->alpha_mode = cgltf_alpha_mode_mask; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0) { + out_material->alpha_mode = cgltf_alpha_mode_blend; + } + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0) { + ++i; + out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0) { + ++i; + out_material->double_sided = cgltf_json_to_bool(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_material->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (out_material->extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + ++i; + out_material->extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + out_material->extensions_count = 0; + + if (!out_material->extensions) { + return CGLTF_ERROR_NOMEM; + } + + for (int k = 0; k < extensions_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_pbrSpecularGlossiness") == 0) { + out_material->has_pbr_specular_glossiness = 1; + i = cgltf_parse_json_pbr_specular_glossiness( + options, tokens, i + 1, json_chunk, + &out_material->pbr_specular_glossiness); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_unlit") == 0) { + out_material->unlit = 1; + i = cgltf_skip_json(tokens, i + 1); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_clearcoat") == 0) { + out_material->has_clearcoat = 1; + i = cgltf_parse_json_clearcoat(options, tokens, i + 1, json_chunk, + &out_material->clearcoat); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_ior") == 0) { + out_material->has_ior = 1; + i = cgltf_parse_json_ior(tokens, i + 1, json_chunk, + &out_material->ior); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_specular") == 0) { + out_material->has_specular = 1; + i = cgltf_parse_json_specular(options, tokens, i + 1, json_chunk, + &out_material->specular); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_transmission") == 0) { + out_material->has_transmission = 1; + i = cgltf_parse_json_transmission(options, tokens, i + 1, json_chunk, + &out_material->transmission); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_volume") == 0) { + out_material->has_volume = 1; + i = cgltf_parse_json_volume(options, tokens, i + 1, json_chunk, + &out_material->volume); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_sheen") == 0) { + out_material->has_sheen = 1; + i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, + &out_material->sheen); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_emissive_strength") == 0) { + out_material->has_emissive_strength = 1; + i = cgltf_parse_json_emissive_strength( + tokens, i + 1, json_chunk, &out_material->emissive_strength); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_iridescence") == 0) { + out_material->has_iridescence = 1; + i = cgltf_parse_json_iridescence(options, tokens, i + 1, json_chunk, + &out_material->iridescence); + } else { + i = cgltf_parse_json_unprocessed_extension( + options, tokens, i, json_chunk, + &(out_material->extensions[out_material->extensions_count++])); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_accessors(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_accessor), (void**)&out_data->accessors, &out_data->accessors_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->accessors_count; ++j) - { - i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, &out_data->accessors[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_accessors(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array( + options, tokens, i, json_chunk, sizeof(cgltf_accessor), + (void **)&out_data->accessors, &out_data->accessors_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->accessors_count; ++j) { + i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, + &out_data->accessors[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_materials(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material), (void**)&out_data->materials, &out_data->materials_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->materials_count; ++j) - { - i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data->materials[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_materials(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array( + options, tokens, i, json_chunk, sizeof(cgltf_material), + (void **)&out_data->materials, &out_data->materials_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->materials_count; ++j) { + i = cgltf_parse_json_material(options, tokens, i, json_chunk, + &out_data->materials[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_images(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_image), (void**)&out_data->images, &out_data->images_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->images_count; ++j) - { - i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data->images[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_images(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, + sizeof(cgltf_image), (void **)&out_data->images, + &out_data->images_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->images_count; ++j) { + i = cgltf_parse_json_image(options, tokens, i, json_chunk, + &out_data->images[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_textures(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_texture), (void**)&out_data->textures, &out_data->textures_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->textures_count; ++j) - { - i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data->textures[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_textures(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array( + options, tokens, i, json_chunk, sizeof(cgltf_texture), + (void **)&out_data->textures, &out_data->textures_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->textures_count; ++j) { + i = cgltf_parse_json_texture(options, tokens, i, json_chunk, + &out_data->textures[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_samplers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_sampler), (void**)&out_data->samplers, &out_data->samplers_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->samplers_count; ++j) - { - i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data->samplers[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_samplers(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array( + options, tokens, i, json_chunk, sizeof(cgltf_sampler), + (void **)&out_data->samplers, &out_data->samplers_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->samplers_count; ++j) { + i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, + &out_data->samplers[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_meshopt_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_meshopt_compression* out_meshopt_compression) -{ - (void)options; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0) - { - ++i; - out_meshopt_compression->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) - { - ++i; - out_meshopt_compression->offset = cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) - { - ++i; - out_meshopt_compression->size = cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0) - { - ++i; - out_meshopt_compression->stride = cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0) - { - ++i; - out_meshopt_compression->count = cgltf_json_to_int(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens+i, json_chunk, "ATTRIBUTES") == 0) - { - out_meshopt_compression->mode = cgltf_meshopt_compression_mode_attributes; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "TRIANGLES") == 0) - { - out_meshopt_compression->mode = cgltf_meshopt_compression_mode_triangles; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "INDICES") == 0) - { - out_meshopt_compression->mode = cgltf_meshopt_compression_mode_indices; - } - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "filter") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens+i, json_chunk, "NONE") == 0) - { - out_meshopt_compression->filter = cgltf_meshopt_compression_filter_none; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "OCTAHEDRAL") == 0) - { - out_meshopt_compression->filter = cgltf_meshopt_compression_filter_octahedral; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "QUATERNION") == 0) - { - out_meshopt_compression->filter = cgltf_meshopt_compression_filter_quaternion; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "EXPONENTIAL") == 0) - { - out_meshopt_compression->filter = cgltf_meshopt_compression_filter_exponential; - } - ++i; - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_meshopt_compression( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_meshopt_compression *out_meshopt_compression) { + (void)options; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "buffer") == 0) { + ++i; + out_meshopt_compression->buffer = CGLTF_PTRINDEX( + cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteOffset") == 0) { + ++i; + out_meshopt_compression->offset = + cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteLength") == 0) { + ++i; + out_meshopt_compression->size = + cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteStride") == 0) { + ++i; + out_meshopt_compression->stride = + cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "count") == 0) { + ++i; + out_meshopt_compression->count = + cgltf_json_to_int(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "mode") == 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "ATTRIBUTES") == 0) { + out_meshopt_compression->mode = + cgltf_meshopt_compression_mode_attributes; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "TRIANGLES") == 0) { + out_meshopt_compression->mode = + cgltf_meshopt_compression_mode_triangles; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "INDICES") == 0) { + out_meshopt_compression->mode = cgltf_meshopt_compression_mode_indices; + } + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "filter") == 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "NONE") == 0) { + out_meshopt_compression->filter = cgltf_meshopt_compression_filter_none; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "OCTAHEDRAL") == 0) { + out_meshopt_compression->filter = + cgltf_meshopt_compression_filter_octahedral; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "QUATERNION") == 0) { + out_meshopt_compression->filter = + cgltf_meshopt_compression_filter_quaternion; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXPONENTIAL") == + 0) { + out_meshopt_compression->filter = + cgltf_meshopt_compression_filter_exponential; + } + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer_view* out_buffer_view) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer_view->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0) - { - ++i; - out_buffer_view->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0) - { - ++i; - out_buffer_view->offset = - cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) - { - ++i; - out_buffer_view->size = - cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0) - { - ++i; - out_buffer_view->stride = - cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0) - { - ++i; - int type = cgltf_json_to_int(tokens+i, json_chunk); - switch (type) - { - case 34962: - type = cgltf_buffer_view_type_vertices; - break; - case 34963: - type = cgltf_buffer_view_type_indices; - break; - default: - type = cgltf_buffer_view_type_invalid; - break; - } - out_buffer_view->type = (cgltf_buffer_view_type)type; - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer_view->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if(out_buffer_view->extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - out_buffer_view->extensions_count = 0; - out_buffer_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - - if (!out_buffer_view->extensions) - { - return CGLTF_ERROR_NOMEM; - } - - ++i; - for (int k = 0; k < extensions_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "EXT_meshopt_compression") == 0) - { - out_buffer_view->has_meshopt_compression = 1; - i = cgltf_parse_json_meshopt_compression(options, tokens, i + 1, json_chunk, &out_buffer_view->meshopt_compression); - } - else - { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_buffer_view->extensions[out_buffer_view->extensions_count++])); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_buffer_view(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_buffer_view *out_buffer_view) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_buffer_view->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffer") == 0) { + ++i; + out_buffer_view->buffer = CGLTF_PTRINDEX( + cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteOffset") == 0) { + ++i; + out_buffer_view->offset = cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteLength") == 0) { + ++i; + out_buffer_view->size = cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteStride") == 0) { + ++i; + out_buffer_view->stride = cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "target") == 0) { + ++i; + int type = cgltf_json_to_int(tokens + i, json_chunk); + switch (type) { + case 34962: + type = cgltf_buffer_view_type_vertices; + break; + case 34963: + type = cgltf_buffer_view_type_indices; + break; + default: + type = cgltf_buffer_view_type_invalid; + break; + } + out_buffer_view->type = (cgltf_buffer_view_type)type; + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_buffer_view->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (out_buffer_view->extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + out_buffer_view->extensions_count = 0; + out_buffer_view->extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + + if (!out_buffer_view->extensions) { + return CGLTF_ERROR_NOMEM; + } + + ++i; + for (int k = 0; k < extensions_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, + "EXT_meshopt_compression") == 0) { + out_buffer_view->has_meshopt_compression = 1; + i = cgltf_parse_json_meshopt_compression( + options, tokens, i + 1, json_chunk, + &out_buffer_view->meshopt_compression); + } else { + i = cgltf_parse_json_unprocessed_extension( + options, tokens, i, json_chunk, + &(out_buffer_view + ->extensions[out_buffer_view->extensions_count++])); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_buffer_views(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), (void**)&out_data->buffer_views, &out_data->buffer_views_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j) - { - i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, &out_data->buffer_views[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_buffer_views(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array( + options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), + (void **)&out_data->buffer_views, &out_data->buffer_views_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j) { + i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, + &out_data->buffer_views[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer* out_buffer) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0) - { - ++i; - out_buffer->size = - cgltf_json_to_size(tokens+i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "uri") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->uri); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_buffer->extensions_count, &out_buffer->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_buffer(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_buffer *out_buffer) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_buffer->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "byteLength") == 0) { + ++i; + out_buffer->size = cgltf_json_to_size(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_buffer->uri); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_buffer->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_buffer->extensions_count, + &out_buffer->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_buffers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer), (void**)&out_data->buffers, &out_data->buffers_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->buffers_count; ++j) - { - i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data->buffers[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_buffers(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, + sizeof(cgltf_buffer), (void **)&out_data->buffers, + &out_data->buffers_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->buffers_count; ++j) { + i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, + &out_data->buffers[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_skin* out_skin) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_skin->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "joints") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_skin->joints, &out_skin->joints_count); - if (i < 0) - { - return i; - } - - for (cgltf_size k = 0; k < out_skin->joints_count; ++k) - { - out_skin->joints[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "skeleton") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); - out_skin->skeleton = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "inverseBindMatrices") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); - out_skin->inverse_bind_matrices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_skin->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_skin->extensions_count, &out_skin->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_skin(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_skin *out_skin) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_skin->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "joints") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_node *), + (void **)&out_skin->joints, &out_skin->joints_count); + if (i < 0) { + return i; + } + + for (cgltf_size k = 0; k < out_skin->joints_count; ++k) { + out_skin->joints[k] = CGLTF_PTRINDEX( + cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "skeleton") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); + out_skin->skeleton = + CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "inverseBindMatrices") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); + out_skin->inverse_bind_matrices = CGLTF_PTRINDEX( + cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_skin->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_skin->extensions_count, + &out_skin->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_skins(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), (void**)&out_data->skins, &out_data->skins_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->skins_count; ++j) - { - i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data->skins[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_skins(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), + (void **)&out_data->skins, &out_data->skins_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->skins_count; ++j) { + i = cgltf_parse_json_skin(options, tokens, i, json_chunk, + &out_data->skins[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_camera* out_camera) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0) - { - out_camera->type = cgltf_camera_type_perspective; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0) - { - out_camera->type = cgltf_camera_type_orthographic; - } - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int data_size = tokens[i].size; - ++i; - - out_camera->type = cgltf_camera_type_perspective; - - for (int k = 0; k < data_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "aspectRatio") == 0) - { - ++i; - out_camera->data.perspective.has_aspect_ratio = 1; - out_camera->data.perspective.aspect_ratio = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "yfov") == 0) - { - ++i; - out_camera->data.perspective.yfov = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0) - { - ++i; - out_camera->data.perspective.has_zfar = 1; - out_camera->data.perspective.zfar = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0) - { - ++i; - out_camera->data.perspective.znear = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.perspective.extras); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "orthographic") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int data_size = tokens[i].size; - ++i; - - out_camera->type = cgltf_camera_type_orthographic; - - for (int k = 0; k < data_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "xmag") == 0) - { - ++i; - out_camera->data.orthographic.xmag = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "ymag") == 0) - { - ++i; - out_camera->data.orthographic.ymag = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0) - { - ++i; - out_camera->data.orthographic.zfar = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0) - { - ++i; - out_camera->data.orthographic.znear = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_camera->extensions_count, &out_camera->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_camera(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_camera *out_camera) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_camera->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "type") == 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0) { + out_camera->type = cgltf_camera_type_perspective; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == + 0) { + out_camera->type = cgltf_camera_type_orthographic; + } + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int data_size = tokens[i].size; + ++i; + + out_camera->type = cgltf_camera_type_perspective; + + for (int k = 0; k < data_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "aspectRatio") == 0) { + ++i; + out_camera->data.perspective.has_aspect_ratio = 1; + out_camera->data.perspective.aspect_ratio = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "yfov") == 0) { + ++i; + out_camera->data.perspective.yfov = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "zfar") == 0) { + ++i; + out_camera->data.perspective.has_zfar = 1; + out_camera->data.perspective.zfar = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "znear") == 0) { + ++i; + out_camera->data.perspective.znear = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_camera->data.perspective.extras); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int data_size = tokens[i].size; + ++i; + + out_camera->type = cgltf_camera_type_orthographic; + + for (int k = 0; k < data_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "xmag") == 0) { + ++i; + out_camera->data.orthographic.xmag = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "ymag") == 0) { + ++i; + out_camera->data.orthographic.ymag = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "zfar") == 0) { + ++i; + out_camera->data.orthographic.zfar = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "znear") == 0) { + ++i; + out_camera->data.orthographic.znear = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_camera->data.orthographic.extras); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_camera->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_camera->extensions_count, + &out_camera->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_cameras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_camera), (void**)&out_data->cameras, &out_data->cameras_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->cameras_count; ++j) - { - i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data->cameras[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_cameras(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, + sizeof(cgltf_camera), (void **)&out_data->cameras, + &out_data->cameras_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->cameras_count; ++j) { + i = cgltf_parse_json_camera(options, tokens, i, json_chunk, + &out_data->cameras[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_light* out_light) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - out_light->color[0] = 1.f; - out_light->color[1] = 1.f; - out_light->color[2] = 1.f; - out_light->intensity = 1.f; - - out_light->spot_inner_cone_angle = 0.f; - out_light->spot_outer_cone_angle = 3.1415926535f / 4.0f; - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_light->name); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0) - { - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_light->color, 3); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0) - { - ++i; - out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0) - { - out_light->type = cgltf_light_type_directional; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0) - { - out_light->type = cgltf_light_type_point; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0) - { - out_light->type = cgltf_light_type_spot; - } - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0) - { - ++i; - out_light->range = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "spot") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int data_size = tokens[i].size; - ++i; - - for (int k = 0; k < data_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "innerConeAngle") == 0) - { - ++i; - out_light->spot_inner_cone_angle = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "outerConeAngle") == 0) - { - ++i; - out_light->spot_outer_cone_angle = cgltf_json_to_float(tokens + i, json_chunk); - ++i; - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_light->extras); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_light(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_light *out_light) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + out_light->color[0] = 1.f; + out_light->color[1] = 1.f; + out_light->color[2] = 1.f; + out_light->intensity = 1.f; + + out_light->spot_inner_cone_angle = 0.f; + out_light->spot_outer_cone_angle = 3.1415926535f / 4.0f; + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_light->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0) { + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_light->color, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0) { + ++i; + out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "type") == 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0) { + out_light->type = cgltf_light_type_directional; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0) { + out_light->type = cgltf_light_type_point; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0) { + out_light->type = cgltf_light_type_spot; + } + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0) { + ++i; + out_light->range = cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int data_size = tokens[i].size; + ++i; + + for (int k = 0; k < data_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "innerConeAngle") == 0) { + ++i; + out_light->spot_inner_cone_angle = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "outerConeAngle") == 0) { + ++i; + out_light->spot_outer_cone_angle = + cgltf_json_to_float(tokens + i, json_chunk); + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_light->extras); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_lights(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_light), (void**)&out_data->lights, &out_data->lights_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->lights_count; ++j) - { - i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data->lights[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_lights(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, + sizeof(cgltf_light), (void **)&out_data->lights, + &out_data->lights_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->lights_count; ++j) { + i = cgltf_parse_json_light(options, tokens, i, json_chunk, + &out_data->lights[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_node* out_node) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - out_node->rotation[3] = 1.0f; - out_node->scale[0] = 1.0f; - out_node->scale[1] = 1.0f; - out_node->scale[2] = 1.0f; - out_node->matrix[0] = 1.0f; - out_node->matrix[5] = 1.0f; - out_node->matrix[10] = 1.0f; - out_node->matrix[15] = 1.0f; - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_node->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "children") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_node->children, &out_node->children_count); - if (i < 0) - { - return i; - } - - for (cgltf_size k = 0; k < out_node->children_count; ++k) - { - out_node->children[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "mesh") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); - out_node->mesh = CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "skin") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); - out_node->skin = CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "camera") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); - out_node->camera = CGLTF_PTRINDEX(cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0) - { - out_node->has_translation = 1; - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->translation, 3); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0) - { - out_node->has_rotation = 1; - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->rotation, 4); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0) - { - out_node->has_scale = 1; - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->scale, 3); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "matrix") == 0) - { - out_node->has_matrix = 1; - i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->matrix, 16); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_node->weights, &out_node->weights_count); - if (i < 0) - { - return i; - } - - i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_node->weights, (int)out_node->weights_count); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_node->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if(out_node->extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - out_node->extensions_count= 0; - out_node->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - - if (!out_node->extensions) - { - return CGLTF_ERROR_NOMEM; - } - - ++i; - - for (int k = 0; k < extensions_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int data_size = tokens[i].size; - ++i; - - for (int m = 0; m < data_size; ++m) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0) - { - ++i; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); - out_node->light = CGLTF_PTRINDEX(cgltf_light, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXT_mesh_gpu_instancing") == 0) - { - out_node->has_mesh_gpu_instancing = 1; - i = cgltf_parse_json_mesh_gpu_instancing(options, tokens, i + 1, json_chunk, &out_node->mesh_gpu_instancing); - } - else - { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_node->extensions[out_node->extensions_count++])); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_node(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_node *out_node) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + out_node->rotation[3] = 1.0f; + out_node->scale[0] = 1.0f; + out_node->scale[1] = 1.0f; + out_node->scale[2] = 1.0f; + out_node->matrix[0] = 1.0f; + out_node->matrix[5] = 1.0f; + out_node->matrix[10] = 1.0f; + out_node->matrix[15] = 1.0f; + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_node->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "children") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_node *), + (void **)&out_node->children, &out_node->children_count); + if (i < 0) { + return i; + } + + for (cgltf_size k = 0; k < out_node->children_count; ++k) { + out_node->children[k] = CGLTF_PTRINDEX( + cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "mesh") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); + out_node->mesh = + CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "skin") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); + out_node->skin = + CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "camera") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); + out_node->camera = CGLTF_PTRINDEX( + cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "translation") == 0) { + out_node->has_translation = 1; + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_node->translation, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0) { + out_node->has_rotation = 1; + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_node->rotation, 4); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { + out_node->has_scale = 1; + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_node->scale, 3); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "matrix") == 0) { + out_node->has_matrix = 1; + i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, + out_node->matrix, 16); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_float), + (void **)&out_node->weights, &out_node->weights_count); + if (i < 0) { + return i; + } + + i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, + out_node->weights, + (int)out_node->weights_count); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_node->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (out_node->extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + out_node->extensions_count = 0; + out_node->extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + + if (!out_node->extensions) { + return CGLTF_ERROR_NOMEM; + } + + ++i; + + for (int k = 0; k < extensions_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_lights_punctual") == + 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int data_size = tokens[i].size; + ++i; + + for (int m = 0; m < data_size; ++m) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0) { + ++i; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE); + out_node->light = CGLTF_PTRINDEX( + cgltf_light, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "EXT_mesh_gpu_instancing") == 0) { + out_node->has_mesh_gpu_instancing = 1; + i = cgltf_parse_json_mesh_gpu_instancing( + options, tokens, i + 1, json_chunk, + &out_node->mesh_gpu_instancing); + } else { + i = cgltf_parse_json_unprocessed_extension( + options, tokens, i, json_chunk, + &(out_node->extensions[out_node->extensions_count++])); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_nodes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), (void**)&out_data->nodes, &out_data->nodes_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->nodes_count; ++j) - { - i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data->nodes[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_nodes(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), + (void **)&out_data->nodes, &out_data->nodes_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->nodes_count; ++j) { + i = cgltf_parse_json_node(options, tokens, i, json_chunk, + &out_data->nodes[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_scene* out_scene) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_scene->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "nodes") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_scene->nodes, &out_scene->nodes_count); - if (i < 0) - { - return i; - } - - for (cgltf_size k = 0; k < out_scene->nodes_count; ++k) - { - out_scene->nodes[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_scene->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_scene->extensions_count, &out_scene->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_scene(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_scene *out_scene) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_scene->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_node *), + (void **)&out_scene->nodes, &out_scene->nodes_count); + if (i < 0) { + return i; + } + + for (cgltf_size k = 0; k < out_scene->nodes_count; ++k) { + out_scene->nodes[k] = CGLTF_PTRINDEX( + cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_scene->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_scene->extensions_count, + &out_scene->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_scenes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_scene), (void**)&out_data->scenes, &out_data->scenes_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->scenes_count; ++j) - { - i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data->scenes[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_scenes(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array(options, tokens, i, json_chunk, + sizeof(cgltf_scene), (void **)&out_data->scenes, + &out_data->scenes_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->scenes_count; ++j) { + i = cgltf_parse_json_scene(options, tokens, i, json_chunk, + &out_data->scenes[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_sampler* out_sampler) -{ - (void)options; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "input") == 0) - { - ++i; - out_sampler->input = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "output") == 0) - { - ++i; - out_sampler->output = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "interpolation") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0) - { - out_sampler->interpolation = cgltf_interpolation_type_linear; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0) - { - out_sampler->interpolation = cgltf_interpolation_type_step; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == 0) - { - out_sampler->interpolation = cgltf_interpolation_type_cubic_spline; - } - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_animation_sampler( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_animation_sampler *out_sampler) { + (void)options; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "input") == 0) { + ++i; + out_sampler->input = CGLTF_PTRINDEX( + cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "output") == 0) { + ++i; + out_sampler->output = CGLTF_PTRINDEX( + cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "interpolation") == + 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0) { + out_sampler->interpolation = cgltf_interpolation_type_linear; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0) { + out_sampler->interpolation = cgltf_interpolation_type_step; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == + 0) { + out_sampler->interpolation = cgltf_interpolation_type_cubic_spline; + } + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_sampler->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_sampler->extensions_count, + &out_sampler->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_channel* out_channel) -{ - (void)options; - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "sampler") == 0) - { - ++i; - out_channel->sampler = CGLTF_PTRINDEX(cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int target_size = tokens[i].size; - ++i; - - for (int k = 0; k < target_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "node") == 0) - { - ++i; - out_channel->target_node = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "path") == 0) - { - ++i; - if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0) - { - out_channel->target_path = cgltf_animation_path_type_translation; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0) - { - out_channel->target_path = cgltf_animation_path_type_rotation; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0) - { - out_channel->target_path = cgltf_animation_path_type_scale; - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "weights") == 0) - { - out_channel->target_path = cgltf_animation_path_type_weights; - } - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_channel->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_channel->extensions_count, &out_channel->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_animation_channel( + cgltf_options *options, jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, cgltf_animation_channel *out_channel) { + (void)options; + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0) { + ++i; + out_channel->sampler = CGLTF_PTRINDEX( + cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "target") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int target_size = tokens[i].size; + ++i; + + for (int k = 0; k < target_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "node") == 0) { + ++i; + out_channel->target_node = CGLTF_PTRINDEX( + cgltf_node, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "path") == 0) { + ++i; + if (cgltf_json_strcmp(tokens + i, json_chunk, "translation") == 0) { + out_channel->target_path = cgltf_animation_path_type_translation; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == + 0) { + out_channel->target_path = cgltf_animation_path_type_rotation; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) { + out_channel->target_path = cgltf_animation_path_type_scale; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == + 0) { + out_channel->target_path = cgltf_animation_path_type_weights; + } + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_channel->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == + 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_channel->extensions_count, + &out_channel->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation* out_animation) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_animation->name); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "samplers") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), (void**)&out_animation->samplers, &out_animation->samplers_count); - if (i < 0) - { - return i; - } - - for (cgltf_size k = 0; k < out_animation->samplers_count; ++k) - { - i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation->samplers[k]); - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "channels") == 0) - { - i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), (void**)&out_animation->channels, &out_animation->channels_count); - if (i < 0) - { - return i; - } - - for (cgltf_size k = 0; k < out_animation->channels_count; ++k) - { - i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation->channels[k]); - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_animation->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_animation->extensions_count, &out_animation->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_animation(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_animation *out_animation) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_animation->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), + (void **)&out_animation->samplers, &out_animation->samplers_count); + if (i < 0) { + return i; + } + + for (cgltf_size k = 0; k < out_animation->samplers_count; ++k) { + i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, + &out_animation->samplers[k]); + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "channels") == 0) { + i = cgltf_parse_json_array( + options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), + (void **)&out_animation->channels, &out_animation->channels_count); + if (i < 0) { + return i; + } + + for (cgltf_size k = 0; k < out_animation->channels_count; ++k) { + i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, + &out_animation->channels[k]); + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_animation->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_animation->extensions_count, + &out_animation->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_animations(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_animation), (void**)&out_data->animations, &out_data->animations_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->animations_count; ++j) - { - i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data->animations[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_animations(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array( + options, tokens, i, json_chunk, sizeof(cgltf_animation), + (void **)&out_data->animations, &out_data->animations_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->animations_count; ++j) { + i = cgltf_parse_json_animation(options, tokens, i, json_chunk, + &out_data->animations[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_variant(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_variant* out_variant) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_variant->name); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_variant->extras); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_parse_json_variant(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_material_variant *out_variant) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_variant->name); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_variant->extras); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -static int cgltf_parse_json_variants(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material_variant), (void**)&out_data->variants, &out_data->variants_count); - if (i < 0) - { - return i; - } - - for (cgltf_size j = 0; j < out_data->variants_count; ++j) - { - i = cgltf_parse_json_variant(options, tokens, i, json_chunk, &out_data->variants[j]); - if (i < 0) - { - return i; - } - } - return i; +static int cgltf_parse_json_variants(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + i = cgltf_parse_json_array( + options, tokens, i, json_chunk, sizeof(cgltf_material_variant), + (void **)&out_data->variants, &out_data->variants_count); + if (i < 0) { + return i; + } + + for (cgltf_size j = 0; j < out_data->variants_count; ++j) { + i = cgltf_parse_json_variant(options, tokens, i, json_chunk, + &out_data->variants[j]); + if (i < 0) { + return i; + } + } + return i; } -static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_asset* out_asset) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "copyright") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->copyright); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "generator") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->generator); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "version") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->version); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "minVersion") == 0) - { - i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->min_version); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_asset->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_asset->extensions_count, &out_asset->extensions); - } - else - { - i = cgltf_skip_json(tokens, i+1); - } - - if (i < 0) - { - return i; - } - } - - if (out_asset->version && CGLTF_ATOF(out_asset->version) < 2) - { - return CGLTF_ERROR_LEGACY; - } - - return i; +static int cgltf_parse_json_asset(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_asset *out_asset) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "copyright") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_asset->copyright); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "generator") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_asset->generator); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "version") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_asset->version); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "minVersion") == 0) { + i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, + &out_asset->min_version); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, + &out_asset->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + i = cgltf_parse_json_unprocessed_extensions( + options, tokens, i, json_chunk, &out_asset->extensions_count, + &out_asset->extensions); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + if (out_asset->version && CGLTF_ATOF(out_asset->version) < 2) { + return CGLTF_ERROR_LEGACY; + } + + return i; } cgltf_size cgltf_num_components(cgltf_type type) { - switch (type) - { - case cgltf_type_vec2: - return 2; - case cgltf_type_vec3: - return 3; - case cgltf_type_vec4: - return 4; - case cgltf_type_mat2: - return 4; - case cgltf_type_mat3: - return 9; - case cgltf_type_mat4: - return 16; - case cgltf_type_invalid: - case cgltf_type_scalar: - default: - return 1; - } + switch (type) { + case cgltf_type_vec2: + return 2; + case cgltf_type_vec3: + return 3; + case cgltf_type_vec4: + return 4; + case cgltf_type_mat2: + return 4; + case cgltf_type_mat3: + return 9; + case cgltf_type_mat4: + return 16; + case cgltf_type_invalid: + case cgltf_type_scalar: + default: + return 1; + } } static cgltf_size cgltf_component_size(cgltf_component_type component_type) { - switch (component_type) - { - case cgltf_component_type_r_8: - case cgltf_component_type_r_8u: - return 1; - case cgltf_component_type_r_16: - case cgltf_component_type_r_16u: - return 2; - case cgltf_component_type_r_32u: - case cgltf_component_type_r_32f: - return 4; - case cgltf_component_type_invalid: - default: - return 0; - } + switch (component_type) { + case cgltf_component_type_r_8: + case cgltf_component_type_r_8u: + return 1; + case cgltf_component_type_r_16: + case cgltf_component_type_r_16u: + return 2; + case cgltf_component_type_r_32u: + case cgltf_component_type_r_32f: + return 4; + case cgltf_component_type_invalid: + default: + return 0; + } } -static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type) -{ - cgltf_size component_size = cgltf_component_size(component_type); - if (type == cgltf_type_mat2 && component_size == 1) - { - return 8 * component_size; - } - else if (type == cgltf_type_mat3 && (component_size == 1 || component_size == 2)) - { - return 12 * component_size; - } - return component_size * cgltf_num_components(type); +static cgltf_size cgltf_calc_size(cgltf_type type, + cgltf_component_type component_type) { + cgltf_size component_size = cgltf_component_size(component_type); + if (type == cgltf_type_mat2 && component_size == 1) { + return 8 * component_size; + } else if (type == cgltf_type_mat3 && + (component_size == 1 || component_size == 2)) { + return 12 * component_size; + } + return component_size * cgltf_num_components(type); } -static int cgltf_fixup_pointers(cgltf_data* out_data); - -static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data) -{ - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int size = tokens[i].size; - ++i; - - for (int j = 0; j < size; ++j) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0) - { - i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, &out_data->asset); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0) - { - i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0) - { - i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0) - { - i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0) - { - i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0) - { - i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0) - { - i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0) - { - i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0) - { - i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0) - { - i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0) - { - i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0) - { - i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0) - { - i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0) - { - ++i; - out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk)); - ++i; - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0) - { - i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, out_data); - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0) - { - i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_data->extras); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - if(out_data->data_extensions) - { - return CGLTF_ERROR_JSON; - } - - int extensions_size = tokens[i].size; - out_data->data_extensions_count = 0; - out_data->data_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size); - - if (!out_data->data_extensions) - { - return CGLTF_ERROR_NOMEM; - } - - ++i; - - for (int k = 0; k < extensions_size; ++k) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int data_size = tokens[i].size; - ++i; - - for (int m = 0; m < data_size; ++m) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0) - { - i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, out_data); - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0) - { - ++i; - - CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); - - int data_size = tokens[i].size; - ++i; - - for (int m = 0; m < data_size; ++m) - { - CGLTF_CHECK_KEY(tokens[i]); - - if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0) - { - i = cgltf_parse_json_variants(options, tokens, i + 1, json_chunk, out_data); - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - } - else - { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_data->data_extensions[out_data->data_extensions_count++])); - } - - if (i < 0) - { - return i; - } - } - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsUsed") == 0) - { - i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_used, &out_data->extensions_used_count); - } - else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsRequired") == 0) - { - i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_required, &out_data->extensions_required_count); - } - else - { - i = cgltf_skip_json(tokens, i + 1); - } - - if (i < 0) - { - return i; - } - } - - return i; +static int cgltf_fixup_pointers(cgltf_data *out_data); + +static int cgltf_parse_json_root(cgltf_options *options, + jsmntok_t const *tokens, int i, + const uint8_t *json_chunk, + cgltf_data *out_data) { + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int size = tokens[i].size; + ++i; + + for (int j = 0; j < size; ++j) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0) { + i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, + &out_data->asset); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0) { + i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0) { + i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0) { + i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0) { + i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0) { + i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0) { + i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0) { + i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0) { + i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0) { + i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0) { + i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0) { + i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0) { + i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0) { + ++i; + out_data->scene = CGLTF_PTRINDEX( + cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk)); + ++i; + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0) { + i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, + out_data); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0) { + i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_data->extras); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + if (out_data->data_extensions) { + return CGLTF_ERROR_JSON; + } + + int extensions_size = tokens[i].size; + out_data->data_extensions_count = 0; + out_data->data_extensions = (cgltf_extension *)cgltf_calloc( + options, sizeof(cgltf_extension), extensions_size); + + if (!out_data->data_extensions) { + return CGLTF_ERROR_NOMEM; + } + + ++i; + + for (int k = 0; k < extensions_size; ++k) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_lights_punctual") == + 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int data_size = tokens[i].size; + ++i; + + for (int m = 0; m < data_size; ++m) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0) { + i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, + out_data); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "KHR_materials_variants") == 0) { + ++i; + + CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT); + + int data_size = tokens[i].size; + ++i; + + for (int m = 0; m < data_size; ++m) { + CGLTF_CHECK_KEY(tokens[i]); + + if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0) { + i = cgltf_parse_json_variants(options, tokens, i + 1, json_chunk, + out_data); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + } else { + i = cgltf_parse_json_unprocessed_extension( + options, tokens, i, json_chunk, + &(out_data->data_extensions[out_data->data_extensions_count++])); + } + + if (i < 0) { + return i; + } + } + } else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsUsed") == + 0) { + i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, + &out_data->extensions_used, + &out_data->extensions_used_count); + } else if (cgltf_json_strcmp(tokens + i, json_chunk, + "extensionsRequired") == 0) { + i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, + &out_data->extensions_required, + &out_data->extensions_required_count); + } else { + i = cgltf_skip_json(tokens, i + 1); + } + + if (i < 0) { + return i; + } + } + + return i; } -cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data) -{ - jsmn_parser parser = { 0, 0, 0 }; +cgltf_result cgltf_parse_json(cgltf_options *options, const uint8_t *json_chunk, + cgltf_size size, cgltf_data **out_data) { + jsmn_parser parser = {0, 0, 0}; - if (options->json_token_count == 0) - { - int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, NULL, 0); + if (options->json_token_count == 0) { + int token_count = + jsmn_parse(&parser, (const char *)json_chunk, size, NULL, 0); - if (token_count <= 0) - { - return cgltf_result_invalid_json; - } + if (token_count <= 0) { + return cgltf_result_invalid_json; + } - options->json_token_count = token_count; - } + options->json_token_count = token_count; + } - jsmntok_t* tokens = (jsmntok_t*)options->memory.alloc_func(options->memory.user_data, sizeof(jsmntok_t) * (options->json_token_count + 1)); + jsmntok_t *tokens = (jsmntok_t *)options->memory.alloc_func( + options->memory.user_data, + sizeof(jsmntok_t) * (options->json_token_count + 1)); - if (!tokens) - { - return cgltf_result_out_of_memory; - } + if (!tokens) { + return cgltf_result_out_of_memory; + } - jsmn_init(&parser); + jsmn_init(&parser); - int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, tokens, options->json_token_count); + int token_count = jsmn_parse(&parser, (const char *)json_chunk, size, tokens, + options->json_token_count); - if (token_count <= 0) - { - options->memory.free_func(options->memory.user_data, tokens); - return cgltf_result_invalid_json; - } + if (token_count <= 0) { + options->memory.free_func(options->memory.user_data, tokens); + return cgltf_result_invalid_json; + } - // this makes sure that we always have an UNDEFINED token at the end of the stream - // for invalid JSON inputs this makes sure we don't perform out of bound reads of token data - tokens[token_count].type = JSMN_UNDEFINED; + // this makes sure that we always have an UNDEFINED token at the end of the + // stream for invalid JSON inputs this makes sure we don't perform out of + // bound reads of token data + tokens[token_count].type = JSMN_UNDEFINED; - cgltf_data* data = (cgltf_data*)options->memory.alloc_func(options->memory.user_data, sizeof(cgltf_data)); + cgltf_data *data = (cgltf_data *)options->memory.alloc_func( + options->memory.user_data, sizeof(cgltf_data)); - if (!data) - { - options->memory.free_func(options->memory.user_data, tokens); - return cgltf_result_out_of_memory; - } + if (!data) { + options->memory.free_func(options->memory.user_data, tokens); + return cgltf_result_out_of_memory; + } - memset(data, 0, sizeof(cgltf_data)); - data->memory = options->memory; - data->file = options->file; + memset(data, 0, sizeof(cgltf_data)); + data->memory = options->memory; + data->file = options->file; - int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data); + int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data); - options->memory.free_func(options->memory.user_data, tokens); + options->memory.free_func(options->memory.user_data, tokens); - if (i < 0) - { - cgltf_free(data); + if (i < 0) { + cgltf_free(data); - switch (i) - { - case CGLTF_ERROR_NOMEM: return cgltf_result_out_of_memory; - case CGLTF_ERROR_LEGACY: return cgltf_result_legacy_gltf; - default: return cgltf_result_invalid_gltf; - } - } + switch (i) { + case CGLTF_ERROR_NOMEM: + return cgltf_result_out_of_memory; + case CGLTF_ERROR_LEGACY: + return cgltf_result_legacy_gltf; + default: + return cgltf_result_invalid_gltf; + } + } - if (cgltf_fixup_pointers(data) < 0) - { - cgltf_free(data); - return cgltf_result_invalid_gltf; - } + if (cgltf_fixup_pointers(data) < 0) { + cgltf_free(data); + return cgltf_result_invalid_gltf; + } - data->json = (const char*)json_chunk; - data->json_size = size; + data->json = (const char *)json_chunk; + data->json_size = size; - *out_data = data; + *out_data = data; - return cgltf_result_success; + return cgltf_result_success; } -static int cgltf_fixup_pointers(cgltf_data* data) -{ - for (cgltf_size i = 0; i < data->meshes_count; ++i) - { - for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) - { - CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, data->accessors_count); - CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, data->materials_count); - - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k) - { - CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, data->accessors, data->accessors_count); - } - - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k) - { - for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m) - { - CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].targets[k].attributes[m].data, data->accessors, data->accessors_count); - } - } - - if (data->meshes[i].primitives[j].has_draco_mesh_compression) - { - CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.buffer_view, data->buffer_views, data->buffer_views_count); - for (cgltf_size m = 0; m < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++m) - { - CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.attributes[m].data, data->accessors, data->accessors_count); - } - } - - for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k) - { - CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].mappings[k].material, data->materials, data->materials_count); - } - } - } - - for (cgltf_size i = 0; i < data->accessors_count; ++i) - { - CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, data->buffer_views_count); - - if (data->accessors[i].is_sparse) - { - CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, data->buffer_views, data->buffer_views_count); - CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, data->buffer_views, data->buffer_views_count); - } - - if (data->accessors[i].buffer_view) - { - data->accessors[i].stride = data->accessors[i].buffer_view->stride; - } - - if (data->accessors[i].stride == 0) - { - data->accessors[i].stride = cgltf_calc_size(data->accessors[i].type, data->accessors[i].component_type); - } - } - - for (cgltf_size i = 0; i < data->textures_count; ++i) - { - CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count); - CGLTF_PTRFIXUP(data->textures[i].basisu_image, data->images, data->images_count); - CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count); - } - - for (cgltf_size i = 0; i < data->images_count; ++i) - { - CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, data->buffer_views_count); - } - - for (cgltf_size i = 0; i < data->materials_count; ++i) - { - CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.base_color_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_roughness_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_normal_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].specular.specular_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].specular.specular_color_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].transmission.transmission_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].volume.thickness_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, data->textures, data->textures_count); - - CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_texture.texture, data->textures, data->textures_count); - CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_thickness_texture.texture, data->textures, data->textures_count); - } - - for (cgltf_size i = 0; i < data->buffer_views_count; ++i) - { - CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, data->buffers_count); - - if (data->buffer_views[i].has_meshopt_compression) - { - CGLTF_PTRFIXUP_REQ(data->buffer_views[i].meshopt_compression.buffer, data->buffers, data->buffers_count); - } - } - - for (cgltf_size i = 0; i < data->skins_count; ++i) - { - for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j) - { - CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, data->nodes_count); - } - - CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count); - CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, data->accessors_count); - } - - for (cgltf_size i = 0; i < data->nodes_count; ++i) - { - for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j) - { - CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, data->nodes_count); - - if (data->nodes[i].children[j]->parent) - { - return CGLTF_ERROR_JSON; - } - - data->nodes[i].children[j]->parent = &data->nodes[i]; - } - - CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count); - CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count); - CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count); - CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count); - - if (data->nodes[i].has_mesh_gpu_instancing) - { - CGLTF_PTRFIXUP_REQ(data->nodes[i].mesh_gpu_instancing.buffer_view, data->buffer_views, data->buffer_views_count); - for (cgltf_size m = 0; m < data->nodes[i].mesh_gpu_instancing.attributes_count; ++m) - { - CGLTF_PTRFIXUP_REQ(data->nodes[i].mesh_gpu_instancing.attributes[m].data, data->accessors, data->accessors_count); - } - } - } - - for (cgltf_size i = 0; i < data->scenes_count; ++i) - { - for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j) - { - CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, data->nodes_count); - - if (data->scenes[i].nodes[j]->parent) - { - return CGLTF_ERROR_JSON; - } - } - } - - CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count); - - for (cgltf_size i = 0; i < data->animations_count; ++i) - { - for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j) - { - CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, data->accessors_count); - CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, data->accessors, data->accessors_count); - } - - for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) - { - CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, data->animations[i].samplers, data->animations[i].samplers_count); - CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, data->nodes_count); - } - } - - return 0; +static int cgltf_fixup_pointers(cgltf_data *data) { + for (cgltf_size i = 0; i < data->meshes_count; ++i) { + for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j) { + CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, + data->accessors_count); + CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, + data->materials_count); + + for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; + ++k) { + CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, + data->accessors, data->accessors_count); + } + + for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; + ++k) { + for (cgltf_size m = 0; + m < data->meshes[i].primitives[j].targets[k].attributes_count; + ++m) { + CGLTF_PTRFIXUP_REQ( + data->meshes[i].primitives[j].targets[k].attributes[m].data, + data->accessors, data->accessors_count); + } + } + + if (data->meshes[i].primitives[j].has_draco_mesh_compression) { + CGLTF_PTRFIXUP_REQ( + data->meshes[i].primitives[j].draco_mesh_compression.buffer_view, + data->buffer_views, data->buffer_views_count); + for (cgltf_size m = 0; m < data->meshes[i] + .primitives[j] + .draco_mesh_compression.attributes_count; + ++m) { + CGLTF_PTRFIXUP_REQ(data->meshes[i] + .primitives[j] + .draco_mesh_compression.attributes[m] + .data, + data->accessors, data->accessors_count); + } + } + + for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; + ++k) { + CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].mappings[k].material, + data->materials, data->materials_count); + } + } + } + + for (cgltf_size i = 0; i < data->accessors_count; ++i) { + CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, + data->buffer_views_count); + + if (data->accessors[i].is_sparse) { + CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, + data->buffer_views, data->buffer_views_count); + CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, + data->buffer_views, data->buffer_views_count); + } + + if (data->accessors[i].buffer_view) { + data->accessors[i].stride = data->accessors[i].buffer_view->stride; + } + + if (data->accessors[i].stride == 0) { + data->accessors[i].stride = cgltf_calc_size( + data->accessors[i].type, data->accessors[i].component_type); + } + } + + for (cgltf_size i = 0; i < data->textures_count; ++i) { + CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count); + CGLTF_PTRFIXUP(data->textures[i].basisu_image, data->images, + data->images_count); + CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, + data->samplers_count); + } + + for (cgltf_size i = 0; i < data->images_count; ++i) { + CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, + data->buffer_views_count); + } + + for (cgltf_size i = 0; i < data->materials_count; ++i) { + CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, + data->textures_count); + CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, + data->textures_count); + CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, + data->textures_count); + + CGLTF_PTRFIXUP( + data->materials[i].pbr_metallic_roughness.base_color_texture.texture, + data->textures, data->textures_count); + CGLTF_PTRFIXUP( + data->materials[i] + .pbr_metallic_roughness.metallic_roughness_texture.texture, + data->textures, data->textures_count); + + CGLTF_PTRFIXUP( + data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, + data->textures, data->textures_count); + CGLTF_PTRFIXUP( + data->materials[i] + .pbr_specular_glossiness.specular_glossiness_texture.texture, + data->textures, data->textures_count); + + CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_texture.texture, + data->textures, data->textures_count); + CGLTF_PTRFIXUP( + data->materials[i].clearcoat.clearcoat_roughness_texture.texture, + data->textures, data->textures_count); + CGLTF_PTRFIXUP( + data->materials[i].clearcoat.clearcoat_normal_texture.texture, + data->textures, data->textures_count); + + CGLTF_PTRFIXUP(data->materials[i].specular.specular_texture.texture, + data->textures, data->textures_count); + CGLTF_PTRFIXUP(data->materials[i].specular.specular_color_texture.texture, + data->textures, data->textures_count); + + CGLTF_PTRFIXUP(data->materials[i].transmission.transmission_texture.texture, + data->textures, data->textures_count); + + CGLTF_PTRFIXUP(data->materials[i].volume.thickness_texture.texture, + data->textures, data->textures_count); + + CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, + data->textures, data->textures_count); + CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, + data->textures, data->textures_count); + + CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_texture.texture, + data->textures, data->textures_count); + CGLTF_PTRFIXUP( + data->materials[i].iridescence.iridescence_thickness_texture.texture, + data->textures, data->textures_count); + } + + for (cgltf_size i = 0; i < data->buffer_views_count; ++i) { + CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, + data->buffers_count); + + if (data->buffer_views[i].has_meshopt_compression) { + CGLTF_PTRFIXUP_REQ(data->buffer_views[i].meshopt_compression.buffer, + data->buffers, data->buffers_count); + } + } + + for (cgltf_size i = 0; i < data->skins_count; ++i) { + for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j) { + CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, + data->nodes_count); + } + + CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count); + CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, + data->accessors_count); + } + + for (cgltf_size i = 0; i < data->nodes_count; ++i) { + for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j) { + CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, + data->nodes_count); + + if (data->nodes[i].children[j]->parent) { + return CGLTF_ERROR_JSON; + } + + data->nodes[i].children[j]->parent = &data->nodes[i]; + } + + CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count); + CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count); + CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count); + CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count); + + if (data->nodes[i].has_mesh_gpu_instancing) { + CGLTF_PTRFIXUP_REQ(data->nodes[i].mesh_gpu_instancing.buffer_view, + data->buffer_views, data->buffer_views_count); + for (cgltf_size m = 0; + m < data->nodes[i].mesh_gpu_instancing.attributes_count; ++m) { + CGLTF_PTRFIXUP_REQ( + data->nodes[i].mesh_gpu_instancing.attributes[m].data, + data->accessors, data->accessors_count); + } + } + } + + for (cgltf_size i = 0; i < data->scenes_count; ++i) { + for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j) { + CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, + data->nodes_count); + + if (data->scenes[i].nodes[j]->parent) { + return CGLTF_ERROR_JSON; + } + } + } + + CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count); + + for (cgltf_size i = 0; i < data->animations_count; ++i) { + for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j) { + CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, + data->accessors_count); + CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, + data->accessors, data->accessors_count); + } + + for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j) { + CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, + data->animations[i].samplers, + data->animations[i].samplers_count); + CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, + data->nodes_count); + } + } + + return 0; } /* @@ -6401,303 +6205,334 @@ static int cgltf_fixup_pointers(cgltf_data* data) /** * Allocates a fresh unused token from the token pull. */ -static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, - jsmntok_t *tokens, size_t num_tokens) { - jsmntok_t *tok; - if (parser->toknext >= num_tokens) { - return NULL; - } - tok = &tokens[parser->toknext++]; - tok->start = tok->end = -1; - tok->size = 0; +static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, + size_t num_tokens) { + jsmntok_t *tok; + if (parser->toknext >= num_tokens) { + return NULL; + } + tok = &tokens[parser->toknext++]; + tok->start = tok->end = -1; + tok->size = 0; #ifdef JSMN_PARENT_LINKS - tok->parent = -1; + tok->parent = -1; #endif - return tok; + return tok; } /** * Fills token type and boundaries. */ -static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, - int start, int end) { - token->type = type; - token->start = start; - token->end = end; - token->size = 0; +static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, int start, + int end) { + token->type = type; + token->start = start; + token->end = end; + token->size = 0; } /** * Fills next available token with JSON primitive. */ -static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, - size_t len, jsmntok_t *tokens, size_t num_tokens) { - jsmntok_t *token; - int start; +static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, size_t len, + jsmntok_t *tokens, size_t num_tokens) { + jsmntok_t *token; + int start; - start = parser->pos; + start = parser->pos; - for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { - switch (js[parser->pos]) { + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + switch (js[parser->pos]) { #ifndef JSMN_STRICT - /* In strict mode primitive must be followed by "," or "}" or "]" */ - case ':': + /* In strict mode primitive must be followed by "," or "}" or "]" */ + case ':': #endif - case '\t' : case '\r' : case '\n' : case ' ' : - case ',' : case ']' : case '}' : - goto found; - } - if (js[parser->pos] < 32 || js[parser->pos] >= 127) { - parser->pos = start; - return JSMN_ERROR_INVAL; - } - } + case '\t': + case '\r': + case '\n': + case ' ': + case ',': + case ']': + case '}': + goto found; + } + if (js[parser->pos] < 32 || js[parser->pos] >= 127) { + parser->pos = start; + return JSMN_ERROR_INVAL; + } + } #ifdef JSMN_STRICT - /* In strict mode primitive must be followed by a comma/object/array */ - parser->pos = start; - return JSMN_ERROR_PART; + /* In strict mode primitive must be followed by a comma/object/array */ + parser->pos = start; + return JSMN_ERROR_PART; #endif found: - if (tokens == NULL) { - parser->pos--; - return 0; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == NULL) { - parser->pos = start; - return JSMN_ERROR_NOMEM; - } - jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); + if (tokens == NULL) { + parser->pos--; + return 0; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) { + parser->pos = start; + return JSMN_ERROR_NOMEM; + } + jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); #ifdef JSMN_PARENT_LINKS - token->parent = parser->toksuper; + token->parent = parser->toksuper; #endif - parser->pos--; - return 0; + parser->pos--; + return 0; } /** * Fills next token with JSON string. */ -static int jsmn_parse_string(jsmn_parser *parser, const char *js, - size_t len, jsmntok_t *tokens, size_t num_tokens) { - jsmntok_t *token; - - int start = parser->pos; - - parser->pos++; - - /* Skip starting quote */ - for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { - char c = js[parser->pos]; - - /* Quote: end of string */ - if (c == '\"') { - if (tokens == NULL) { - return 0; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == NULL) { - parser->pos = start; - return JSMN_ERROR_NOMEM; - } - jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos); +static int jsmn_parse_string(jsmn_parser *parser, const char *js, size_t len, + jsmntok_t *tokens, size_t num_tokens) { + jsmntok_t *token; + + int start = parser->pos; + + parser->pos++; + + /* Skip starting quote */ + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + char c = js[parser->pos]; + + /* Quote: end of string */ + if (c == '\"') { + if (tokens == NULL) { + return 0; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) { + parser->pos = start; + return JSMN_ERROR_NOMEM; + } + jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos); #ifdef JSMN_PARENT_LINKS - token->parent = parser->toksuper; + token->parent = parser->toksuper; #endif - return 0; - } - - /* Backslash: Quoted symbol expected */ - if (c == '\\' && parser->pos + 1 < len) { - int i; - parser->pos++; - switch (js[parser->pos]) { - /* Allowed escaped symbols */ - case '\"': case '/' : case '\\' : case 'b' : - case 'f' : case 'r' : case 'n' : case 't' : - break; - /* Allows escaped symbol \uXXXX */ - case 'u': - parser->pos++; - for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) { - /* If it isn't a hex character we have an error */ - if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ - (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ - (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ - parser->pos = start; - return JSMN_ERROR_INVAL; - } - parser->pos++; - } - parser->pos--; - break; - /* Unexpected symbol */ - default: - parser->pos = start; - return JSMN_ERROR_INVAL; - } - } - } - parser->pos = start; - return JSMN_ERROR_PART; + return 0; + } + + /* Backslash: Quoted symbol expected */ + if (c == '\\' && parser->pos + 1 < len) { + int i; + parser->pos++; + switch (js[parser->pos]) { + /* Allowed escaped symbols */ + case '\"': + case '/': + case '\\': + case 'b': + case 'f': + case 'r': + case 'n': + case 't': + break; + /* Allows escaped symbol \uXXXX */ + case 'u': + parser->pos++; + for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; + i++) { + /* If it isn't a hex character we have an error */ + if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ + (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ + (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ + parser->pos = start; + return JSMN_ERROR_INVAL; + } + parser->pos++; + } + parser->pos--; + break; + /* Unexpected symbol */ + default: + parser->pos = start; + return JSMN_ERROR_INVAL; + } + } + } + parser->pos = start; + return JSMN_ERROR_PART; } /** * Parse JSON string and fill tokens. */ static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, - jsmntok_t *tokens, size_t num_tokens) { - int r; - int i; - jsmntok_t *token; - int count = parser->toknext; - - for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { - char c; - jsmntype_t type; - - c = js[parser->pos]; - switch (c) { - case '{': case '[': - count++; - if (tokens == NULL) { - break; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == NULL) - return JSMN_ERROR_NOMEM; - if (parser->toksuper != -1) { - tokens[parser->toksuper].size++; + jsmntok_t *tokens, size_t num_tokens) { + int r; + int i; + jsmntok_t *token; + int count = parser->toknext; + + for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { + char c; + jsmntype_t type; + + c = js[parser->pos]; + switch (c) { + case '{': + case '[': + count++; + if (tokens == NULL) { + break; + } + token = jsmn_alloc_token(parser, tokens, num_tokens); + if (token == NULL) + return JSMN_ERROR_NOMEM; + if (parser->toksuper != -1) { + tokens[parser->toksuper].size++; #ifdef JSMN_PARENT_LINKS - token->parent = parser->toksuper; + token->parent = parser->toksuper; #endif - } - token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); - token->start = parser->pos; - parser->toksuper = parser->toknext - 1; - break; - case '}': case ']': - if (tokens == NULL) - break; - type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); + } + token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); + token->start = parser->pos; + parser->toksuper = parser->toknext - 1; + break; + case '}': + case ']': + if (tokens == NULL) + break; + type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); #ifdef JSMN_PARENT_LINKS - if (parser->toknext < 1) { - return JSMN_ERROR_INVAL; - } - token = &tokens[parser->toknext - 1]; - for (;;) { - if (token->start != -1 && token->end == -1) { - if (token->type != type) { - return JSMN_ERROR_INVAL; - } - token->end = parser->pos + 1; - parser->toksuper = token->parent; - break; - } - if (token->parent == -1) { - if(token->type != type || parser->toksuper == -1) { - return JSMN_ERROR_INVAL; - } - break; - } - token = &tokens[token->parent]; - } + if (parser->toknext < 1) { + return JSMN_ERROR_INVAL; + } + token = &tokens[parser->toknext - 1]; + for (;;) { + if (token->start != -1 && token->end == -1) { + if (token->type != type) { + return JSMN_ERROR_INVAL; + } + token->end = parser->pos + 1; + parser->toksuper = token->parent; + break; + } + if (token->parent == -1) { + if (token->type != type || parser->toksuper == -1) { + return JSMN_ERROR_INVAL; + } + break; + } + token = &tokens[token->parent]; + } #else - for (i = parser->toknext - 1; i >= 0; i--) { - token = &tokens[i]; - if (token->start != -1 && token->end == -1) { - if (token->type != type) { - return JSMN_ERROR_INVAL; - } - parser->toksuper = -1; - token->end = parser->pos + 1; - break; - } - } - /* Error if unmatched closing bracket */ - if (i == -1) return JSMN_ERROR_INVAL; - for (; i >= 0; i--) { - token = &tokens[i]; - if (token->start != -1 && token->end == -1) { - parser->toksuper = i; - break; - } - } + for (i = parser->toknext - 1; i >= 0; i--) { + token = &tokens[i]; + if (token->start != -1 && token->end == -1) { + if (token->type != type) { + return JSMN_ERROR_INVAL; + } + parser->toksuper = -1; + token->end = parser->pos + 1; + break; + } + } + /* Error if unmatched closing bracket */ + if (i == -1) + return JSMN_ERROR_INVAL; + for (; i >= 0; i--) { + token = &tokens[i]; + if (token->start != -1 && token->end == -1) { + parser->toksuper = i; + break; + } + } #endif - break; - case '\"': - r = jsmn_parse_string(parser, js, len, tokens, num_tokens); - if (r < 0) return r; - count++; - if (parser->toksuper != -1 && tokens != NULL) - tokens[parser->toksuper].size++; - break; - case '\t' : case '\r' : case '\n' : case ' ': - break; - case ':': - parser->toksuper = parser->toknext - 1; - break; - case ',': - if (tokens != NULL && parser->toksuper != -1 && - tokens[parser->toksuper].type != JSMN_ARRAY && - tokens[parser->toksuper].type != JSMN_OBJECT) { + break; + case '\"': + r = jsmn_parse_string(parser, js, len, tokens, num_tokens); + if (r < 0) + return r; + count++; + if (parser->toksuper != -1 && tokens != NULL) + tokens[parser->toksuper].size++; + break; + case '\t': + case '\r': + case '\n': + case ' ': + break; + case ':': + parser->toksuper = parser->toknext - 1; + break; + case ',': + if (tokens != NULL && parser->toksuper != -1 && + tokens[parser->toksuper].type != JSMN_ARRAY && + tokens[parser->toksuper].type != JSMN_OBJECT) { #ifdef JSMN_PARENT_LINKS - parser->toksuper = tokens[parser->toksuper].parent; + parser->toksuper = tokens[parser->toksuper].parent; #else - for (i = parser->toknext - 1; i >= 0; i--) { - if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { - if (tokens[i].start != -1 && tokens[i].end == -1) { - parser->toksuper = i; - break; - } - } - } + for (i = parser->toknext - 1; i >= 0; i--) { + if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { + if (tokens[i].start != -1 && tokens[i].end == -1) { + parser->toksuper = i; + break; + } + } + } #endif - } - break; + } + break; #ifdef JSMN_STRICT - /* In strict mode primitives are: numbers and booleans */ - case '-': case '0': case '1' : case '2': case '3' : case '4': - case '5': case '6': case '7' : case '8': case '9': - case 't': case 'f': case 'n' : - /* And they must not be keys of the object */ - if (tokens != NULL && parser->toksuper != -1) { - jsmntok_t *t = &tokens[parser->toksuper]; - if (t->type == JSMN_OBJECT || - (t->type == JSMN_STRING && t->size != 0)) { - return JSMN_ERROR_INVAL; - } - } + /* In strict mode primitives are: numbers and booleans */ + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 't': + case 'f': + case 'n': + /* And they must not be keys of the object */ + if (tokens != NULL && parser->toksuper != -1) { + jsmntok_t *t = &tokens[parser->toksuper]; + if (t->type == JSMN_OBJECT || + (t->type == JSMN_STRING && t->size != 0)) { + return JSMN_ERROR_INVAL; + } + } #else - /* In non-strict mode every unquoted value is a primitive */ - default: + /* In non-strict mode every unquoted value is a primitive */ + default: #endif - r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); - if (r < 0) return r; - count++; - if (parser->toksuper != -1 && tokens != NULL) - tokens[parser->toksuper].size++; - break; + r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); + if (r < 0) + return r; + count++; + if (parser->toksuper != -1 && tokens != NULL) + tokens[parser->toksuper].size++; + break; #ifdef JSMN_STRICT - /* Unexpected char in strict mode */ - default: - return JSMN_ERROR_INVAL; + /* Unexpected char in strict mode */ + default: + return JSMN_ERROR_INVAL; #endif - } - } - - if (tokens != NULL) { - for (i = parser->toknext - 1; i >= 0; i--) { - /* Unmatched opened object or array */ - if (tokens[i].start != -1 && tokens[i].end == -1) { - return JSMN_ERROR_PART; - } - } - } - - return count; + } + } + + if (tokens != NULL) { + for (i = parser->toknext - 1; i >= 0; i--) { + /* Unmatched opened object or array */ + if (tokens[i].start != -1 && tokens[i].end == -1) { + return JSMN_ERROR_PART; + } + } + } + + return count; } /** @@ -6705,9 +6540,9 @@ static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, * available. */ static void jsmn_init(jsmn_parser *parser) { - parser->pos = 0; - parser->toknext = 0; - parser->toksuper = -1; + parser->pos = 0; + parser->toknext = 0; + parser->toksuper = -1; } /* * -- jsmn.c end -- @@ -6726,7 +6561,8 @@ static void jsmn_init(jsmn_parser *parser) { * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * The above copyright notice and this permission notice shall be included in all + * The above copyright notice and this permission notice shall be included in + all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR diff --git a/Sources/MaterialX/include/MaterialX/Glad.h b/Sources/MaterialX/include/MaterialX/Glad.h index 9f9917df..11825251 100644 --- a/Sources/MaterialX/include/MaterialX/Glad.h +++ b/Sources/MaterialX/include/MaterialX/Glad.h @@ -7,19 +7,18 @@ APIs: gl=4.6 Profile: compatibility Extensions: - + Loader: True Local files: True Omit khrplatform: False Reproducible: False Commandline: - --profile="compatibility" --api="gl=4.6" --generator="c" --spec="gl" --local-files --extensions="" - Online: + --profile="compatibility" --api="gl=4.6" --generator="c" --spec="gl" + --local-files --extensions="" Online: https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D4.6 */ - #ifndef __glad_h_ #define __glad_h_ @@ -28,7 +27,8 @@ #endif #define __gl_h_ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && \ + !defined(__SCITECH_SNAP__) #define APIENTRY __stdcall #endif @@ -50,36 +50,36 @@ extern "C" { #endif struct gladGLversionStruct { - int major; - int minor; + int major; + int minor; }; -typedef void* (* GLADloadproc)(const char *name); +typedef void *(*GLADloadproc)(const char *name); #ifndef GLAPI -# if defined(GLAD_GLAPI_EXPORT) -# if defined(_WIN32) || defined(__CYGWIN__) -# if defined(GLAD_GLAPI_EXPORT_BUILD) -# if defined(__GNUC__) -# define GLAPI __attribute__ ((dllexport)) extern -# else -# define GLAPI __declspec(dllexport) extern -# endif -# else -# if defined(__GNUC__) -# define GLAPI __attribute__ ((dllimport)) extern -# else -# define GLAPI __declspec(dllimport) extern -# endif -# endif -# elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD) -# define GLAPI __attribute__ ((visibility ("default"))) extern -# else -# define GLAPI extern -# endif -# else -# define GLAPI extern -# endif +#if defined(GLAD_GLAPI_EXPORT) +#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(GLAD_GLAPI_EXPORT_BUILD) +#if defined(__GNUC__) +#define GLAPI __attribute__((dllexport)) extern +#else +#define GLAPI __declspec(dllexport) extern +#endif +#else +#if defined(__GNUC__) +#define GLAPI __attribute__((dllimport)) extern +#else +#define GLAPI __declspec(dllimport) extern +#endif +#endif +#elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD) +#define GLAPI __attribute__((visibility("default"))) extern +#else +#define GLAPI extern +#endif +#else +#define GLAPI extern +#endif #endif GLAPI struct gladGLversionStruct GLVersion; @@ -127,13 +127,24 @@ typedef khronos_uint64_t GLuint64EXT; typedef struct __GLsync *GLsync; struct _cl_context; struct _cl_event; -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +typedef void(APIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, + GLenum severity, GLsizei length, + const GLchar *message, + const void *userParam); +typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, + GLenum severity, GLsizei length, + const GLchar *message, + const void *userParam); +typedef void(APIENTRY *GLDEBUGPROCKHR)(GLenum source, GLenum type, GLuint id, + GLenum severity, GLsizei length, + const GLchar *message, + const void *userParam); +typedef void(APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, + GLenum severity, GLsizei length, + const GLchar *message, void *userParam); typedef unsigned short GLhalfNV; typedef GLintptr GLvdpauSurfaceNV; -typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void(APIENTRY *GLVULKANPROCNV)(void); #define GL_DEPTH_BUFFER_BIT 0x00000100 #define GL_STENCIL_BUFFER_BIT 0x00000400 #define GL_COLOR_BUFFER_BIT 0x00004000 @@ -1945,3220 +1956,4420 @@ typedef void (APIENTRY *GLVULKANPROCNV)(void); #ifndef GL_VERSION_1_0 #define GL_VERSION_1_0 1 GLAPI int GLAD_GL_VERSION_1_0; -typedef void (APIENTRYP PFNGLCULLFACEPROC)(GLenum mode); +typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode); GLAPI PFNGLCULLFACEPROC glad_glCullFace; #define glCullFace glad_glCullFace -typedef void (APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode); +typedef void(APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode); GLAPI PFNGLFRONTFACEPROC glad_glFrontFace; #define glFrontFace glad_glFrontFace -typedef void (APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode); +typedef void(APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode); GLAPI PFNGLHINTPROC glad_glHint; #define glHint glad_glHint -typedef void (APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width); +typedef void(APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width); GLAPI PFNGLLINEWIDTHPROC glad_glLineWidth; #define glLineWidth glad_glLineWidth -typedef void (APIENTRYP PFNGLPOINTSIZEPROC)(GLfloat size); +typedef void(APIENTRYP PFNGLPOINTSIZEPROC)(GLfloat size); GLAPI PFNGLPOINTSIZEPROC glad_glPointSize; #define glPointSize glad_glPointSize -typedef void (APIENTRYP PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode); +typedef void(APIENTRYP PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode); GLAPI PFNGLPOLYGONMODEPROC glad_glPolygonMode; #define glPolygonMode glad_glPolygonMode -typedef void (APIENTRYP PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, + GLsizei height); GLAPI PFNGLSCISSORPROC glad_glScissor; #define glScissor glad_glScissor -typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, + GLfloat param); GLAPI PFNGLTEXPARAMETERFPROC glad_glTexParameterf; #define glTexParameterf glad_glTexParameterf -typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, + const GLfloat *params); GLAPI PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv; #define glTexParameterfv glad_glTexParameterfv -typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, + GLint param); GLAPI PFNGLTEXPARAMETERIPROC glad_glTexParameteri; #define glTexParameteri glad_glTexParameteri -typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, + const GLint *params); GLAPI PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv; #define glTexParameteriv glad_glTexParameteriv -typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, + GLint internalformat, GLsizei width, + GLint border, GLenum format, + GLenum type, const void *pixels); GLAPI PFNGLTEXIMAGE1DPROC glad_glTexImage1D; #define glTexImage1D glad_glTexImage1D -typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, + GLint internalformat, GLsizei width, + GLsizei height, GLint border, + GLenum format, GLenum type, + const void *pixels); GLAPI PFNGLTEXIMAGE2DPROC glad_glTexImage2D; #define glTexImage2D glad_glTexImage2D -typedef void (APIENTRYP PFNGLDRAWBUFFERPROC)(GLenum buf); +typedef void(APIENTRYP PFNGLDRAWBUFFERPROC)(GLenum buf); GLAPI PFNGLDRAWBUFFERPROC glad_glDrawBuffer; #define glDrawBuffer glad_glDrawBuffer -typedef void (APIENTRYP PFNGLCLEARPROC)(GLbitfield mask); +typedef void(APIENTRYP PFNGLCLEARPROC)(GLbitfield mask); GLAPI PFNGLCLEARPROC glad_glClear; #define glClear glad_glClear -typedef void (APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha); GLAPI PFNGLCLEARCOLORPROC glad_glClearColor; #define glClearColor glad_glClearColor -typedef void (APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s); +typedef void(APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s); GLAPI PFNGLCLEARSTENCILPROC glad_glClearStencil; #define glClearStencil glad_glClearStencil -typedef void (APIENTRYP PFNGLCLEARDEPTHPROC)(GLdouble depth); +typedef void(APIENTRYP PFNGLCLEARDEPTHPROC)(GLdouble depth); GLAPI PFNGLCLEARDEPTHPROC glad_glClearDepth; #define glClearDepth glad_glClearDepth -typedef void (APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask); +typedef void(APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask); GLAPI PFNGLSTENCILMASKPROC glad_glStencilMask; #define glStencilMask glad_glStencilMask -typedef void (APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void(APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha); GLAPI PFNGLCOLORMASKPROC glad_glColorMask; #define glColorMask glad_glColorMask -typedef void (APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag); +typedef void(APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag); GLAPI PFNGLDEPTHMASKPROC glad_glDepthMask; #define glDepthMask glad_glDepthMask -typedef void (APIENTRYP PFNGLDISABLEPROC)(GLenum cap); +typedef void(APIENTRYP PFNGLDISABLEPROC)(GLenum cap); GLAPI PFNGLDISABLEPROC glad_glDisable; #define glDisable glad_glDisable -typedef void (APIENTRYP PFNGLENABLEPROC)(GLenum cap); +typedef void(APIENTRYP PFNGLENABLEPROC)(GLenum cap); GLAPI PFNGLENABLEPROC glad_glEnable; #define glEnable glad_glEnable -typedef void (APIENTRYP PFNGLFINISHPROC)(void); +typedef void(APIENTRYP PFNGLFINISHPROC)(void); GLAPI PFNGLFINISHPROC glad_glFinish; #define glFinish glad_glFinish -typedef void (APIENTRYP PFNGLFLUSHPROC)(void); +typedef void(APIENTRYP PFNGLFLUSHPROC)(void); GLAPI PFNGLFLUSHPROC glad_glFlush; #define glFlush glad_glFlush -typedef void (APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); +typedef void(APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); GLAPI PFNGLBLENDFUNCPROC glad_glBlendFunc; #define glBlendFunc glad_glBlendFunc -typedef void (APIENTRYP PFNGLLOGICOPPROC)(GLenum opcode); +typedef void(APIENTRYP PFNGLLOGICOPPROC)(GLenum opcode); GLAPI PFNGLLOGICOPPROC glad_glLogicOp; #define glLogicOp glad_glLogicOp -typedef void (APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask); +typedef void(APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, + GLuint mask); GLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc; #define glStencilFunc glad_glStencilFunc -typedef void (APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass); +typedef void(APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, + GLenum zpass); GLAPI PFNGLSTENCILOPPROC glad_glStencilOp; #define glStencilOp glad_glStencilOp -typedef void (APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func); +typedef void(APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func); GLAPI PFNGLDEPTHFUNCPROC glad_glDepthFunc; #define glDepthFunc glad_glDepthFunc -typedef void (APIENTRYP PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param); GLAPI PFNGLPIXELSTOREFPROC glad_glPixelStoref; #define glPixelStoref glad_glPixelStoref -typedef void (APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); GLAPI PFNGLPIXELSTOREIPROC glad_glPixelStorei; #define glPixelStorei glad_glPixelStorei -typedef void (APIENTRYP PFNGLREADBUFFERPROC)(GLenum src); +typedef void(APIENTRYP PFNGLREADBUFFERPROC)(GLenum src); GLAPI PFNGLREADBUFFERPROC glad_glReadBuffer; #define glReadBuffer glad_glReadBuffer -typedef void (APIENTRYP PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void(APIENTRYP PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, + GLsizei height, GLenum format, + GLenum type, void *pixels); GLAPI PFNGLREADPIXELSPROC glad_glReadPixels; #define glReadPixels glad_glReadPixels -typedef void (APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean *data); +typedef void(APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean *data); GLAPI PFNGLGETBOOLEANVPROC glad_glGetBooleanv; #define glGetBooleanv glad_glGetBooleanv -typedef void (APIENTRYP PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble *data); +typedef void(APIENTRYP PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble *data); GLAPI PFNGLGETDOUBLEVPROC glad_glGetDoublev; #define glGetDoublev glad_glGetDoublev -typedef GLenum (APIENTRYP PFNGLGETERRORPROC)(void); +typedef GLenum(APIENTRYP PFNGLGETERRORPROC)(void); GLAPI PFNGLGETERRORPROC glad_glGetError; #define glGetError glad_glGetError -typedef void (APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat *data); +typedef void(APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat *data); GLAPI PFNGLGETFLOATVPROC glad_glGetFloatv; #define glGetFloatv glad_glGetFloatv -typedef void (APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint *data); +typedef void(APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint *data); GLAPI PFNGLGETINTEGERVPROC glad_glGetIntegerv; #define glGetIntegerv glad_glGetIntegerv -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC)(GLenum name); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC)(GLenum name); GLAPI PFNGLGETSTRINGPROC glad_glGetString; #define glGetString glad_glGetString -typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void(APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, + GLenum format, GLenum type, + void *pixels); GLAPI PFNGLGETTEXIMAGEPROC glad_glGetTexImage; #define glGetTexImage glad_glGetTexImage -typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, + GLfloat *params); GLAPI PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv; #define glGetTexParameterfv glad_glGetTexParameterfv -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, + GLint *params); GLAPI PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv; #define glGetTexParameteriv glad_glGetTexParameteriv -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, + GLint level, + GLenum pname, + GLfloat *params); GLAPI PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv; #define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, + GLint level, + GLenum pname, + GLint *params); GLAPI PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv; #define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv -typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); +typedef GLboolean(APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); GLAPI PFNGLISENABLEDPROC glad_glIsEnabled; #define glIsEnabled glad_glIsEnabled -typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); +typedef void(APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); GLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange; #define glDepthRange glad_glDepthRange -typedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, + GLsizei height); GLAPI PFNGLVIEWPORTPROC glad_glViewport; #define glViewport glad_glViewport -typedef void (APIENTRYP PFNGLNEWLISTPROC)(GLuint list, GLenum mode); +typedef void(APIENTRYP PFNGLNEWLISTPROC)(GLuint list, GLenum mode); GLAPI PFNGLNEWLISTPROC glad_glNewList; #define glNewList glad_glNewList -typedef void (APIENTRYP PFNGLENDLISTPROC)(void); +typedef void(APIENTRYP PFNGLENDLISTPROC)(void); GLAPI PFNGLENDLISTPROC glad_glEndList; #define glEndList glad_glEndList -typedef void (APIENTRYP PFNGLCALLLISTPROC)(GLuint list); +typedef void(APIENTRYP PFNGLCALLLISTPROC)(GLuint list); GLAPI PFNGLCALLLISTPROC glad_glCallList; #define glCallList glad_glCallList -typedef void (APIENTRYP PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, const void *lists); +typedef void(APIENTRYP PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, + const void *lists); GLAPI PFNGLCALLLISTSPROC glad_glCallLists; #define glCallLists glad_glCallLists -typedef void (APIENTRYP PFNGLDELETELISTSPROC)(GLuint list, GLsizei range); +typedef void(APIENTRYP PFNGLDELETELISTSPROC)(GLuint list, GLsizei range); GLAPI PFNGLDELETELISTSPROC glad_glDeleteLists; #define glDeleteLists glad_glDeleteLists -typedef GLuint (APIENTRYP PFNGLGENLISTSPROC)(GLsizei range); +typedef GLuint(APIENTRYP PFNGLGENLISTSPROC)(GLsizei range); GLAPI PFNGLGENLISTSPROC glad_glGenLists; #define glGenLists glad_glGenLists -typedef void (APIENTRYP PFNGLLISTBASEPROC)(GLuint base); +typedef void(APIENTRYP PFNGLLISTBASEPROC)(GLuint base); GLAPI PFNGLLISTBASEPROC glad_glListBase; #define glListBase glad_glListBase -typedef void (APIENTRYP PFNGLBEGINPROC)(GLenum mode); +typedef void(APIENTRYP PFNGLBEGINPROC)(GLenum mode); GLAPI PFNGLBEGINPROC glad_glBegin; #define glBegin glad_glBegin -typedef void (APIENTRYP PFNGLBITMAPPROC)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +typedef void(APIENTRYP PFNGLBITMAPPROC)(GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap); GLAPI PFNGLBITMAPPROC glad_glBitmap; #define glBitmap glad_glBitmap -typedef void (APIENTRYP PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +typedef void(APIENTRYP PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); GLAPI PFNGLCOLOR3BPROC glad_glColor3b; #define glColor3b glad_glColor3b -typedef void (APIENTRYP PFNGLCOLOR3BVPROC)(const GLbyte *v); +typedef void(APIENTRYP PFNGLCOLOR3BVPROC)(const GLbyte *v); GLAPI PFNGLCOLOR3BVPROC glad_glColor3bv; #define glColor3bv glad_glColor3bv -typedef void (APIENTRYP PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +typedef void(APIENTRYP PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, + GLdouble blue); GLAPI PFNGLCOLOR3DPROC glad_glColor3d; #define glColor3d glad_glColor3d -typedef void (APIENTRYP PFNGLCOLOR3DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLCOLOR3DVPROC)(const GLdouble *v); GLAPI PFNGLCOLOR3DVPROC glad_glColor3dv; #define glColor3dv glad_glColor3dv -typedef void (APIENTRYP PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void(APIENTRYP PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, + GLfloat blue); GLAPI PFNGLCOLOR3FPROC glad_glColor3f; #define glColor3f glad_glColor3f -typedef void (APIENTRYP PFNGLCOLOR3FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLCOLOR3FVPROC)(const GLfloat *v); GLAPI PFNGLCOLOR3FVPROC glad_glColor3fv; #define glColor3fv glad_glColor3fv -typedef void (APIENTRYP PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue); +typedef void(APIENTRYP PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue); GLAPI PFNGLCOLOR3IPROC glad_glColor3i; #define glColor3i glad_glColor3i -typedef void (APIENTRYP PFNGLCOLOR3IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLCOLOR3IVPROC)(const GLint *v); GLAPI PFNGLCOLOR3IVPROC glad_glColor3iv; #define glColor3iv glad_glColor3iv -typedef void (APIENTRYP PFNGLCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +typedef void(APIENTRYP PFNGLCOLOR3SPROC)(GLshort red, GLshort green, + GLshort blue); GLAPI PFNGLCOLOR3SPROC glad_glColor3s; #define glColor3s glad_glColor3s -typedef void (APIENTRYP PFNGLCOLOR3SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLCOLOR3SVPROC)(const GLshort *v); GLAPI PFNGLCOLOR3SVPROC glad_glColor3sv; #define glColor3sv glad_glColor3sv -typedef void (APIENTRYP PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void(APIENTRYP PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, + GLubyte blue); GLAPI PFNGLCOLOR3UBPROC glad_glColor3ub; #define glColor3ub glad_glColor3ub -typedef void (APIENTRYP PFNGLCOLOR3UBVPROC)(const GLubyte *v); +typedef void(APIENTRYP PFNGLCOLOR3UBVPROC)(const GLubyte *v); GLAPI PFNGLCOLOR3UBVPROC glad_glColor3ubv; #define glColor3ubv glad_glColor3ubv -typedef void (APIENTRYP PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +typedef void(APIENTRYP PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, + GLuint blue); GLAPI PFNGLCOLOR3UIPROC glad_glColor3ui; #define glColor3ui glad_glColor3ui -typedef void (APIENTRYP PFNGLCOLOR3UIVPROC)(const GLuint *v); +typedef void(APIENTRYP PFNGLCOLOR3UIVPROC)(const GLuint *v); GLAPI PFNGLCOLOR3UIVPROC glad_glColor3uiv; #define glColor3uiv glad_glColor3uiv -typedef void (APIENTRYP PFNGLCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +typedef void(APIENTRYP PFNGLCOLOR3USPROC)(GLushort red, GLushort green, + GLushort blue); GLAPI PFNGLCOLOR3USPROC glad_glColor3us; #define glColor3us glad_glColor3us -typedef void (APIENTRYP PFNGLCOLOR3USVPROC)(const GLushort *v); +typedef void(APIENTRYP PFNGLCOLOR3USVPROC)(const GLushort *v); GLAPI PFNGLCOLOR3USVPROC glad_glColor3usv; #define glColor3usv glad_glColor3usv -typedef void (APIENTRYP PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +typedef void(APIENTRYP PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, + GLbyte alpha); GLAPI PFNGLCOLOR4BPROC glad_glColor4b; #define glColor4b glad_glColor4b -typedef void (APIENTRYP PFNGLCOLOR4BVPROC)(const GLbyte *v); +typedef void(APIENTRYP PFNGLCOLOR4BVPROC)(const GLbyte *v); GLAPI PFNGLCOLOR4BVPROC glad_glColor4bv; #define glColor4bv glad_glColor4bv -typedef void (APIENTRYP PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +typedef void(APIENTRYP PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha); GLAPI PFNGLCOLOR4DPROC glad_glColor4d; #define glColor4d glad_glColor4d -typedef void (APIENTRYP PFNGLCOLOR4DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLCOLOR4DVPROC)(const GLdouble *v); GLAPI PFNGLCOLOR4DVPROC glad_glColor4dv; #define glColor4dv glad_glColor4dv -typedef void (APIENTRYP PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(APIENTRYP PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha); GLAPI PFNGLCOLOR4FPROC glad_glColor4f; #define glColor4f glad_glColor4f -typedef void (APIENTRYP PFNGLCOLOR4FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLCOLOR4FVPROC)(const GLfloat *v); GLAPI PFNGLCOLOR4FVPROC glad_glColor4fv; #define glColor4fv glad_glColor4fv -typedef void (APIENTRYP PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, GLint alpha); +typedef void(APIENTRYP PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, + GLint alpha); GLAPI PFNGLCOLOR4IPROC glad_glColor4i; #define glColor4i glad_glColor4i -typedef void (APIENTRYP PFNGLCOLOR4IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLCOLOR4IVPROC)(const GLint *v); GLAPI PFNGLCOLOR4IVPROC glad_glColor4iv; #define glColor4iv glad_glColor4iv -typedef void (APIENTRYP PFNGLCOLOR4SPROC)(GLshort red, GLshort green, GLshort blue, GLshort alpha); +typedef void(APIENTRYP PFNGLCOLOR4SPROC)(GLshort red, GLshort green, + GLshort blue, GLshort alpha); GLAPI PFNGLCOLOR4SPROC glad_glColor4s; #define glColor4s glad_glColor4s -typedef void (APIENTRYP PFNGLCOLOR4SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLCOLOR4SVPROC)(const GLshort *v); GLAPI PFNGLCOLOR4SVPROC glad_glColor4sv; #define glColor4sv glad_glColor4sv -typedef void (APIENTRYP PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +typedef void(APIENTRYP PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha); GLAPI PFNGLCOLOR4UBPROC glad_glColor4ub; #define glColor4ub glad_glColor4ub -typedef void (APIENTRYP PFNGLCOLOR4UBVPROC)(const GLubyte *v); +typedef void(APIENTRYP PFNGLCOLOR4UBVPROC)(const GLubyte *v); GLAPI PFNGLCOLOR4UBVPROC glad_glColor4ubv; #define glColor4ubv glad_glColor4ubv -typedef void (APIENTRYP PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void(APIENTRYP PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, + GLuint alpha); GLAPI PFNGLCOLOR4UIPROC glad_glColor4ui; #define glColor4ui glad_glColor4ui -typedef void (APIENTRYP PFNGLCOLOR4UIVPROC)(const GLuint *v); +typedef void(APIENTRYP PFNGLCOLOR4UIVPROC)(const GLuint *v); GLAPI PFNGLCOLOR4UIVPROC glad_glColor4uiv; #define glColor4uiv glad_glColor4uiv -typedef void (APIENTRYP PFNGLCOLOR4USPROC)(GLushort red, GLushort green, GLushort blue, GLushort alpha); +typedef void(APIENTRYP PFNGLCOLOR4USPROC)(GLushort red, GLushort green, + GLushort blue, GLushort alpha); GLAPI PFNGLCOLOR4USPROC glad_glColor4us; #define glColor4us glad_glColor4us -typedef void (APIENTRYP PFNGLCOLOR4USVPROC)(const GLushort *v); +typedef void(APIENTRYP PFNGLCOLOR4USVPROC)(const GLushort *v); GLAPI PFNGLCOLOR4USVPROC glad_glColor4usv; #define glColor4usv glad_glColor4usv -typedef void (APIENTRYP PFNGLEDGEFLAGPROC)(GLboolean flag); +typedef void(APIENTRYP PFNGLEDGEFLAGPROC)(GLboolean flag); GLAPI PFNGLEDGEFLAGPROC glad_glEdgeFlag; #define glEdgeFlag glad_glEdgeFlag -typedef void (APIENTRYP PFNGLEDGEFLAGVPROC)(const GLboolean *flag); +typedef void(APIENTRYP PFNGLEDGEFLAGVPROC)(const GLboolean *flag); GLAPI PFNGLEDGEFLAGVPROC glad_glEdgeFlagv; #define glEdgeFlagv glad_glEdgeFlagv -typedef void (APIENTRYP PFNGLENDPROC)(void); +typedef void(APIENTRYP PFNGLENDPROC)(void); GLAPI PFNGLENDPROC glad_glEnd; #define glEnd glad_glEnd -typedef void (APIENTRYP PFNGLINDEXDPROC)(GLdouble c); +typedef void(APIENTRYP PFNGLINDEXDPROC)(GLdouble c); GLAPI PFNGLINDEXDPROC glad_glIndexd; #define glIndexd glad_glIndexd -typedef void (APIENTRYP PFNGLINDEXDVPROC)(const GLdouble *c); +typedef void(APIENTRYP PFNGLINDEXDVPROC)(const GLdouble *c); GLAPI PFNGLINDEXDVPROC glad_glIndexdv; #define glIndexdv glad_glIndexdv -typedef void (APIENTRYP PFNGLINDEXFPROC)(GLfloat c); +typedef void(APIENTRYP PFNGLINDEXFPROC)(GLfloat c); GLAPI PFNGLINDEXFPROC glad_glIndexf; #define glIndexf glad_glIndexf -typedef void (APIENTRYP PFNGLINDEXFVPROC)(const GLfloat *c); +typedef void(APIENTRYP PFNGLINDEXFVPROC)(const GLfloat *c); GLAPI PFNGLINDEXFVPROC glad_glIndexfv; #define glIndexfv glad_glIndexfv -typedef void (APIENTRYP PFNGLINDEXIPROC)(GLint c); +typedef void(APIENTRYP PFNGLINDEXIPROC)(GLint c); GLAPI PFNGLINDEXIPROC glad_glIndexi; #define glIndexi glad_glIndexi -typedef void (APIENTRYP PFNGLINDEXIVPROC)(const GLint *c); +typedef void(APIENTRYP PFNGLINDEXIVPROC)(const GLint *c); GLAPI PFNGLINDEXIVPROC glad_glIndexiv; #define glIndexiv glad_glIndexiv -typedef void (APIENTRYP PFNGLINDEXSPROC)(GLshort c); +typedef void(APIENTRYP PFNGLINDEXSPROC)(GLshort c); GLAPI PFNGLINDEXSPROC glad_glIndexs; #define glIndexs glad_glIndexs -typedef void (APIENTRYP PFNGLINDEXSVPROC)(const GLshort *c); +typedef void(APIENTRYP PFNGLINDEXSVPROC)(const GLshort *c); GLAPI PFNGLINDEXSVPROC glad_glIndexsv; #define glIndexsv glad_glIndexsv -typedef void (APIENTRYP PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz); +typedef void(APIENTRYP PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz); GLAPI PFNGLNORMAL3BPROC glad_glNormal3b; #define glNormal3b glad_glNormal3b -typedef void (APIENTRYP PFNGLNORMAL3BVPROC)(const GLbyte *v); +typedef void(APIENTRYP PFNGLNORMAL3BVPROC)(const GLbyte *v); GLAPI PFNGLNORMAL3BVPROC glad_glNormal3bv; #define glNormal3bv glad_glNormal3bv -typedef void (APIENTRYP PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, GLdouble nz); +typedef void(APIENTRYP PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, + GLdouble nz); GLAPI PFNGLNORMAL3DPROC glad_glNormal3d; #define glNormal3d glad_glNormal3d -typedef void (APIENTRYP PFNGLNORMAL3DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLNORMAL3DVPROC)(const GLdouble *v); GLAPI PFNGLNORMAL3DVPROC glad_glNormal3dv; #define glNormal3dv glad_glNormal3dv -typedef void (APIENTRYP PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz); +typedef void(APIENTRYP PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz); GLAPI PFNGLNORMAL3FPROC glad_glNormal3f; #define glNormal3f glad_glNormal3f -typedef void (APIENTRYP PFNGLNORMAL3FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLNORMAL3FVPROC)(const GLfloat *v); GLAPI PFNGLNORMAL3FVPROC glad_glNormal3fv; #define glNormal3fv glad_glNormal3fv -typedef void (APIENTRYP PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz); +typedef void(APIENTRYP PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz); GLAPI PFNGLNORMAL3IPROC glad_glNormal3i; #define glNormal3i glad_glNormal3i -typedef void (APIENTRYP PFNGLNORMAL3IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLNORMAL3IVPROC)(const GLint *v); GLAPI PFNGLNORMAL3IVPROC glad_glNormal3iv; #define glNormal3iv glad_glNormal3iv -typedef void (APIENTRYP PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz); +typedef void(APIENTRYP PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz); GLAPI PFNGLNORMAL3SPROC glad_glNormal3s; #define glNormal3s glad_glNormal3s -typedef void (APIENTRYP PFNGLNORMAL3SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLNORMAL3SVPROC)(const GLshort *v); GLAPI PFNGLNORMAL3SVPROC glad_glNormal3sv; #define glNormal3sv glad_glNormal3sv -typedef void (APIENTRYP PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y); +typedef void(APIENTRYP PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y); GLAPI PFNGLRASTERPOS2DPROC glad_glRasterPos2d; #define glRasterPos2d glad_glRasterPos2d -typedef void (APIENTRYP PFNGLRASTERPOS2DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLRASTERPOS2DVPROC)(const GLdouble *v); GLAPI PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv; #define glRasterPos2dv glad_glRasterPos2dv -typedef void (APIENTRYP PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y); +typedef void(APIENTRYP PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y); GLAPI PFNGLRASTERPOS2FPROC glad_glRasterPos2f; #define glRasterPos2f glad_glRasterPos2f -typedef void (APIENTRYP PFNGLRASTERPOS2FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLRASTERPOS2FVPROC)(const GLfloat *v); GLAPI PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv; #define glRasterPos2fv glad_glRasterPos2fv -typedef void (APIENTRYP PFNGLRASTERPOS2IPROC)(GLint x, GLint y); +typedef void(APIENTRYP PFNGLRASTERPOS2IPROC)(GLint x, GLint y); GLAPI PFNGLRASTERPOS2IPROC glad_glRasterPos2i; #define glRasterPos2i glad_glRasterPos2i -typedef void (APIENTRYP PFNGLRASTERPOS2IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLRASTERPOS2IVPROC)(const GLint *v); GLAPI PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv; #define glRasterPos2iv glad_glRasterPos2iv -typedef void (APIENTRYP PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y); +typedef void(APIENTRYP PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y); GLAPI PFNGLRASTERPOS2SPROC glad_glRasterPos2s; #define glRasterPos2s glad_glRasterPos2s -typedef void (APIENTRYP PFNGLRASTERPOS2SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLRASTERPOS2SVPROC)(const GLshort *v); GLAPI PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv; #define glRasterPos2sv glad_glRasterPos2sv -typedef void (APIENTRYP PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, + GLdouble z); GLAPI PFNGLRASTERPOS3DPROC glad_glRasterPos3d; #define glRasterPos3d glad_glRasterPos3d -typedef void (APIENTRYP PFNGLRASTERPOS3DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLRASTERPOS3DVPROC)(const GLdouble *v); GLAPI PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv; #define glRasterPos3dv glad_glRasterPos3dv -typedef void (APIENTRYP PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(APIENTRYP PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); GLAPI PFNGLRASTERPOS3FPROC glad_glRasterPos3f; #define glRasterPos3f glad_glRasterPos3f -typedef void (APIENTRYP PFNGLRASTERPOS3FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLRASTERPOS3FVPROC)(const GLfloat *v); GLAPI PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv; #define glRasterPos3fv glad_glRasterPos3fv -typedef void (APIENTRYP PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z); +typedef void(APIENTRYP PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z); GLAPI PFNGLRASTERPOS3IPROC glad_glRasterPos3i; #define glRasterPos3i glad_glRasterPos3i -typedef void (APIENTRYP PFNGLRASTERPOS3IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLRASTERPOS3IVPROC)(const GLint *v); GLAPI PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv; #define glRasterPos3iv glad_glRasterPos3iv -typedef void (APIENTRYP PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void(APIENTRYP PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z); GLAPI PFNGLRASTERPOS3SPROC glad_glRasterPos3s; #define glRasterPos3s glad_glRasterPos3s -typedef void (APIENTRYP PFNGLRASTERPOS3SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLRASTERPOS3SVPROC)(const GLshort *v); GLAPI PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv; #define glRasterPos3sv glad_glRasterPos3sv -typedef void (APIENTRYP PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(APIENTRYP PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, + GLdouble w); GLAPI PFNGLRASTERPOS4DPROC glad_glRasterPos4d; #define glRasterPos4d glad_glRasterPos4d -typedef void (APIENTRYP PFNGLRASTERPOS4DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLRASTERPOS4DVPROC)(const GLdouble *v); GLAPI PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv; #define glRasterPos4dv glad_glRasterPos4dv -typedef void (APIENTRYP PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void(APIENTRYP PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, + GLfloat w); GLAPI PFNGLRASTERPOS4FPROC glad_glRasterPos4f; #define glRasterPos4f glad_glRasterPos4f -typedef void (APIENTRYP PFNGLRASTERPOS4FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLRASTERPOS4FVPROC)(const GLfloat *v); GLAPI PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv; #define glRasterPos4fv glad_glRasterPos4fv -typedef void (APIENTRYP PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, GLint w); +typedef void(APIENTRYP PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, + GLint w); GLAPI PFNGLRASTERPOS4IPROC glad_glRasterPos4i; #define glRasterPos4i glad_glRasterPos4i -typedef void (APIENTRYP PFNGLRASTERPOS4IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLRASTERPOS4IVPROC)(const GLint *v); GLAPI PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv; #define glRasterPos4iv glad_glRasterPos4iv -typedef void (APIENTRYP PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void(APIENTRYP PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, + GLshort w); GLAPI PFNGLRASTERPOS4SPROC glad_glRasterPos4s; #define glRasterPos4s glad_glRasterPos4s -typedef void (APIENTRYP PFNGLRASTERPOS4SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLRASTERPOS4SVPROC)(const GLshort *v); GLAPI PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv; #define glRasterPos4sv glad_glRasterPos4sv -typedef void (APIENTRYP PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +typedef void(APIENTRYP PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, + GLdouble y2); GLAPI PFNGLRECTDPROC glad_glRectd; #define glRectd glad_glRectd -typedef void (APIENTRYP PFNGLRECTDVPROC)(const GLdouble *v1, const GLdouble *v2); +typedef void(APIENTRYP PFNGLRECTDVPROC)(const GLdouble *v1, const GLdouble *v2); GLAPI PFNGLRECTDVPROC glad_glRectdv; #define glRectdv glad_glRectdv -typedef void (APIENTRYP PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +typedef void(APIENTRYP PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, + GLfloat y2); GLAPI PFNGLRECTFPROC glad_glRectf; #define glRectf glad_glRectf -typedef void (APIENTRYP PFNGLRECTFVPROC)(const GLfloat *v1, const GLfloat *v2); +typedef void(APIENTRYP PFNGLRECTFVPROC)(const GLfloat *v1, const GLfloat *v2); GLAPI PFNGLRECTFVPROC glad_glRectfv; #define glRectfv glad_glRectfv -typedef void (APIENTRYP PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2); +typedef void(APIENTRYP PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2); GLAPI PFNGLRECTIPROC glad_glRecti; #define glRecti glad_glRecti -typedef void (APIENTRYP PFNGLRECTIVPROC)(const GLint *v1, const GLint *v2); +typedef void(APIENTRYP PFNGLRECTIVPROC)(const GLint *v1, const GLint *v2); GLAPI PFNGLRECTIVPROC glad_glRectiv; #define glRectiv glad_glRectiv -typedef void (APIENTRYP PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +typedef void(APIENTRYP PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, + GLshort y2); GLAPI PFNGLRECTSPROC glad_glRects; #define glRects glad_glRects -typedef void (APIENTRYP PFNGLRECTSVPROC)(const GLshort *v1, const GLshort *v2); +typedef void(APIENTRYP PFNGLRECTSVPROC)(const GLshort *v1, const GLshort *v2); GLAPI PFNGLRECTSVPROC glad_glRectsv; #define glRectsv glad_glRectsv -typedef void (APIENTRYP PFNGLTEXCOORD1DPROC)(GLdouble s); +typedef void(APIENTRYP PFNGLTEXCOORD1DPROC)(GLdouble s); GLAPI PFNGLTEXCOORD1DPROC glad_glTexCoord1d; #define glTexCoord1d glad_glTexCoord1d -typedef void (APIENTRYP PFNGLTEXCOORD1DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLTEXCOORD1DVPROC)(const GLdouble *v); GLAPI PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv; #define glTexCoord1dv glad_glTexCoord1dv -typedef void (APIENTRYP PFNGLTEXCOORD1FPROC)(GLfloat s); +typedef void(APIENTRYP PFNGLTEXCOORD1FPROC)(GLfloat s); GLAPI PFNGLTEXCOORD1FPROC glad_glTexCoord1f; #define glTexCoord1f glad_glTexCoord1f -typedef void (APIENTRYP PFNGLTEXCOORD1FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLTEXCOORD1FVPROC)(const GLfloat *v); GLAPI PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv; #define glTexCoord1fv glad_glTexCoord1fv -typedef void (APIENTRYP PFNGLTEXCOORD1IPROC)(GLint s); +typedef void(APIENTRYP PFNGLTEXCOORD1IPROC)(GLint s); GLAPI PFNGLTEXCOORD1IPROC glad_glTexCoord1i; #define glTexCoord1i glad_glTexCoord1i -typedef void (APIENTRYP PFNGLTEXCOORD1IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLTEXCOORD1IVPROC)(const GLint *v); GLAPI PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv; #define glTexCoord1iv glad_glTexCoord1iv -typedef void (APIENTRYP PFNGLTEXCOORD1SPROC)(GLshort s); +typedef void(APIENTRYP PFNGLTEXCOORD1SPROC)(GLshort s); GLAPI PFNGLTEXCOORD1SPROC glad_glTexCoord1s; #define glTexCoord1s glad_glTexCoord1s -typedef void (APIENTRYP PFNGLTEXCOORD1SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLTEXCOORD1SVPROC)(const GLshort *v); GLAPI PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv; #define glTexCoord1sv glad_glTexCoord1sv -typedef void (APIENTRYP PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t); +typedef void(APIENTRYP PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t); GLAPI PFNGLTEXCOORD2DPROC glad_glTexCoord2d; #define glTexCoord2d glad_glTexCoord2d -typedef void (APIENTRYP PFNGLTEXCOORD2DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLTEXCOORD2DVPROC)(const GLdouble *v); GLAPI PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv; #define glTexCoord2dv glad_glTexCoord2dv -typedef void (APIENTRYP PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t); +typedef void(APIENTRYP PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t); GLAPI PFNGLTEXCOORD2FPROC glad_glTexCoord2f; #define glTexCoord2f glad_glTexCoord2f -typedef void (APIENTRYP PFNGLTEXCOORD2FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLTEXCOORD2FVPROC)(const GLfloat *v); GLAPI PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv; #define glTexCoord2fv glad_glTexCoord2fv -typedef void (APIENTRYP PFNGLTEXCOORD2IPROC)(GLint s, GLint t); +typedef void(APIENTRYP PFNGLTEXCOORD2IPROC)(GLint s, GLint t); GLAPI PFNGLTEXCOORD2IPROC glad_glTexCoord2i; #define glTexCoord2i glad_glTexCoord2i -typedef void (APIENTRYP PFNGLTEXCOORD2IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLTEXCOORD2IVPROC)(const GLint *v); GLAPI PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv; #define glTexCoord2iv glad_glTexCoord2iv -typedef void (APIENTRYP PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t); +typedef void(APIENTRYP PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t); GLAPI PFNGLTEXCOORD2SPROC glad_glTexCoord2s; #define glTexCoord2s glad_glTexCoord2s -typedef void (APIENTRYP PFNGLTEXCOORD2SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLTEXCOORD2SVPROC)(const GLshort *v); GLAPI PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv; #define glTexCoord2sv glad_glTexCoord2sv -typedef void (APIENTRYP PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r); +typedef void(APIENTRYP PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r); GLAPI PFNGLTEXCOORD3DPROC glad_glTexCoord3d; #define glTexCoord3d glad_glTexCoord3d -typedef void (APIENTRYP PFNGLTEXCOORD3DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLTEXCOORD3DVPROC)(const GLdouble *v); GLAPI PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv; #define glTexCoord3dv glad_glTexCoord3dv -typedef void (APIENTRYP PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r); +typedef void(APIENTRYP PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r); GLAPI PFNGLTEXCOORD3FPROC glad_glTexCoord3f; #define glTexCoord3f glad_glTexCoord3f -typedef void (APIENTRYP PFNGLTEXCOORD3FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLTEXCOORD3FVPROC)(const GLfloat *v); GLAPI PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv; #define glTexCoord3fv glad_glTexCoord3fv -typedef void (APIENTRYP PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r); +typedef void(APIENTRYP PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r); GLAPI PFNGLTEXCOORD3IPROC glad_glTexCoord3i; #define glTexCoord3i glad_glTexCoord3i -typedef void (APIENTRYP PFNGLTEXCOORD3IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLTEXCOORD3IVPROC)(const GLint *v); GLAPI PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv; #define glTexCoord3iv glad_glTexCoord3iv -typedef void (APIENTRYP PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r); +typedef void(APIENTRYP PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r); GLAPI PFNGLTEXCOORD3SPROC glad_glTexCoord3s; #define glTexCoord3s glad_glTexCoord3s -typedef void (APIENTRYP PFNGLTEXCOORD3SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLTEXCOORD3SVPROC)(const GLshort *v); GLAPI PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv; #define glTexCoord3sv glad_glTexCoord3sv -typedef void (APIENTRYP PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void(APIENTRYP PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, + GLdouble q); GLAPI PFNGLTEXCOORD4DPROC glad_glTexCoord4d; #define glTexCoord4d glad_glTexCoord4d -typedef void (APIENTRYP PFNGLTEXCOORD4DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLTEXCOORD4DVPROC)(const GLdouble *v); GLAPI PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv; #define glTexCoord4dv glad_glTexCoord4dv -typedef void (APIENTRYP PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void(APIENTRYP PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, + GLfloat q); GLAPI PFNGLTEXCOORD4FPROC glad_glTexCoord4f; #define glTexCoord4f glad_glTexCoord4f -typedef void (APIENTRYP PFNGLTEXCOORD4FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLTEXCOORD4FVPROC)(const GLfloat *v); GLAPI PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv; #define glTexCoord4fv glad_glTexCoord4fv -typedef void (APIENTRYP PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q); +typedef void(APIENTRYP PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q); GLAPI PFNGLTEXCOORD4IPROC glad_glTexCoord4i; #define glTexCoord4i glad_glTexCoord4i -typedef void (APIENTRYP PFNGLTEXCOORD4IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLTEXCOORD4IVPROC)(const GLint *v); GLAPI PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv; #define glTexCoord4iv glad_glTexCoord4iv -typedef void (APIENTRYP PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, GLshort q); +typedef void(APIENTRYP PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, + GLshort q); GLAPI PFNGLTEXCOORD4SPROC glad_glTexCoord4s; #define glTexCoord4s glad_glTexCoord4s -typedef void (APIENTRYP PFNGLTEXCOORD4SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLTEXCOORD4SVPROC)(const GLshort *v); GLAPI PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv; #define glTexCoord4sv glad_glTexCoord4sv -typedef void (APIENTRYP PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y); +typedef void(APIENTRYP PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y); GLAPI PFNGLVERTEX2DPROC glad_glVertex2d; #define glVertex2d glad_glVertex2d -typedef void (APIENTRYP PFNGLVERTEX2DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEX2DVPROC)(const GLdouble *v); GLAPI PFNGLVERTEX2DVPROC glad_glVertex2dv; #define glVertex2dv glad_glVertex2dv -typedef void (APIENTRYP PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y); +typedef void(APIENTRYP PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y); GLAPI PFNGLVERTEX2FPROC glad_glVertex2f; #define glVertex2f glad_glVertex2f -typedef void (APIENTRYP PFNGLVERTEX2FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLVERTEX2FVPROC)(const GLfloat *v); GLAPI PFNGLVERTEX2FVPROC glad_glVertex2fv; #define glVertex2fv glad_glVertex2fv -typedef void (APIENTRYP PFNGLVERTEX2IPROC)(GLint x, GLint y); +typedef void(APIENTRYP PFNGLVERTEX2IPROC)(GLint x, GLint y); GLAPI PFNGLVERTEX2IPROC glad_glVertex2i; #define glVertex2i glad_glVertex2i -typedef void (APIENTRYP PFNGLVERTEX2IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLVERTEX2IVPROC)(const GLint *v); GLAPI PFNGLVERTEX2IVPROC glad_glVertex2iv; #define glVertex2iv glad_glVertex2iv -typedef void (APIENTRYP PFNGLVERTEX2SPROC)(GLshort x, GLshort y); +typedef void(APIENTRYP PFNGLVERTEX2SPROC)(GLshort x, GLshort y); GLAPI PFNGLVERTEX2SPROC glad_glVertex2s; #define glVertex2s glad_glVertex2s -typedef void (APIENTRYP PFNGLVERTEX2SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEX2SVPROC)(const GLshort *v); GLAPI PFNGLVERTEX2SVPROC glad_glVertex2sv; #define glVertex2sv glad_glVertex2sv -typedef void (APIENTRYP PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z); GLAPI PFNGLVERTEX3DPROC glad_glVertex3d; #define glVertex3d glad_glVertex3d -typedef void (APIENTRYP PFNGLVERTEX3DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEX3DVPROC)(const GLdouble *v); GLAPI PFNGLVERTEX3DVPROC glad_glVertex3dv; #define glVertex3dv glad_glVertex3dv -typedef void (APIENTRYP PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(APIENTRYP PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z); GLAPI PFNGLVERTEX3FPROC glad_glVertex3f; #define glVertex3f glad_glVertex3f -typedef void (APIENTRYP PFNGLVERTEX3FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLVERTEX3FVPROC)(const GLfloat *v); GLAPI PFNGLVERTEX3FVPROC glad_glVertex3fv; #define glVertex3fv glad_glVertex3fv -typedef void (APIENTRYP PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z); +typedef void(APIENTRYP PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z); GLAPI PFNGLVERTEX3IPROC glad_glVertex3i; #define glVertex3i glad_glVertex3i -typedef void (APIENTRYP PFNGLVERTEX3IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLVERTEX3IVPROC)(const GLint *v); GLAPI PFNGLVERTEX3IVPROC glad_glVertex3iv; #define glVertex3iv glad_glVertex3iv -typedef void (APIENTRYP PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void(APIENTRYP PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z); GLAPI PFNGLVERTEX3SPROC glad_glVertex3s; #define glVertex3s glad_glVertex3s -typedef void (APIENTRYP PFNGLVERTEX3SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEX3SVPROC)(const GLshort *v); GLAPI PFNGLVERTEX3SVPROC glad_glVertex3sv; #define glVertex3sv glad_glVertex3sv -typedef void (APIENTRYP PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(APIENTRYP PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, + GLdouble w); GLAPI PFNGLVERTEX4DPROC glad_glVertex4d; #define glVertex4d glad_glVertex4d -typedef void (APIENTRYP PFNGLVERTEX4DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEX4DVPROC)(const GLdouble *v); GLAPI PFNGLVERTEX4DVPROC glad_glVertex4dv; #define glVertex4dv glad_glVertex4dv -typedef void (APIENTRYP PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void(APIENTRYP PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, + GLfloat w); GLAPI PFNGLVERTEX4FPROC glad_glVertex4f; #define glVertex4f glad_glVertex4f -typedef void (APIENTRYP PFNGLVERTEX4FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLVERTEX4FVPROC)(const GLfloat *v); GLAPI PFNGLVERTEX4FVPROC glad_glVertex4fv; #define glVertex4fv glad_glVertex4fv -typedef void (APIENTRYP PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w); +typedef void(APIENTRYP PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w); GLAPI PFNGLVERTEX4IPROC glad_glVertex4i; #define glVertex4i glad_glVertex4i -typedef void (APIENTRYP PFNGLVERTEX4IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLVERTEX4IVPROC)(const GLint *v); GLAPI PFNGLVERTEX4IVPROC glad_glVertex4iv; #define glVertex4iv glad_glVertex4iv -typedef void (APIENTRYP PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void(APIENTRYP PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, + GLshort w); GLAPI PFNGLVERTEX4SPROC glad_glVertex4s; #define glVertex4s glad_glVertex4s -typedef void (APIENTRYP PFNGLVERTEX4SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEX4SVPROC)(const GLshort *v); GLAPI PFNGLVERTEX4SVPROC glad_glVertex4sv; #define glVertex4sv glad_glVertex4sv -typedef void (APIENTRYP PFNGLCLIPPLANEPROC)(GLenum plane, const GLdouble *equation); +typedef void(APIENTRYP PFNGLCLIPPLANEPROC)(GLenum plane, + const GLdouble *equation); GLAPI PFNGLCLIPPLANEPROC glad_glClipPlane; #define glClipPlane glad_glClipPlane -typedef void (APIENTRYP PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode); +typedef void(APIENTRYP PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode); GLAPI PFNGLCOLORMATERIALPROC glad_glColorMaterial; #define glColorMaterial glad_glColorMaterial -typedef void (APIENTRYP PFNGLFOGFPROC)(GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLFOGFPROC)(GLenum pname, GLfloat param); GLAPI PFNGLFOGFPROC glad_glFogf; #define glFogf glad_glFogf -typedef void (APIENTRYP PFNGLFOGFVPROC)(GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLFOGFVPROC)(GLenum pname, const GLfloat *params); GLAPI PFNGLFOGFVPROC glad_glFogfv; #define glFogfv glad_glFogfv -typedef void (APIENTRYP PFNGLFOGIPROC)(GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLFOGIPROC)(GLenum pname, GLint param); GLAPI PFNGLFOGIPROC glad_glFogi; #define glFogi glad_glFogi -typedef void (APIENTRYP PFNGLFOGIVPROC)(GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLFOGIVPROC)(GLenum pname, const GLint *params); GLAPI PFNGLFOGIVPROC glad_glFogiv; #define glFogiv glad_glFogiv -typedef void (APIENTRYP PFNGLLIGHTFPROC)(GLenum light, GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLLIGHTFPROC)(GLenum light, GLenum pname, + GLfloat param); GLAPI PFNGLLIGHTFPROC glad_glLightf; #define glLightf glad_glLightf -typedef void (APIENTRYP PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, + const GLfloat *params); GLAPI PFNGLLIGHTFVPROC glad_glLightfv; #define glLightfv glad_glLightfv -typedef void (APIENTRYP PFNGLLIGHTIPROC)(GLenum light, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLLIGHTIPROC)(GLenum light, GLenum pname, + GLint param); GLAPI PFNGLLIGHTIPROC glad_glLighti; #define glLighti glad_glLighti -typedef void (APIENTRYP PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, + const GLint *params); GLAPI PFNGLLIGHTIVPROC glad_glLightiv; #define glLightiv glad_glLightiv -typedef void (APIENTRYP PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param); GLAPI PFNGLLIGHTMODELFPROC glad_glLightModelf; #define glLightModelf glad_glLightModelf -typedef void (APIENTRYP PFNGLLIGHTMODELFVPROC)(GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLLIGHTMODELFVPROC)(GLenum pname, + const GLfloat *params); GLAPI PFNGLLIGHTMODELFVPROC glad_glLightModelfv; #define glLightModelfv glad_glLightModelfv -typedef void (APIENTRYP PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param); GLAPI PFNGLLIGHTMODELIPROC glad_glLightModeli; #define glLightModeli glad_glLightModeli -typedef void (APIENTRYP PFNGLLIGHTMODELIVPROC)(GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLLIGHTMODELIVPROC)(GLenum pname, + const GLint *params); GLAPI PFNGLLIGHTMODELIVPROC glad_glLightModeliv; #define glLightModeliv glad_glLightModeliv -typedef void (APIENTRYP PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern); +typedef void(APIENTRYP PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern); GLAPI PFNGLLINESTIPPLEPROC glad_glLineStipple; #define glLineStipple glad_glLineStipple -typedef void (APIENTRYP PFNGLMATERIALFPROC)(GLenum face, GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLMATERIALFPROC)(GLenum face, GLenum pname, + GLfloat param); GLAPI PFNGLMATERIALFPROC glad_glMaterialf; #define glMaterialf glad_glMaterialf -typedef void (APIENTRYP PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, + const GLfloat *params); GLAPI PFNGLMATERIALFVPROC glad_glMaterialfv; #define glMaterialfv glad_glMaterialfv -typedef void (APIENTRYP PFNGLMATERIALIPROC)(GLenum face, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLMATERIALIPROC)(GLenum face, GLenum pname, + GLint param); GLAPI PFNGLMATERIALIPROC glad_glMateriali; #define glMateriali glad_glMateriali -typedef void (APIENTRYP PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, + const GLint *params); GLAPI PFNGLMATERIALIVPROC glad_glMaterialiv; #define glMaterialiv glad_glMaterialiv -typedef void (APIENTRYP PFNGLPOLYGONSTIPPLEPROC)(const GLubyte *mask); +typedef void(APIENTRYP PFNGLPOLYGONSTIPPLEPROC)(const GLubyte *mask); GLAPI PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple; #define glPolygonStipple glad_glPolygonStipple -typedef void (APIENTRYP PFNGLSHADEMODELPROC)(GLenum mode); +typedef void(APIENTRYP PFNGLSHADEMODELPROC)(GLenum mode); GLAPI PFNGLSHADEMODELPROC glad_glShadeModel; #define glShadeModel glad_glShadeModel -typedef void (APIENTRYP PFNGLTEXENVFPROC)(GLenum target, GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLTEXENVFPROC)(GLenum target, GLenum pname, + GLfloat param); GLAPI PFNGLTEXENVFPROC glad_glTexEnvf; #define glTexEnvf glad_glTexEnvf -typedef void (APIENTRYP PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, + const GLfloat *params); GLAPI PFNGLTEXENVFVPROC glad_glTexEnvfv; #define glTexEnvfv glad_glTexEnvfv -typedef void (APIENTRYP PFNGLTEXENVIPROC)(GLenum target, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLTEXENVIPROC)(GLenum target, GLenum pname, + GLint param); GLAPI PFNGLTEXENVIPROC glad_glTexEnvi; #define glTexEnvi glad_glTexEnvi -typedef void (APIENTRYP PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, + const GLint *params); GLAPI PFNGLTEXENVIVPROC glad_glTexEnviv; #define glTexEnviv glad_glTexEnviv -typedef void (APIENTRYP PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, GLdouble param); +typedef void(APIENTRYP PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, + GLdouble param); GLAPI PFNGLTEXGENDPROC glad_glTexGend; #define glTexGend glad_glTexGend -typedef void (APIENTRYP PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, const GLdouble *params); +typedef void(APIENTRYP PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, + const GLdouble *params); GLAPI PFNGLTEXGENDVPROC glad_glTexGendv; #define glTexGendv glad_glTexGendv -typedef void (APIENTRYP PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, + GLfloat param); GLAPI PFNGLTEXGENFPROC glad_glTexGenf; #define glTexGenf glad_glTexGenf -typedef void (APIENTRYP PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, + const GLfloat *params); GLAPI PFNGLTEXGENFVPROC glad_glTexGenfv; #define glTexGenfv glad_glTexGenfv -typedef void (APIENTRYP PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, + GLint param); GLAPI PFNGLTEXGENIPROC glad_glTexGeni; #define glTexGeni glad_glTexGeni -typedef void (APIENTRYP PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, + const GLint *params); GLAPI PFNGLTEXGENIVPROC glad_glTexGeniv; #define glTexGeniv glad_glTexGeniv -typedef void (APIENTRYP PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, GLfloat *buffer); +typedef void(APIENTRYP PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, + GLfloat *buffer); GLAPI PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer; #define glFeedbackBuffer glad_glFeedbackBuffer -typedef void (APIENTRYP PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint *buffer); +typedef void(APIENTRYP PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint *buffer); GLAPI PFNGLSELECTBUFFERPROC glad_glSelectBuffer; #define glSelectBuffer glad_glSelectBuffer -typedef GLint (APIENTRYP PFNGLRENDERMODEPROC)(GLenum mode); +typedef GLint(APIENTRYP PFNGLRENDERMODEPROC)(GLenum mode); GLAPI PFNGLRENDERMODEPROC glad_glRenderMode; #define glRenderMode glad_glRenderMode -typedef void (APIENTRYP PFNGLINITNAMESPROC)(void); +typedef void(APIENTRYP PFNGLINITNAMESPROC)(void); GLAPI PFNGLINITNAMESPROC glad_glInitNames; #define glInitNames glad_glInitNames -typedef void (APIENTRYP PFNGLLOADNAMEPROC)(GLuint name); +typedef void(APIENTRYP PFNGLLOADNAMEPROC)(GLuint name); GLAPI PFNGLLOADNAMEPROC glad_glLoadName; #define glLoadName glad_glLoadName -typedef void (APIENTRYP PFNGLPASSTHROUGHPROC)(GLfloat token); +typedef void(APIENTRYP PFNGLPASSTHROUGHPROC)(GLfloat token); GLAPI PFNGLPASSTHROUGHPROC glad_glPassThrough; #define glPassThrough glad_glPassThrough -typedef void (APIENTRYP PFNGLPOPNAMEPROC)(void); +typedef void(APIENTRYP PFNGLPOPNAMEPROC)(void); GLAPI PFNGLPOPNAMEPROC glad_glPopName; #define glPopName glad_glPopName -typedef void (APIENTRYP PFNGLPUSHNAMEPROC)(GLuint name); +typedef void(APIENTRYP PFNGLPUSHNAMEPROC)(GLuint name); GLAPI PFNGLPUSHNAMEPROC glad_glPushName; #define glPushName glad_glPushName -typedef void (APIENTRYP PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(APIENTRYP PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha); GLAPI PFNGLCLEARACCUMPROC glad_glClearAccum; #define glClearAccum glad_glClearAccum -typedef void (APIENTRYP PFNGLCLEARINDEXPROC)(GLfloat c); +typedef void(APIENTRYP PFNGLCLEARINDEXPROC)(GLfloat c); GLAPI PFNGLCLEARINDEXPROC glad_glClearIndex; #define glClearIndex glad_glClearIndex -typedef void (APIENTRYP PFNGLINDEXMASKPROC)(GLuint mask); +typedef void(APIENTRYP PFNGLINDEXMASKPROC)(GLuint mask); GLAPI PFNGLINDEXMASKPROC glad_glIndexMask; #define glIndexMask glad_glIndexMask -typedef void (APIENTRYP PFNGLACCUMPROC)(GLenum op, GLfloat value); +typedef void(APIENTRYP PFNGLACCUMPROC)(GLenum op, GLfloat value); GLAPI PFNGLACCUMPROC glad_glAccum; #define glAccum glad_glAccum -typedef void (APIENTRYP PFNGLPOPATTRIBPROC)(void); +typedef void(APIENTRYP PFNGLPOPATTRIBPROC)(void); GLAPI PFNGLPOPATTRIBPROC glad_glPopAttrib; #define glPopAttrib glad_glPopAttrib -typedef void (APIENTRYP PFNGLPUSHATTRIBPROC)(GLbitfield mask); +typedef void(APIENTRYP PFNGLPUSHATTRIBPROC)(GLbitfield mask); GLAPI PFNGLPUSHATTRIBPROC glad_glPushAttrib; #define glPushAttrib glad_glPushAttrib -typedef void (APIENTRYP PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void(APIENTRYP PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, + GLint stride, GLint order, + const GLdouble *points); GLAPI PFNGLMAP1DPROC glad_glMap1d; #define glMap1d glad_glMap1d -typedef void (APIENTRYP PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void(APIENTRYP PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, + GLint stride, GLint order, + const GLfloat *points); GLAPI PFNGLMAP1FPROC glad_glMap1f; #define glMap1f glad_glMap1f -typedef void (APIENTRYP PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void(APIENTRYP PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, + GLint ustride, GLint uorder, GLdouble v1, + GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points); GLAPI PFNGLMAP2DPROC glad_glMap2d; #define glMap2d glad_glMap2d -typedef void (APIENTRYP PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +typedef void(APIENTRYP PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, + GLint ustride, GLint uorder, GLfloat v1, + GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points); GLAPI PFNGLMAP2FPROC glad_glMap2f; #define glMap2f glad_glMap2f -typedef void (APIENTRYP PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2); +typedef void(APIENTRYP PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2); GLAPI PFNGLMAPGRID1DPROC glad_glMapGrid1d; #define glMapGrid1d glad_glMapGrid1d -typedef void (APIENTRYP PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2); +typedef void(APIENTRYP PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2); GLAPI PFNGLMAPGRID1FPROC glad_glMapGrid1f; #define glMapGrid1f glad_glMapGrid1f -typedef void (APIENTRYP PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +typedef void(APIENTRYP PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2); GLAPI PFNGLMAPGRID2DPROC glad_glMapGrid2d; #define glMapGrid2d glad_glMapGrid2d -typedef void (APIENTRYP PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +typedef void(APIENTRYP PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2); GLAPI PFNGLMAPGRID2FPROC glad_glMapGrid2f; #define glMapGrid2f glad_glMapGrid2f -typedef void (APIENTRYP PFNGLEVALCOORD1DPROC)(GLdouble u); +typedef void(APIENTRYP PFNGLEVALCOORD1DPROC)(GLdouble u); GLAPI PFNGLEVALCOORD1DPROC glad_glEvalCoord1d; #define glEvalCoord1d glad_glEvalCoord1d -typedef void (APIENTRYP PFNGLEVALCOORD1DVPROC)(const GLdouble *u); +typedef void(APIENTRYP PFNGLEVALCOORD1DVPROC)(const GLdouble *u); GLAPI PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv; #define glEvalCoord1dv glad_glEvalCoord1dv -typedef void (APIENTRYP PFNGLEVALCOORD1FPROC)(GLfloat u); +typedef void(APIENTRYP PFNGLEVALCOORD1FPROC)(GLfloat u); GLAPI PFNGLEVALCOORD1FPROC glad_glEvalCoord1f; #define glEvalCoord1f glad_glEvalCoord1f -typedef void (APIENTRYP PFNGLEVALCOORD1FVPROC)(const GLfloat *u); +typedef void(APIENTRYP PFNGLEVALCOORD1FVPROC)(const GLfloat *u); GLAPI PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv; #define glEvalCoord1fv glad_glEvalCoord1fv -typedef void (APIENTRYP PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v); +typedef void(APIENTRYP PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v); GLAPI PFNGLEVALCOORD2DPROC glad_glEvalCoord2d; #define glEvalCoord2d glad_glEvalCoord2d -typedef void (APIENTRYP PFNGLEVALCOORD2DVPROC)(const GLdouble *u); +typedef void(APIENTRYP PFNGLEVALCOORD2DVPROC)(const GLdouble *u); GLAPI PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv; #define glEvalCoord2dv glad_glEvalCoord2dv -typedef void (APIENTRYP PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v); +typedef void(APIENTRYP PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v); GLAPI PFNGLEVALCOORD2FPROC glad_glEvalCoord2f; #define glEvalCoord2f glad_glEvalCoord2f -typedef void (APIENTRYP PFNGLEVALCOORD2FVPROC)(const GLfloat *u); +typedef void(APIENTRYP PFNGLEVALCOORD2FVPROC)(const GLfloat *u); GLAPI PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv; #define glEvalCoord2fv glad_glEvalCoord2fv -typedef void (APIENTRYP PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2); +typedef void(APIENTRYP PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2); GLAPI PFNGLEVALMESH1PROC glad_glEvalMesh1; #define glEvalMesh1 glad_glEvalMesh1 -typedef void (APIENTRYP PFNGLEVALPOINT1PROC)(GLint i); +typedef void(APIENTRYP PFNGLEVALPOINT1PROC)(GLint i); GLAPI PFNGLEVALPOINT1PROC glad_glEvalPoint1; #define glEvalPoint1 glad_glEvalPoint1 -typedef void (APIENTRYP PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +typedef void(APIENTRYP PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, + GLint j1, GLint j2); GLAPI PFNGLEVALMESH2PROC glad_glEvalMesh2; #define glEvalMesh2 glad_glEvalMesh2 -typedef void (APIENTRYP PFNGLEVALPOINT2PROC)(GLint i, GLint j); +typedef void(APIENTRYP PFNGLEVALPOINT2PROC)(GLint i, GLint j); GLAPI PFNGLEVALPOINT2PROC glad_glEvalPoint2; #define glEvalPoint2 glad_glEvalPoint2 -typedef void (APIENTRYP PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref); +typedef void(APIENTRYP PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref); GLAPI PFNGLALPHAFUNCPROC glad_glAlphaFunc; #define glAlphaFunc glad_glAlphaFunc -typedef void (APIENTRYP PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor); +typedef void(APIENTRYP PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor); GLAPI PFNGLPIXELZOOMPROC glad_glPixelZoom; #define glPixelZoom glad_glPixelZoom -typedef void (APIENTRYP PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param); GLAPI PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf; #define glPixelTransferf glad_glPixelTransferf -typedef void (APIENTRYP PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param); GLAPI PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi; #define glPixelTransferi glad_glPixelTransferi -typedef void (APIENTRYP PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, const GLfloat *values); +typedef void(APIENTRYP PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, + const GLfloat *values); GLAPI PFNGLPIXELMAPFVPROC glad_glPixelMapfv; #define glPixelMapfv glad_glPixelMapfv -typedef void (APIENTRYP PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, const GLuint *values); +typedef void(APIENTRYP PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, + const GLuint *values); GLAPI PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv; #define glPixelMapuiv glad_glPixelMapuiv -typedef void (APIENTRYP PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, const GLushort *values); +typedef void(APIENTRYP PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, + const GLushort *values); GLAPI PFNGLPIXELMAPUSVPROC glad_glPixelMapusv; #define glPixelMapusv glad_glPixelMapusv -typedef void (APIENTRYP PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +typedef void(APIENTRYP PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, + GLsizei height, GLenum type); GLAPI PFNGLCOPYPIXELSPROC glad_glCopyPixels; #define glCopyPixels glad_glCopyPixels -typedef void (APIENTRYP PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, + GLenum format, GLenum type, + const void *pixels); GLAPI PFNGLDRAWPIXELSPROC glad_glDrawPixels; #define glDrawPixels glad_glDrawPixels -typedef void (APIENTRYP PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble *equation); +typedef void(APIENTRYP PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble *equation); GLAPI PFNGLGETCLIPPLANEPROC glad_glGetClipPlane; #define glGetClipPlane glad_glGetClipPlane -typedef void (APIENTRYP PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, + GLfloat *params); GLAPI PFNGLGETLIGHTFVPROC glad_glGetLightfv; #define glGetLightfv glad_glGetLightfv -typedef void (APIENTRYP PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, + GLint *params); GLAPI PFNGLGETLIGHTIVPROC glad_glGetLightiv; #define glGetLightiv glad_glGetLightiv -typedef void (APIENTRYP PFNGLGETMAPDVPROC)(GLenum target, GLenum query, GLdouble *v); +typedef void(APIENTRYP PFNGLGETMAPDVPROC)(GLenum target, GLenum query, + GLdouble *v); GLAPI PFNGLGETMAPDVPROC glad_glGetMapdv; #define glGetMapdv glad_glGetMapdv -typedef void (APIENTRYP PFNGLGETMAPFVPROC)(GLenum target, GLenum query, GLfloat *v); +typedef void(APIENTRYP PFNGLGETMAPFVPROC)(GLenum target, GLenum query, + GLfloat *v); GLAPI PFNGLGETMAPFVPROC glad_glGetMapfv; #define glGetMapfv glad_glGetMapfv -typedef void (APIENTRYP PFNGLGETMAPIVPROC)(GLenum target, GLenum query, GLint *v); +typedef void(APIENTRYP PFNGLGETMAPIVPROC)(GLenum target, GLenum query, + GLint *v); GLAPI PFNGLGETMAPIVPROC glad_glGetMapiv; #define glGetMapiv glad_glGetMapiv -typedef void (APIENTRYP PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, + GLfloat *params); GLAPI PFNGLGETMATERIALFVPROC glad_glGetMaterialfv; #define glGetMaterialfv glad_glGetMaterialfv -typedef void (APIENTRYP PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, + GLint *params); GLAPI PFNGLGETMATERIALIVPROC glad_glGetMaterialiv; #define glGetMaterialiv glad_glGetMaterialiv -typedef void (APIENTRYP PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat *values); +typedef void(APIENTRYP PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat *values); GLAPI PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv; #define glGetPixelMapfv glad_glGetPixelMapfv -typedef void (APIENTRYP PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint *values); +typedef void(APIENTRYP PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint *values); GLAPI PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv; #define glGetPixelMapuiv glad_glGetPixelMapuiv -typedef void (APIENTRYP PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort *values); +typedef void(APIENTRYP PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort *values); GLAPI PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv; #define glGetPixelMapusv glad_glGetPixelMapusv -typedef void (APIENTRYP PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte *mask); +typedef void(APIENTRYP PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte *mask); GLAPI PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple; #define glGetPolygonStipple glad_glGetPolygonStipple -typedef void (APIENTRYP PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, + GLfloat *params); GLAPI PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv; #define glGetTexEnvfv glad_glGetTexEnvfv -typedef void (APIENTRYP PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, + GLint *params); GLAPI PFNGLGETTEXENVIVPROC glad_glGetTexEnviv; #define glGetTexEnviv glad_glGetTexEnviv -typedef void (APIENTRYP PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, GLdouble *params); +typedef void(APIENTRYP PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, + GLdouble *params); GLAPI PFNGLGETTEXGENDVPROC glad_glGetTexGendv; #define glGetTexGendv glad_glGetTexGendv -typedef void (APIENTRYP PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, + GLfloat *params); GLAPI PFNGLGETTEXGENFVPROC glad_glGetTexGenfv; #define glGetTexGenfv glad_glGetTexGenfv -typedef void (APIENTRYP PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, + GLint *params); GLAPI PFNGLGETTEXGENIVPROC glad_glGetTexGeniv; #define glGetTexGeniv glad_glGetTexGeniv -typedef GLboolean (APIENTRYP PFNGLISLISTPROC)(GLuint list); +typedef GLboolean(APIENTRYP PFNGLISLISTPROC)(GLuint list); GLAPI PFNGLISLISTPROC glad_glIsList; #define glIsList glad_glIsList -typedef void (APIENTRYP PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void(APIENTRYP PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble zNear, GLdouble zFar); GLAPI PFNGLFRUSTUMPROC glad_glFrustum; #define glFrustum glad_glFrustum -typedef void (APIENTRYP PFNGLLOADIDENTITYPROC)(void); +typedef void(APIENTRYP PFNGLLOADIDENTITYPROC)(void); GLAPI PFNGLLOADIDENTITYPROC glad_glLoadIdentity; #define glLoadIdentity glad_glLoadIdentity -typedef void (APIENTRYP PFNGLLOADMATRIXFPROC)(const GLfloat *m); +typedef void(APIENTRYP PFNGLLOADMATRIXFPROC)(const GLfloat *m); GLAPI PFNGLLOADMATRIXFPROC glad_glLoadMatrixf; #define glLoadMatrixf glad_glLoadMatrixf -typedef void (APIENTRYP PFNGLLOADMATRIXDPROC)(const GLdouble *m); +typedef void(APIENTRYP PFNGLLOADMATRIXDPROC)(const GLdouble *m); GLAPI PFNGLLOADMATRIXDPROC glad_glLoadMatrixd; #define glLoadMatrixd glad_glLoadMatrixd -typedef void (APIENTRYP PFNGLMATRIXMODEPROC)(GLenum mode); +typedef void(APIENTRYP PFNGLMATRIXMODEPROC)(GLenum mode); GLAPI PFNGLMATRIXMODEPROC glad_glMatrixMode; #define glMatrixMode glad_glMatrixMode -typedef void (APIENTRYP PFNGLMULTMATRIXFPROC)(const GLfloat *m); +typedef void(APIENTRYP PFNGLMULTMATRIXFPROC)(const GLfloat *m); GLAPI PFNGLMULTMATRIXFPROC glad_glMultMatrixf; #define glMultMatrixf glad_glMultMatrixf -typedef void (APIENTRYP PFNGLMULTMATRIXDPROC)(const GLdouble *m); +typedef void(APIENTRYP PFNGLMULTMATRIXDPROC)(const GLdouble *m); GLAPI PFNGLMULTMATRIXDPROC glad_glMultMatrixd; #define glMultMatrixd glad_glMultMatrixd -typedef void (APIENTRYP PFNGLORTHOPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void(APIENTRYP PFNGLORTHOPROC)(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble zNear, GLdouble zFar); GLAPI PFNGLORTHOPROC glad_glOrtho; #define glOrtho glad_glOrtho -typedef void (APIENTRYP PFNGLPOPMATRIXPROC)(void); +typedef void(APIENTRYP PFNGLPOPMATRIXPROC)(void); GLAPI PFNGLPOPMATRIXPROC glad_glPopMatrix; #define glPopMatrix glad_glPopMatrix -typedef void (APIENTRYP PFNGLPUSHMATRIXPROC)(void); +typedef void(APIENTRYP PFNGLPUSHMATRIXPROC)(void); GLAPI PFNGLPUSHMATRIXPROC glad_glPushMatrix; #define glPushMatrix glad_glPushMatrix -typedef void (APIENTRYP PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, + GLdouble z); GLAPI PFNGLROTATEDPROC glad_glRotated; #define glRotated glad_glRotated -typedef void (APIENTRYP PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void(APIENTRYP PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, + GLfloat z); GLAPI PFNGLROTATEFPROC glad_glRotatef; #define glRotatef glad_glRotatef -typedef void (APIENTRYP PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z); GLAPI PFNGLSCALEDPROC glad_glScaled; #define glScaled glad_glScaled -typedef void (APIENTRYP PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(APIENTRYP PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z); GLAPI PFNGLSCALEFPROC glad_glScalef; #define glScalef glad_glScalef -typedef void (APIENTRYP PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z); GLAPI PFNGLTRANSLATEDPROC glad_glTranslated; #define glTranslated glad_glTranslated -typedef void (APIENTRYP PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(APIENTRYP PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z); GLAPI PFNGLTRANSLATEFPROC glad_glTranslatef; #define glTranslatef glad_glTranslatef #endif #ifndef GL_VERSION_1_1 #define GL_VERSION_1_1 1 GLAPI int GLAD_GL_VERSION_1_1; -typedef void (APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count); +typedef void(APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, + GLsizei count); GLAPI PFNGLDRAWARRAYSPROC glad_glDrawArrays; #define glDrawArrays glad_glDrawArrays -typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void(APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, + GLenum type, const void *indices); GLAPI PFNGLDRAWELEMENTSPROC glad_glDrawElements; #define glDrawElements glad_glDrawElements -typedef void (APIENTRYP PFNGLGETPOINTERVPROC)(GLenum pname, void **params); +typedef void(APIENTRYP PFNGLGETPOINTERVPROC)(GLenum pname, void **params); GLAPI PFNGLGETPOINTERVPROC glad_glGetPointerv; #define glGetPointerv glad_glGetPointerv -typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); +typedef void(APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); GLAPI PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset; #define glPolygonOffset glad_glPolygonOffset -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void(APIENTRYP PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, + GLenum internalformat, GLint x, + GLint y, GLsizei width, + GLint border); GLAPI PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D; #define glCopyTexImage1D glad_glCopyTexImage1D -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void(APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, + GLenum internalformat, GLint x, + GLint y, GLsizei width, + GLsizei height, GLint border); GLAPI PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D; #define glCopyTexImage2D glad_glCopyTexImage2D -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void(APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, + GLint xoffset, GLint x, + GLint y, GLsizei width); GLAPI PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D; #define glCopyTexSubImage1D glad_glCopyTexSubImage1D -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, + GLsizei height); GLAPI PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D; #define glCopyTexSubImage2D glad_glCopyTexSubImage2D -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const void *pixels); GLAPI PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D; #define glTexSubImage1D glad_glTexSubImage1D -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const void *pixels); GLAPI PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D; #define glTexSubImage2D glad_glTexSubImage2D -typedef void (APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); +typedef void(APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); GLAPI PFNGLBINDTEXTUREPROC glad_glBindTexture; #define glBindTexture glad_glBindTexture -typedef void (APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint *textures); +typedef void(APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, + const GLuint *textures); GLAPI PFNGLDELETETEXTURESPROC glad_glDeleteTextures; #define glDeleteTextures glad_glDeleteTextures -typedef void (APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint *textures); +typedef void(APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint *textures); GLAPI PFNGLGENTEXTURESPROC glad_glGenTextures; #define glGenTextures glad_glGenTextures -typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture); +typedef GLboolean(APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture); GLAPI PFNGLISTEXTUREPROC glad_glIsTexture; #define glIsTexture glad_glIsTexture -typedef void (APIENTRYP PFNGLARRAYELEMENTPROC)(GLint i); +typedef void(APIENTRYP PFNGLARRAYELEMENTPROC)(GLint i); GLAPI PFNGLARRAYELEMENTPROC glad_glArrayElement; #define glArrayElement glad_glArrayElement -typedef void (APIENTRYP PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, + GLsizei stride, + const void *pointer); GLAPI PFNGLCOLORPOINTERPROC glad_glColorPointer; #define glColorPointer glad_glColorPointer -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEPROC)(GLenum array); +typedef void(APIENTRYP PFNGLDISABLECLIENTSTATEPROC)(GLenum array); GLAPI PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState; #define glDisableClientState glad_glDisableClientState -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, + const void *pointer); GLAPI PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer; #define glEdgeFlagPointer glad_glEdgeFlagPointer -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEPROC)(GLenum array); +typedef void(APIENTRYP PFNGLENABLECLIENTSTATEPROC)(GLenum array); GLAPI PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState; #define glEnableClientState glad_glEnableClientState -typedef void (APIENTRYP PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, + const void *pointer); GLAPI PFNGLINDEXPOINTERPROC glad_glIndexPointer; #define glIndexPointer glad_glIndexPointer -typedef void (APIENTRYP PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, + GLsizei stride, + const void *pointer); GLAPI PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays; #define glInterleavedArrays glad_glInterleavedArrays -typedef void (APIENTRYP PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, + const void *pointer); GLAPI PFNGLNORMALPOINTERPROC glad_glNormalPointer; #define glNormalPointer glad_glNormalPointer -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, + GLsizei stride, + const void *pointer); GLAPI PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer; #define glTexCoordPointer glad_glTexCoordPointer -typedef void (APIENTRYP PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, + GLsizei stride, + const void *pointer); GLAPI PFNGLVERTEXPOINTERPROC glad_glVertexPointer; #define glVertexPointer glad_glVertexPointer -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTPROC)(GLsizei n, const GLuint *textures, GLboolean *residences); +typedef GLboolean(APIENTRYP PFNGLARETEXTURESRESIDENTPROC)( + GLsizei n, const GLuint *textures, GLboolean *residences); GLAPI PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident; #define glAreTexturesResident glad_glAreTexturesResident -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, const GLuint *textures, const GLfloat *priorities); +typedef void(APIENTRYP PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, + const GLuint *textures, + const GLfloat *priorities); GLAPI PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures; #define glPrioritizeTextures glad_glPrioritizeTextures -typedef void (APIENTRYP PFNGLINDEXUBPROC)(GLubyte c); +typedef void(APIENTRYP PFNGLINDEXUBPROC)(GLubyte c); GLAPI PFNGLINDEXUBPROC glad_glIndexub; #define glIndexub glad_glIndexub -typedef void (APIENTRYP PFNGLINDEXUBVPROC)(const GLubyte *c); +typedef void(APIENTRYP PFNGLINDEXUBVPROC)(const GLubyte *c); GLAPI PFNGLINDEXUBVPROC glad_glIndexubv; #define glIndexubv glad_glIndexubv -typedef void (APIENTRYP PFNGLPOPCLIENTATTRIBPROC)(void); +typedef void(APIENTRYP PFNGLPOPCLIENTATTRIBPROC)(void); GLAPI PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib; #define glPopClientAttrib glad_glPopClientAttrib -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask); +typedef void(APIENTRYP PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask); GLAPI PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib; #define glPushClientAttrib glad_glPushClientAttrib #endif #ifndef GL_VERSION_1_2 #define GL_VERSION_1_2 1 GLAPI int GLAD_GL_VERSION_1_2; -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void(APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, + const void *indices); GLAPI PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements; #define glDrawRangeElements glad_glDrawRangeElements -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, + GLint internalformat, GLsizei width, + GLsizei height, GLsizei depth, + GLint border, GLenum format, + GLenum type, const void *pixels); GLAPI PFNGLTEXIMAGE3DPROC glad_glTexImage3D; #define glTexImage3D glad_glTexImage3D -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const void *pixels); GLAPI PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D; #define glTexSubImage3D glad_glTexSubImage3D -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height); GLAPI PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D; #define glCopyTexSubImage3D glad_glCopyTexSubImage3D #endif #ifndef GL_VERSION_1_3 #define GL_VERSION_1_3 1 GLAPI int GLAD_GL_VERSION_1_3; -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture); +typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture); GLAPI PFNGLACTIVETEXTUREPROC glad_glActiveTexture; #define glActiveTexture glad_glActiveTexture -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert); +typedef void(APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, + GLboolean invert); GLAPI PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage; #define glSampleCoverage glad_glSampleCoverage -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, + const void *data); GLAPI PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D; #define glCompressedTexImage3D glad_glCompressedTexImage3D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D; #define glCompressedTexImage2D glad_glCompressedTexImage2D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC)( + GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLint border, GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D; #define glCompressedTexImage1D glad_glCompressedTexImage1D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D; #define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)( + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D; #define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)( + GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, + GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D; #define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void *img); +typedef void(APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, + GLint level, void *img); GLAPI PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage; #define glGetCompressedTexImage glad_glGetCompressedTexImage -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture); +typedef void(APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture); GLAPI PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture; #define glClientActiveTexture glad_glClientActiveTexture -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s); GLAPI PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d; #define glMultiTexCoord1d glad_glMultiTexCoord1d -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC)(GLenum target, const GLdouble *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1DVPROC)(GLenum target, + const GLdouble *v); GLAPI PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv; #define glMultiTexCoord1dv glad_glMultiTexCoord1dv -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s); GLAPI PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f; #define glMultiTexCoord1f glad_glMultiTexCoord1f -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC)(GLenum target, const GLfloat *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1FVPROC)(GLenum target, + const GLfloat *v); GLAPI PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv; #define glMultiTexCoord1fv glad_glMultiTexCoord1fv -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s); GLAPI PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i; #define glMultiTexCoord1i glad_glMultiTexCoord1i -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC)(GLenum target, const GLint *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1IVPROC)(GLenum target, + const GLint *v); GLAPI PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv; #define glMultiTexCoord1iv glad_glMultiTexCoord1iv -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s); GLAPI PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s; #define glMultiTexCoord1s glad_glMultiTexCoord1s -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC)(GLenum target, const GLshort *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD1SVPROC)(GLenum target, + const GLshort *v); GLAPI PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv; #define glMultiTexCoord1sv glad_glMultiTexCoord1sv -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, GLdouble t); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, + GLdouble t); GLAPI PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d; #define glMultiTexCoord2d glad_glMultiTexCoord2d -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC)(GLenum target, const GLdouble *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2DVPROC)(GLenum target, + const GLdouble *v); GLAPI PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv; #define glMultiTexCoord2dv glad_glMultiTexCoord2dv -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, + GLfloat t); GLAPI PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f; #define glMultiTexCoord2f glad_glMultiTexCoord2f -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC)(GLenum target, const GLfloat *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2FVPROC)(GLenum target, + const GLfloat *v); GLAPI PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv; #define glMultiTexCoord2fv glad_glMultiTexCoord2fv -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, GLint t); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, + GLint t); GLAPI PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i; #define glMultiTexCoord2i glad_glMultiTexCoord2i -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC)(GLenum target, const GLint *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2IVPROC)(GLenum target, + const GLint *v); GLAPI PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv; #define glMultiTexCoord2iv glad_glMultiTexCoord2iv -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, GLshort t); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, + GLshort t); GLAPI PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s; #define glMultiTexCoord2s glad_glMultiTexCoord2s -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC)(GLenum target, const GLshort *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD2SVPROC)(GLenum target, + const GLshort *v); GLAPI PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv; #define glMultiTexCoord2sv glad_glMultiTexCoord2sv -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, + GLdouble t, GLdouble r); GLAPI PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d; #define glMultiTexCoord3d glad_glMultiTexCoord3d -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC)(GLenum target, const GLdouble *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3DVPROC)(GLenum target, + const GLdouble *v); GLAPI PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv; #define glMultiTexCoord3dv glad_glMultiTexCoord3dv -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, + GLfloat t, GLfloat r); GLAPI PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f; #define glMultiTexCoord3f glad_glMultiTexCoord3f -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC)(GLenum target, const GLfloat *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3FVPROC)(GLenum target, + const GLfloat *v); GLAPI PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv; #define glMultiTexCoord3fv glad_glMultiTexCoord3fv -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, GLint t, GLint r); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, + GLint t, GLint r); GLAPI PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i; #define glMultiTexCoord3i glad_glMultiTexCoord3i -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC)(GLenum target, const GLint *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3IVPROC)(GLenum target, + const GLint *v); GLAPI PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv; #define glMultiTexCoord3iv glad_glMultiTexCoord3iv -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, GLshort t, GLshort r); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, + GLshort t, GLshort r); GLAPI PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s; #define glMultiTexCoord3s glad_glMultiTexCoord3s -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC)(GLenum target, const GLshort *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD3SVPROC)(GLenum target, + const GLshort *v); GLAPI PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv; #define glMultiTexCoord3sv glad_glMultiTexCoord3sv -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, + GLdouble t, GLdouble r, + GLdouble q); GLAPI PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d; #define glMultiTexCoord4d glad_glMultiTexCoord4d -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC)(GLenum target, const GLdouble *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4DVPROC)(GLenum target, + const GLdouble *v); GLAPI PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv; #define glMultiTexCoord4dv glad_glMultiTexCoord4dv -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, + GLfloat t, GLfloat r, + GLfloat q); GLAPI PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f; #define glMultiTexCoord4f glad_glMultiTexCoord4f -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC)(GLenum target, const GLfloat *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4FVPROC)(GLenum target, + const GLfloat *v); GLAPI PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv; #define glMultiTexCoord4fv glad_glMultiTexCoord4fv -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, + GLint t, GLint r, GLint q); GLAPI PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i; #define glMultiTexCoord4i glad_glMultiTexCoord4i -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC)(GLenum target, const GLint *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4IVPROC)(GLenum target, + const GLint *v); GLAPI PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv; #define glMultiTexCoord4iv glad_glMultiTexCoord4iv -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, + GLshort t, GLshort r, + GLshort q); GLAPI PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s; #define glMultiTexCoord4s glad_glMultiTexCoord4s -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC)(GLenum target, const GLshort *v); +typedef void(APIENTRYP PFNGLMULTITEXCOORD4SVPROC)(GLenum target, + const GLshort *v); GLAPI PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv; #define glMultiTexCoord4sv glad_glMultiTexCoord4sv -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat *m); +typedef void(APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat *m); GLAPI PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf; #define glLoadTransposeMatrixf glad_glLoadTransposeMatrixf -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble *m); +typedef void(APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble *m); GLAPI PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd; #define glLoadTransposeMatrixd glad_glLoadTransposeMatrixd -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat *m); +typedef void(APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat *m); GLAPI PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf; #define glMultTransposeMatrixf glad_glMultTransposeMatrixf -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble *m); +typedef void(APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble *m); GLAPI PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd; #define glMultTransposeMatrixd glad_glMultTransposeMatrixd #endif #ifndef GL_VERSION_1_4 #define GL_VERSION_1_4 1 GLAPI int GLAD_GL_VERSION_1_4; -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void(APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, + GLenum dfactorRGB, + GLenum sfactorAlpha, + GLenum dfactorAlpha); GLAPI PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate; #define glBlendFuncSeparate glad_glBlendFuncSeparate -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void(APIENTRYP PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, + const GLint *first, + const GLsizei *count, + GLsizei drawcount); GLAPI PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays; #define glMultiDrawArrays glad_glMultiDrawArrays -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void(APIENTRYP PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, + const GLsizei *count, + GLenum type, + const void *const *indices, + GLsizei drawcount); GLAPI PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements; #define glMultiDrawElements glad_glMultiDrawElements -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param); GLAPI PFNGLPOINTPARAMETERFPROC glad_glPointParameterf; #define glPointParameterf glad_glPointParameterf -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat *params); +typedef void(APIENTRYP PFNGLPOINTPARAMETERFVPROC)(GLenum pname, + const GLfloat *params); GLAPI PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv; #define glPointParameterfv glad_glPointParameterfv -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param); GLAPI PFNGLPOINTPARAMETERIPROC glad_glPointParameteri; #define glPointParameteri glad_glPointParameteri -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLPOINTPARAMETERIVPROC)(GLenum pname, + const GLint *params); GLAPI PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv; #define glPointParameteriv glad_glPointParameteriv -typedef void (APIENTRYP PFNGLFOGCOORDFPROC)(GLfloat coord); +typedef void(APIENTRYP PFNGLFOGCOORDFPROC)(GLfloat coord); GLAPI PFNGLFOGCOORDFPROC glad_glFogCoordf; #define glFogCoordf glad_glFogCoordf -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC)(const GLfloat *coord); +typedef void(APIENTRYP PFNGLFOGCOORDFVPROC)(const GLfloat *coord); GLAPI PFNGLFOGCOORDFVPROC glad_glFogCoordfv; #define glFogCoordfv glad_glFogCoordfv -typedef void (APIENTRYP PFNGLFOGCOORDDPROC)(GLdouble coord); +typedef void(APIENTRYP PFNGLFOGCOORDDPROC)(GLdouble coord); GLAPI PFNGLFOGCOORDDPROC glad_glFogCoordd; #define glFogCoordd glad_glFogCoordd -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC)(const GLdouble *coord); +typedef void(APIENTRYP PFNGLFOGCOORDDVPROC)(const GLdouble *coord); GLAPI PFNGLFOGCOORDDVPROC glad_glFogCoorddv; #define glFogCoorddv glad_glFogCoorddv -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, + const void *pointer); GLAPI PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer; #define glFogCoordPointer glad_glFogCoordPointer -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, + GLbyte blue); GLAPI PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b; #define glSecondaryColor3b glad_glSecondaryColor3b -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte *v); GLAPI PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv; #define glSecondaryColor3bv glad_glSecondaryColor3bv -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, + GLdouble blue); GLAPI PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d; #define glSecondaryColor3d glad_glSecondaryColor3d -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble *v); GLAPI PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv; #define glSecondaryColor3dv glad_glSecondaryColor3dv -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, + GLfloat blue); GLAPI PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f; #define glSecondaryColor3f glad_glSecondaryColor3f -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat *v); GLAPI PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv; #define glSecondaryColor3fv glad_glSecondaryColor3fv -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, GLint blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, + GLint blue); GLAPI PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i; #define glSecondaryColor3i glad_glSecondaryColor3i -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3IVPROC)(const GLint *v); GLAPI PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv; #define glSecondaryColor3iv glad_glSecondaryColor3iv -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, + GLshort blue); GLAPI PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s; #define glSecondaryColor3s glad_glSecondaryColor3s -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3SVPROC)(const GLshort *v); GLAPI PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv; #define glSecondaryColor3sv glad_glSecondaryColor3sv -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, + GLubyte blue); GLAPI PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub; #define glSecondaryColor3ub glad_glSecondaryColor3ub -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte *v); GLAPI PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv; #define glSecondaryColor3ubv glad_glSecondaryColor3ubv -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, + GLuint blue); GLAPI PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui; #define glSecondaryColor3ui glad_glSecondaryColor3ui -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint *v); GLAPI PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv; #define glSecondaryColor3uiv glad_glSecondaryColor3uiv -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, + GLushort blue); GLAPI PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us; #define glSecondaryColor3us glad_glSecondaryColor3us -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC)(const GLushort *v); +typedef void(APIENTRYP PFNGLSECONDARYCOLOR3USVPROC)(const GLushort *v); GLAPI PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv; #define glSecondaryColor3usv glad_glSecondaryColor3usv -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, + GLsizei stride, + const void *pointer); GLAPI PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer; #define glSecondaryColorPointer glad_glSecondaryColorPointer -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y); +typedef void(APIENTRYP PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y); GLAPI PFNGLWINDOWPOS2DPROC glad_glWindowPos2d; #define glWindowPos2d glad_glWindowPos2d -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLWINDOWPOS2DVPROC)(const GLdouble *v); GLAPI PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv; #define glWindowPos2dv glad_glWindowPos2dv -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y); +typedef void(APIENTRYP PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y); GLAPI PFNGLWINDOWPOS2FPROC glad_glWindowPos2f; #define glWindowPos2f glad_glWindowPos2f -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLWINDOWPOS2FVPROC)(const GLfloat *v); GLAPI PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv; #define glWindowPos2fv glad_glWindowPos2fv -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC)(GLint x, GLint y); +typedef void(APIENTRYP PFNGLWINDOWPOS2IPROC)(GLint x, GLint y); GLAPI PFNGLWINDOWPOS2IPROC glad_glWindowPos2i; #define glWindowPos2i glad_glWindowPos2i -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLWINDOWPOS2IVPROC)(const GLint *v); GLAPI PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv; #define glWindowPos2iv glad_glWindowPos2iv -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y); +typedef void(APIENTRYP PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y); GLAPI PFNGLWINDOWPOS2SPROC glad_glWindowPos2s; #define glWindowPos2s glad_glWindowPos2s -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLWINDOWPOS2SVPROC)(const GLshort *v); GLAPI PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv; #define glWindowPos2sv glad_glWindowPos2sv -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, + GLdouble z); GLAPI PFNGLWINDOWPOS3DPROC glad_glWindowPos3d; #define glWindowPos3d glad_glWindowPos3d -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC)(const GLdouble *v); +typedef void(APIENTRYP PFNGLWINDOWPOS3DVPROC)(const GLdouble *v); GLAPI PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv; #define glWindowPos3dv glad_glWindowPos3dv -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void(APIENTRYP PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); GLAPI PFNGLWINDOWPOS3FPROC glad_glWindowPos3f; #define glWindowPos3f glad_glWindowPos3f -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC)(const GLfloat *v); +typedef void(APIENTRYP PFNGLWINDOWPOS3FVPROC)(const GLfloat *v); GLAPI PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv; #define glWindowPos3fv glad_glWindowPos3fv -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z); +typedef void(APIENTRYP PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z); GLAPI PFNGLWINDOWPOS3IPROC glad_glWindowPos3i; #define glWindowPos3i glad_glWindowPos3i -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC)(const GLint *v); +typedef void(APIENTRYP PFNGLWINDOWPOS3IVPROC)(const GLint *v); GLAPI PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv; #define glWindowPos3iv glad_glWindowPos3iv -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void(APIENTRYP PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z); GLAPI PFNGLWINDOWPOS3SPROC glad_glWindowPos3s; #define glWindowPos3s glad_glWindowPos3s -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC)(const GLshort *v); +typedef void(APIENTRYP PFNGLWINDOWPOS3SVPROC)(const GLshort *v); GLAPI PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv; #define glWindowPos3sv glad_glWindowPos3sv -typedef void (APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha); GLAPI PFNGLBLENDCOLORPROC glad_glBlendColor; #define glBlendColor glad_glBlendColor -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode); +typedef void(APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode); GLAPI PFNGLBLENDEQUATIONPROC glad_glBlendEquation; #define glBlendEquation glad_glBlendEquation #endif #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 GLAPI int GLAD_GL_VERSION_1_5; -typedef void (APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint *ids); +typedef void(APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint *ids); GLAPI PFNGLGENQUERIESPROC glad_glGenQueries; #define glGenQueries glad_glGenQueries -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint *ids); +typedef void(APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint *ids); GLAPI PFNGLDELETEQUERIESPROC glad_glDeleteQueries; #define glDeleteQueries glad_glDeleteQueries -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC)(GLuint id); +typedef GLboolean(APIENTRYP PFNGLISQUERYPROC)(GLuint id); GLAPI PFNGLISQUERYPROC glad_glIsQuery; #define glIsQuery glad_glIsQuery -typedef void (APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); +typedef void(APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); GLAPI PFNGLBEGINQUERYPROC glad_glBeginQuery; #define glBeginQuery glad_glBeginQuery -typedef void (APIENTRYP PFNGLENDQUERYPROC)(GLenum target); +typedef void(APIENTRYP PFNGLENDQUERYPROC)(GLenum target); GLAPI PFNGLENDQUERYPROC glad_glEndQuery; #define glEndQuery glad_glEndQuery -typedef void (APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, + GLint *params); GLAPI PFNGLGETQUERYIVPROC glad_glGetQueryiv; #define glGetQueryiv glad_glGetQueryiv -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, + GLint *params); GLAPI PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv; #define glGetQueryObjectiv glad_glGetQueryObjectiv -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint *params); +typedef void(APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, + GLuint *params); GLAPI PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv; #define glGetQueryObjectuiv glad_glGetQueryObjectuiv -typedef void (APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); +typedef void(APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); GLAPI PFNGLBINDBUFFERPROC glad_glBindBuffer; #define glBindBuffer glad_glBindBuffer -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint *buffers); +typedef void(APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, + const GLuint *buffers); GLAPI PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers; #define glDeleteBuffers glad_glDeleteBuffers -typedef void (APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint *buffers); +typedef void(APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint *buffers); GLAPI PFNGLGENBUFFERSPROC glad_glGenBuffers; #define glGenBuffers glad_glGenBuffers -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer); +typedef GLboolean(APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer); GLAPI PFNGLISBUFFERPROC glad_glIsBuffer; #define glIsBuffer glad_glIsBuffer -typedef void (APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void(APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, + const void *data, GLenum usage); GLAPI PFNGLBUFFERDATAPROC glad_glBufferData; #define glBufferData glad_glBufferData -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void(APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, + GLsizeiptr size, + const void *data); GLAPI PFNGLBUFFERSUBDATAPROC glad_glBufferSubData; #define glBufferSubData glad_glBufferSubData -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void(APIENTRYP PFNGLGETBUFFERSUBDATAPROC)(GLenum target, + GLintptr offset, + GLsizeiptr size, void *data); GLAPI PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData; #define glGetBufferSubData glad_glGetBufferSubData -typedef void * (APIENTRYP PFNGLMAPBUFFERPROC)(GLenum target, GLenum access); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC)(GLenum target, GLenum access); GLAPI PFNGLMAPBUFFERPROC glad_glMapBuffer; #define glMapBuffer glad_glMapBuffer -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target); +typedef GLboolean(APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target); GLAPI PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer; #define glUnmapBuffer glad_glUnmapBuffer -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, + GLenum pname, + GLint *params); GLAPI PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv; #define glGetBufferParameteriv glad_glGetBufferParameteriv -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void **params); +typedef void(APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, + void **params); GLAPI PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv; #define glGetBufferPointerv glad_glGetBufferPointerv #endif #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 GLAPI int GLAD_GL_VERSION_2_0; -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); +typedef void(APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, + GLenum modeAlpha); GLAPI PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate; #define glBlendEquationSeparate glad_glBlendEquationSeparate -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs); +typedef void(APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs); GLAPI PFNGLDRAWBUFFERSPROC glad_glDrawBuffers; #define glDrawBuffers glad_glDrawBuffers -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void(APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, + GLenum dpfail, + GLenum dppass); GLAPI PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate; #define glStencilOpSeparate glad_glStencilOpSeparate -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void(APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, + GLint ref, GLuint mask); GLAPI PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate; #define glStencilFuncSeparate glad_glStencilFuncSeparate -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); +typedef void(APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); GLAPI PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate; #define glStencilMaskSeparate glad_glStencilMaskSeparate -typedef void (APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); +typedef void(APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); GLAPI PFNGLATTACHSHADERPROC glad_glAttachShader; #define glAttachShader glad_glAttachShader -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar *name); +typedef void(APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, + GLuint index, + const GLchar *name); GLAPI PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation; #define glBindAttribLocation glad_glBindAttribLocation -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader); +typedef void(APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader); GLAPI PFNGLCOMPILESHADERPROC glad_glCompileShader; #define glCompileShader glad_glCompileShader -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC)(void); +typedef GLuint(APIENTRYP PFNGLCREATEPROGRAMPROC)(void); GLAPI PFNGLCREATEPROGRAMPROC glad_glCreateProgram; #define glCreateProgram glad_glCreateProgram -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC)(GLenum type); +typedef GLuint(APIENTRYP PFNGLCREATESHADERPROC)(GLenum type); GLAPI PFNGLCREATESHADERPROC glad_glCreateShader; #define glCreateShader glad_glCreateShader -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program); +typedef void(APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program); GLAPI PFNGLDELETEPROGRAMPROC glad_glDeleteProgram; #define glDeleteProgram glad_glDeleteProgram -typedef void (APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader); +typedef void(APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader); GLAPI PFNGLDELETESHADERPROC glad_glDeleteShader; #define glDeleteShader glad_glDeleteShader -typedef void (APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); +typedef void(APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); GLAPI PFNGLDETACHSHADERPROC glad_glDetachShader; #define glDetachShader glad_glDetachShader -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void(APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); GLAPI PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray; #define glDisableVertexAttribArray glad_glDisableVertexAttribArray -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void(APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); GLAPI PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray; #define glEnableVertexAttribArray glad_glEnableVertexAttribArray -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void(APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, + GLsizei bufSize, + GLsizei *length, GLint *size, + GLenum *type, GLchar *name); GLAPI PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib; #define glGetActiveAttrib glad_glGetActiveAttrib -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void(APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, + GLsizei bufSize, + GLsizei *length, GLint *size, + GLenum *type, GLchar *name); GLAPI PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform; #define glGetActiveUniform glad_glGetActiveUniform -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef void(APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, + GLsizei maxCount, + GLsizei *count, + GLuint *shaders); GLAPI PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders; #define glGetAttachedShaders glad_glGetAttachedShaders -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name); +typedef GLint(APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, + const GLchar *name); GLAPI PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation; #define glGetAttribLocation glad_glGetAttribLocation -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, + GLint *params); GLAPI PFNGLGETPROGRAMIVPROC glad_glGetProgramiv; #define glGetProgramiv glad_glGetProgramiv -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void(APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, + GLsizei bufSize, + GLsizei *length, + GLchar *infoLog); GLAPI PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog; #define glGetProgramInfoLog glad_glGetProgramInfoLog -typedef void (APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, + GLint *params); GLAPI PFNGLGETSHADERIVPROC glad_glGetShaderiv; #define glGetShaderiv glad_glGetShaderiv -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void(APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, + GLsizei bufSize, + GLsizei *length, + GLchar *infoLog); GLAPI PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog; #define glGetShaderInfoLog glad_glGetShaderInfoLog -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef void(APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, + GLsizei *length, + GLchar *source); GLAPI PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource; #define glGetShaderSource glad_glGetShaderSource -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name); +typedef GLint(APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, + const GLchar *name); GLAPI PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation; #define glGetUniformLocation glad_glGetUniformLocation -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat *params); +typedef void(APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, + GLfloat *params); GLAPI PFNGLGETUNIFORMFVPROC glad_glGetUniformfv; #define glGetUniformfv glad_glGetUniformfv -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint *params); +typedef void(APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, + GLint *params); GLAPI PFNGLGETUNIFORMIVPROC glad_glGetUniformiv; #define glGetUniformiv glad_glGetUniformiv -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void(APIENTRYP PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, + GLdouble *params); GLAPI PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv; #define glGetVertexAttribdv glad_glGetVertexAttribdv -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, + GLfloat *params); GLAPI PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv; #define glGetVertexAttribfv glad_glGetVertexAttribfv -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, + GLint *params); GLAPI PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv; #define glGetVertexAttribiv glad_glGetVertexAttribiv -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void **pointer); +typedef void(APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, + GLenum pname, + void **pointer); GLAPI PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv; #define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC)(GLuint program); +typedef GLboolean(APIENTRYP PFNGLISPROGRAMPROC)(GLuint program); GLAPI PFNGLISPROGRAMPROC glad_glIsProgram; #define glIsProgram glad_glIsProgram -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC)(GLuint shader); +typedef GLboolean(APIENTRYP PFNGLISSHADERPROC)(GLuint shader); GLAPI PFNGLISSHADERPROC glad_glIsShader; #define glIsShader glad_glIsShader -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program); +typedef void(APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program); GLAPI PFNGLLINKPROGRAMPROC glad_glLinkProgram; #define glLinkProgram glad_glLinkProgram -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void(APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, + const GLchar *const *string, + const GLint *length); GLAPI PFNGLSHADERSOURCEPROC glad_glShaderSource; #define glShaderSource glad_glShaderSource -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program); +typedef void(APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program); GLAPI PFNGLUSEPROGRAMPROC glad_glUseProgram; #define glUseProgram glad_glUseProgram -typedef void (APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); +typedef void(APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); GLAPI PFNGLUNIFORM1FPROC glad_glUniform1f; #define glUniform1f glad_glUniform1f -typedef void (APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void(APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, + GLfloat v1); GLAPI PFNGLUNIFORM2FPROC glad_glUniform2f; #define glUniform2f glad_glUniform2f -typedef void (APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void(APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, + GLfloat v1, GLfloat v2); GLAPI PFNGLUNIFORM3FPROC glad_glUniform3f; #define glUniform3f glad_glUniform3f -typedef void (APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void(APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, + GLfloat v1, GLfloat v2, GLfloat v3); GLAPI PFNGLUNIFORM4FPROC glad_glUniform4f; #define glUniform4f glad_glUniform4f -typedef void (APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0); +typedef void(APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0); GLAPI PFNGLUNIFORM1IPROC glad_glUniform1i; #define glUniform1i glad_glUniform1i -typedef void (APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); +typedef void(APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); GLAPI PFNGLUNIFORM2IPROC glad_glUniform2i; #define glUniform2i glad_glUniform2i -typedef void (APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void(APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, + GLint v2); GLAPI PFNGLUNIFORM3IPROC glad_glUniform3i; #define glUniform3i glad_glUniform3i -typedef void (APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void(APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, + GLint v2, GLint v3); GLAPI PFNGLUNIFORM4IPROC glad_glUniform4i; #define glUniform4i glad_glUniform4i -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, + const GLfloat *value); GLAPI PFNGLUNIFORM1FVPROC glad_glUniform1fv; #define glUniform1fv glad_glUniform1fv -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, + const GLfloat *value); GLAPI PFNGLUNIFORM2FVPROC glad_glUniform2fv; #define glUniform2fv glad_glUniform2fv -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, + const GLfloat *value); GLAPI PFNGLUNIFORM3FVPROC glad_glUniform3fv; #define glUniform3fv glad_glUniform3fv -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, + const GLfloat *value); GLAPI PFNGLUNIFORM4FVPROC glad_glUniform4fv; #define glUniform4fv glad_glUniform4fv -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, + const GLint *value); GLAPI PFNGLUNIFORM1IVPROC glad_glUniform1iv; #define glUniform1iv glad_glUniform1iv -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, + const GLint *value); GLAPI PFNGLUNIFORM2IVPROC glad_glUniform2iv; #define glUniform2iv glad_glUniform2iv -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, + const GLint *value); GLAPI PFNGLUNIFORM3IVPROC glad_glUniform3iv; #define glUniform3iv glad_glUniform3iv -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, + const GLint *value); GLAPI PFNGLUNIFORM4IVPROC glad_glUniform4iv; #define glUniform4iv glad_glUniform4iv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv; #define glUniformMatrix2fv glad_glUniformMatrix2fv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv; #define glUniformMatrix3fv glad_glUniformMatrix3fv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv; #define glUniformMatrix4fv glad_glUniformMatrix4fv -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program); +typedef void(APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program); GLAPI PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram; #define glValidateProgram glad_glValidateProgram -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); +typedef void(APIENTRYP PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); GLAPI PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d; #define glVertexAttrib1d glad_glVertexAttrib1d -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB1DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv; #define glVertexAttrib1dv glad_glVertexAttrib1dv -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); +typedef void(APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); GLAPI PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f; #define glVertexAttrib1f glad_glVertexAttrib1f -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, + const GLfloat *v); GLAPI PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv; #define glVertexAttrib1fv glad_glVertexAttrib1fv -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x); +typedef void(APIENTRYP PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x); GLAPI PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s; #define glVertexAttrib1s glad_glVertexAttrib1s -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB1SVPROC)(GLuint index, + const GLshort *v); GLAPI PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv; #define glVertexAttrib1sv glad_glVertexAttrib1sv -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void(APIENTRYP PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, + GLdouble y); GLAPI PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d; #define glVertexAttrib2d glad_glVertexAttrib2d -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB2DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv; #define glVertexAttrib2dv glad_glVertexAttrib2dv -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void(APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, + GLfloat y); GLAPI PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f; #define glVertexAttrib2f glad_glVertexAttrib2f -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, + const GLfloat *v); GLAPI PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv; #define glVertexAttrib2fv glad_glVertexAttrib2fv -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); +typedef void(APIENTRYP PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, + GLshort y); GLAPI PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s; #define glVertexAttrib2s glad_glVertexAttrib2s -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB2SVPROC)(GLuint index, + const GLshort *v); GLAPI PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv; #define glVertexAttrib2sv glad_glVertexAttrib2sv -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, + GLdouble y, GLdouble z); GLAPI PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d; #define glVertexAttrib3d glad_glVertexAttrib3d -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB3DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv; #define glVertexAttrib3dv glad_glVertexAttrib3dv -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void(APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, + GLfloat y, GLfloat z); GLAPI PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f; #define glVertexAttrib3f glad_glVertexAttrib3f -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, + const GLfloat *v); GLAPI PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv; #define glVertexAttrib3fv glad_glVertexAttrib3fv -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +typedef void(APIENTRYP PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, + GLshort y, GLshort z); GLAPI PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s; #define glVertexAttrib3s glad_glVertexAttrib3s -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB3SVPROC)(GLuint index, + const GLshort *v); GLAPI PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv; #define glVertexAttrib3sv glad_glVertexAttrib3sv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, + const GLbyte *v); GLAPI PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv; #define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v); GLAPI PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv; #define glVertexAttrib4Niv glad_glVertexAttrib4Niv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, + const GLshort *v); GLAPI PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv; #define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, + GLubyte y, GLubyte z, + GLubyte w); GLAPI PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub; #define glVertexAttrib4Nub glad_glVertexAttrib4Nub -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, + const GLubyte *v); GLAPI PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv; #define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, + const GLuint *v); GLAPI PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv; #define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, + const GLushort *v); GLAPI PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv; #define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v); GLAPI PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv; #define glVertexAttrib4bv glad_glVertexAttrib4bv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, + GLdouble y, GLdouble z, + GLdouble w); GLAPI PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d; #define glVertexAttrib4d glad_glVertexAttrib4d -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv; #define glVertexAttrib4dv glad_glVertexAttrib4dv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, + GLfloat y, GLfloat z, + GLfloat w); GLAPI PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f; #define glVertexAttrib4f glad_glVertexAttrib4f -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, + const GLfloat *v); GLAPI PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv; #define glVertexAttrib4fv glad_glVertexAttrib4fv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v); GLAPI PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv; #define glVertexAttrib4iv glad_glVertexAttrib4iv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, + GLshort y, GLshort z, + GLshort w); GLAPI PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s; #define glVertexAttrib4s glad_glVertexAttrib4s -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4SVPROC)(GLuint index, + const GLshort *v); GLAPI PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv; #define glVertexAttrib4sv glad_glVertexAttrib4sv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, + const GLubyte *v); GLAPI PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv; #define glVertexAttrib4ubv glad_glVertexAttrib4ubv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, + const GLuint *v); GLAPI PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv; #define glVertexAttrib4uiv glad_glVertexAttrib4uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIB4USVPROC)(GLuint index, + const GLushort *v); GLAPI PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv; #define glVertexAttrib4usv glad_glVertexAttrib4usv -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, + GLenum type, + GLboolean normalized, + GLsizei stride, + const void *pointer); GLAPI PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer; #define glVertexAttribPointer glad_glVertexAttribPointer #endif #ifndef GL_VERSION_2_1 #define GL_VERSION_2_1 1 GLAPI int GLAD_GL_VERSION_2_1; -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv; #define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv; #define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv; #define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv; #define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv; #define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv; #define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv #endif #ifndef GL_VERSION_3_0 #define GL_VERSION_3_0 1 GLAPI int GLAD_GL_VERSION_3_0; -typedef void (APIENTRYP PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void(APIENTRYP PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, + GLboolean g, GLboolean b, + GLboolean a); GLAPI PFNGLCOLORMASKIPROC glad_glColorMaski; #define glColorMaski glad_glColorMaski -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean *data); +typedef void(APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, + GLboolean *data); GLAPI PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v; #define glGetBooleani_v glad_glGetBooleani_v -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint *data); +typedef void(APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, + GLint *data); GLAPI PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v; #define glGetIntegeri_v glad_glGetIntegeri_v -typedef void (APIENTRYP PFNGLENABLEIPROC)(GLenum target, GLuint index); +typedef void(APIENTRYP PFNGLENABLEIPROC)(GLenum target, GLuint index); GLAPI PFNGLENABLEIPROC glad_glEnablei; #define glEnablei glad_glEnablei -typedef void (APIENTRYP PFNGLDISABLEIPROC)(GLenum target, GLuint index); +typedef void(APIENTRYP PFNGLDISABLEIPROC)(GLenum target, GLuint index); GLAPI PFNGLDISABLEIPROC glad_glDisablei; #define glDisablei glad_glDisablei -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC)(GLenum target, GLuint index); +typedef GLboolean(APIENTRYP PFNGLISENABLEDIPROC)(GLenum target, GLuint index); GLAPI PFNGLISENABLEDIPROC glad_glIsEnabledi; #define glIsEnabledi glad_glIsEnabledi -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode); +typedef void(APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode); GLAPI PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback; #define glBeginTransformFeedback glad_glBeginTransformFeedback -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)(void); +typedef void(APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)(void); GLAPI PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback; #define glEndTransformFeedback glad_glEndTransformFeedback -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void(APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, + GLuint buffer, GLintptr offset, + GLsizeiptr size); GLAPI PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange; #define glBindBufferRange glad_glBindBufferRange -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer); +typedef void(APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, + GLuint buffer); GLAPI PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase; #define glBindBufferBase glad_glBindBufferBase -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void(APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)( + GLuint program, GLsizei count, const GLchar *const *varyings, + GLenum bufferMode); GLAPI PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings; #define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void(APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)( + GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, + GLsizei *size, GLenum *type, GLchar *name); GLAPI PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying; #define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp); +typedef void(APIENTRYP PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp); GLAPI PFNGLCLAMPCOLORPROC glad_glClampColor; #define glClampColor glad_glClampColor -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode); +typedef void(APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode); GLAPI PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender; #define glBeginConditionalRender glad_glBeginConditionalRender -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC)(void); +typedef void(APIENTRYP PFNGLENDCONDITIONALRENDERPROC)(void); GLAPI PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender; #define glEndConditionalRender glad_glEndConditionalRender -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, + GLenum type, + GLsizei stride, + const void *pointer); GLAPI PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer; #define glVertexAttribIPointer glad_glVertexAttribIPointer -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, + GLint *params); GLAPI PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv; #define glGetVertexAttribIiv glad_glGetVertexAttribIiv -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint *params); +typedef void(APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, + GLuint *params); GLAPI PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv; #define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x); GLAPI PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i; #define glVertexAttribI1i glad_glVertexAttribI1i -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, + GLint y); GLAPI PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i; #define glVertexAttribI2i glad_glVertexAttribI2i -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, + GLint z); GLAPI PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i; #define glVertexAttribI3i glad_glVertexAttribI3i -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, + GLint z, GLint w); GLAPI PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i; #define glVertexAttribI4i glad_glVertexAttribI4i -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x); GLAPI PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui; #define glVertexAttribI1ui glad_glVertexAttribI1ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, + GLuint y); GLAPI PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui; #define glVertexAttribI2ui glad_glVertexAttribI2ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, + GLuint y, GLuint z); GLAPI PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui; #define glVertexAttribI3ui glad_glVertexAttribI3ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, + GLuint y, GLuint z, GLuint w); GLAPI PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui; #define glVertexAttribI4ui glad_glVertexAttribI4ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint *v); GLAPI PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv; #define glVertexAttribI1iv glad_glVertexAttribI1iv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint *v); GLAPI PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv; #define glVertexAttribI2iv glad_glVertexAttribI2iv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint *v); GLAPI PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv; #define glVertexAttribI3iv glad_glVertexAttribI3iv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint *v); GLAPI PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv; #define glVertexAttribI4iv glad_glVertexAttribI4iv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, + const GLuint *v); GLAPI PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv; #define glVertexAttribI1uiv glad_glVertexAttribI1uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, + const GLuint *v); GLAPI PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv; #define glVertexAttribI2uiv glad_glVertexAttribI2uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, + const GLuint *v); GLAPI PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv; #define glVertexAttribI3uiv glad_glVertexAttribI3uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, + const GLuint *v); GLAPI PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv; #define glVertexAttribI4uiv glad_glVertexAttribI4uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, + const GLbyte *v); GLAPI PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv; #define glVertexAttribI4bv glad_glVertexAttribI4bv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, + const GLshort *v); GLAPI PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv; #define glVertexAttribI4sv glad_glVertexAttribI4sv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, + const GLubyte *v); GLAPI PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv; #define glVertexAttribI4ubv glad_glVertexAttribI4ubv -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, + const GLushort *v); GLAPI PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv; #define glVertexAttribI4usv glad_glVertexAttribI4usv -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint *params); +typedef void(APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, + GLuint *params); GLAPI PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv; #define glGetUniformuiv glad_glGetUniformuiv -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar *name); +typedef void(APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, + GLuint color, + const GLchar *name); GLAPI PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation; #define glBindFragDataLocation glad_glBindFragDataLocation -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar *name); +typedef GLint(APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, + const GLchar *name); GLAPI PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation; #define glGetFragDataLocation glad_glGetFragDataLocation -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); +typedef void(APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); GLAPI PFNGLUNIFORM1UIPROC glad_glUniform1ui; #define glUniform1ui glad_glUniform1ui -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1); +typedef void(APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, + GLuint v1); GLAPI PFNGLUNIFORM2UIPROC glad_glUniform2ui; #define glUniform2ui glad_glUniform2ui -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void(APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, + GLuint v1, GLuint v2); GLAPI PFNGLUNIFORM3UIPROC glad_glUniform3ui; #define glUniform3ui glad_glUniform3ui -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void(APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, + GLuint v1, GLuint v2, GLuint v3); GLAPI PFNGLUNIFORM4UIPROC glad_glUniform4ui; #define glUniform4ui glad_glUniform4ui -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, + const GLuint *value); GLAPI PFNGLUNIFORM1UIVPROC glad_glUniform1uiv; #define glUniform1uiv glad_glUniform1uiv -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, + const GLuint *value); GLAPI PFNGLUNIFORM2UIVPROC glad_glUniform2uiv; #define glUniform2uiv glad_glUniform2uiv -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, + const GLuint *value); GLAPI PFNGLUNIFORM3UIVPROC glad_glUniform3uiv; #define glUniform3uiv glad_glUniform3uiv -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, + const GLuint *value); GLAPI PFNGLUNIFORM4UIVPROC glad_glUniform4uiv; #define glUniform4uiv glad_glUniform4uiv -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, + const GLint *params); GLAPI PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv; #define glTexParameterIiv glad_glTexParameterIiv -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint *params); +typedef void(APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, + const GLuint *params); GLAPI PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv; #define glTexParameterIuiv glad_glTexParameterIuiv -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, + GLint *params); GLAPI PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv; #define glGetTexParameterIiv glad_glGetTexParameterIiv -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint *params); +typedef void(APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, + GLenum pname, + GLuint *params); GLAPI PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv; #define glGetTexParameterIuiv glad_glGetTexParameterIuiv -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void(APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, + const GLint *value); GLAPI PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv; #define glClearBufferiv glad_glClearBufferiv -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void(APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, + const GLuint *value); GLAPI PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv; #define glClearBufferuiv glad_glClearBufferuiv -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void(APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, + const GLfloat *value); GLAPI PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv; #define glClearBufferfv glad_glClearBufferfv -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void(APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, + GLfloat depth, GLint stencil); GLAPI PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi; #define glClearBufferfi glad_glClearBufferfi -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, GLuint index); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, + GLuint index); GLAPI PFNGLGETSTRINGIPROC glad_glGetStringi; #define glGetStringi glad_glGetStringi -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); +typedef GLboolean(APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); GLAPI PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer; #define glIsRenderbuffer glad_glIsRenderbuffer -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); +typedef void(APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, + GLuint renderbuffer); GLAPI PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer; #define glBindRenderbuffer glad_glBindRenderbuffer -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers); +typedef void(APIENTRYP PFNGLDELETERENDERBUFFERSPROC)( + GLsizei n, const GLuint *renderbuffers); GLAPI PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers; #define glDeleteRenderbuffers glad_glDeleteRenderbuffers -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); +typedef void(APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, + GLuint *renderbuffers); GLAPI PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers; #define glGenRenderbuffers glad_glGenRenderbuffers -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, + GLenum internalformat, + GLsizei width, + GLsizei height); GLAPI PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage; #define glRenderbufferStorage glad_glRenderbufferStorage -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, + GLenum pname, + GLint *params); GLAPI PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv; #define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); +typedef GLboolean(APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); GLAPI PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer; #define glIsFramebuffer glad_glIsFramebuffer -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); +typedef void(APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, + GLuint framebuffer); GLAPI PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer; #define glBindFramebuffer glad_glBindFramebuffer -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers); +typedef void(APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, + const GLuint *framebuffers); GLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers; #define glDeleteFramebuffers glad_glDeleteFramebuffers -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); +typedef void(APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, + GLuint *framebuffers); GLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers; #define glGenFramebuffers glad_glGenFramebuffers -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); +typedef GLenum(APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); GLAPI PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus; #define glCheckFramebufferStatus glad_glCheckFramebufferStatus -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void(APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, + GLenum attachment, + GLenum textarget, + GLuint texture, + GLint level); GLAPI PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D; #define glFramebufferTexture1D glad_glFramebufferTexture1D -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void(APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, + GLenum attachment, + GLenum textarget, + GLuint texture, + GLint level); GLAPI PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D; #define glFramebufferTexture2D glad_glFramebufferTexture2D -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void(APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC)( + GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level, GLint zoffset); GLAPI PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D; #define glFramebufferTexture3D glad_glFramebufferTexture3D -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void(APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)( + GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer); GLAPI PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer; #define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv; -#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target); +typedef void(APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)( + GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC + glad_glGetFramebufferAttachmentParameteriv; +#define glGetFramebufferAttachmentParameteriv \ + glad_glGetFramebufferAttachmentParameteriv +typedef void(APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target); GLAPI PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap; #define glGenerateMipmap glad_glGenerateMipmap -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void(APIENTRYP PFNGLBLITFRAMEBUFFERPROC)( + GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, + GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer; #define glBlitFramebuffer glad_glBlitFramebuffer -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample; +typedef void(APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)( + GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height); +GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC + glad_glRenderbufferStorageMultisample; #define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void(APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)( + GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); GLAPI PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer; #define glFramebufferTextureLayer glad_glFramebufferTextureLayer -typedef void * (APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, + GLintptr offset, + GLsizeiptr length, + GLbitfield access); GLAPI PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange; #define glMapBufferRange glad_glMapBufferRange -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); +typedef void(APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, + GLintptr offset, + GLsizeiptr length); GLAPI PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange; #define glFlushMappedBufferRange glad_glFlushMappedBufferRange -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array); +typedef void(APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array); GLAPI PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray; #define glBindVertexArray glad_glBindVertexArray -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint *arrays); +typedef void(APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, + const GLuint *arrays); GLAPI PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays; #define glDeleteVertexArrays glad_glDeleteVertexArrays -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays); +typedef void(APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays); GLAPI PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays; #define glGenVertexArrays glad_glGenVertexArrays -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array); +typedef GLboolean(APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array); GLAPI PFNGLISVERTEXARRAYPROC glad_glIsVertexArray; #define glIsVertexArray glad_glIsVertexArray #endif #ifndef GL_VERSION_3_1 #define GL_VERSION_3_1 1 GLAPI int GLAD_GL_VERSION_3_1; -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void(APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, + GLsizei count, + GLsizei instancecount); GLAPI PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced; #define glDrawArraysInstanced glad_glDrawArraysInstanced -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void(APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, + GLsizei count, + GLenum type, + const void *indices, + GLsizei instancecount); GLAPI PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced; #define glDrawElementsInstanced glad_glDrawElementsInstanced -typedef void (APIENTRYP PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer); +typedef void(APIENTRYP PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, + GLuint buffer); GLAPI PFNGLTEXBUFFERPROC glad_glTexBuffer; #define glTexBuffer glad_glTexBuffer -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index); +typedef void(APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index); GLAPI PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex; #define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void(APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, + GLenum writeTarget, + GLintptr readOffset, + GLintptr writeOffset, + GLsizeiptr size); GLAPI PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData; #define glCopyBufferSubData glad_glCopyBufferSubData -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void(APIENTRYP PFNGLGETUNIFORMINDICESPROC)( + GLuint program, GLsizei uniformCount, const GLchar *const *uniformNames, + GLuint *uniformIndices); GLAPI PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices; #define glGetUniformIndices glad_glGetUniformIndices -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)( + GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, + GLenum pname, GLint *params); GLAPI PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv; #define glGetActiveUniformsiv glad_glGetActiveUniformsiv -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef void(APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, + GLuint uniformIndex, + GLsizei bufSize, + GLsizei *length, + GLchar *uniformName); GLAPI PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName; #define glGetActiveUniformName glad_glGetActiveUniformName -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar *uniformBlockName); +typedef GLuint(APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)( + GLuint program, const GLchar *uniformBlockName); GLAPI PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex; #define glGetUniformBlockIndex glad_glGetUniformBlockIndex -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)( + GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); GLAPI PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv; #define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void(APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)( + GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, + GLchar *uniformBlockName); GLAPI PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName; #define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void(APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)( + GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); GLAPI PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding; #define glUniformBlockBinding glad_glUniformBlockBinding #endif #ifndef GL_VERSION_3_2 #define GL_VERSION_3_2 1 GLAPI int GLAD_GL_VERSION_3_2; -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void(APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, + GLsizei count, + GLenum type, + const void *indices, + GLint basevertex); GLAPI PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex; #define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void(APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)( + GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, + const void *indices, GLint basevertex); GLAPI PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex; #define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex; +typedef void(APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)( + GLenum mode, GLsizei count, GLenum type, const void *indices, + GLsizei instancecount, GLint basevertex); +GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC + glad_glDrawElementsInstancedBaseVertex; #define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void(APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)( + GLenum mode, const GLsizei *count, GLenum type, const void *const *indices, + GLsizei drawcount, const GLint *basevertex); GLAPI PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex; #define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC)(GLenum mode); +typedef void(APIENTRYP PFNGLPROVOKINGVERTEXPROC)(GLenum mode); GLAPI PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex; #define glProvokingVertex glad_glProvokingVertex -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags); +typedef GLsync(APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, + GLbitfield flags); GLAPI PFNGLFENCESYNCPROC glad_glFenceSync; #define glFenceSync glad_glFenceSync -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC)(GLsync sync); +typedef GLboolean(APIENTRYP PFNGLISSYNCPROC)(GLsync sync); GLAPI PFNGLISSYNCPROC glad_glIsSync; #define glIsSync glad_glIsSync -typedef void (APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync); +typedef void(APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync); GLAPI PFNGLDELETESYNCPROC glad_glDeleteSync; #define glDeleteSync glad_glDeleteSync -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef GLenum(APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, + GLuint64 timeout); GLAPI PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync; #define glClientWaitSync glad_glClientWaitSync -typedef void (APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void(APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, + GLuint64 timeout); GLAPI PFNGLWAITSYNCPROC glad_glWaitSync; #define glWaitSync glad_glWaitSync -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 *data); +typedef void(APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 *data); GLAPI PFNGLGETINTEGER64VPROC glad_glGetInteger64v; #define glGetInteger64v glad_glGetInteger64v -typedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void(APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, + GLsizei count, GLsizei *length, + GLint *values); GLAPI PFNGLGETSYNCIVPROC glad_glGetSynciv; #define glGetSynciv glad_glGetSynciv -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 *data); +typedef void(APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, + GLint64 *data); GLAPI PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v; #define glGetInteger64i_v glad_glGetInteger64i_v -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 *params); +typedef void(APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, + GLenum pname, + GLint64 *params); GLAPI PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v; #define glGetBufferParameteri64v glad_glGetBufferParameteri64v -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void(APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, + GLenum attachment, + GLuint texture, + GLint level); GLAPI PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture; #define glFramebufferTexture glad_glFramebufferTexture -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void(APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC)( + GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height, GLboolean fixedsamplelocations); GLAPI PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample; #define glTexImage2DMultisample glad_glTexImage2DMultisample -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void(APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC)( + GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample; #define glTexImage3DMultisample glad_glTexImage3DMultisample -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat *val); +typedef void(APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, + GLfloat *val); GLAPI PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv; #define glGetMultisamplefv glad_glGetMultisamplefv -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask); +typedef void(APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, + GLbitfield mask); GLAPI PFNGLSAMPLEMASKIPROC glad_glSampleMaski; #define glSampleMaski glad_glSampleMaski #endif #ifndef GL_VERSION_3_3 #define GL_VERSION_3_3 1 GLAPI int GLAD_GL_VERSION_3_3; -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef void(APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)( + GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); GLAPI PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed; #define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar *name); +typedef GLint(APIENTRYP PFNGLGETFRAGDATAINDEXPROC)(GLuint program, + const GLchar *name); GLAPI PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex; #define glGetFragDataIndex glad_glGetFragDataIndex -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint *samplers); +typedef void(APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint *samplers); GLAPI PFNGLGENSAMPLERSPROC glad_glGenSamplers; #define glGenSamplers glad_glGenSamplers -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint *samplers); +typedef void(APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, + const GLuint *samplers); GLAPI PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers; #define glDeleteSamplers glad_glDeleteSamplers -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler); +typedef GLboolean(APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler); GLAPI PFNGLISSAMPLERPROC glad_glIsSampler; #define glIsSampler glad_glIsSampler -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); +typedef void(APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); GLAPI PFNGLBINDSAMPLERPROC glad_glBindSampler; #define glBindSampler glad_glBindSampler -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, + GLint param); GLAPI PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri; #define glSamplerParameteri glad_glSamplerParameteri -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint *param); +typedef void(APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, + GLenum pname, + const GLint *param); GLAPI PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv; #define glSamplerParameteriv glad_glSamplerParameteriv -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, + GLfloat param); GLAPI PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf; #define glSamplerParameterf glad_glSamplerParameterf -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat *param); +typedef void(APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, + GLenum pname, + const GLfloat *param); GLAPI PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv; #define glSamplerParameterfv glad_glSamplerParameterfv -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint *param); +typedef void(APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, + GLenum pname, + const GLint *param); GLAPI PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv; #define glSamplerParameterIiv glad_glSamplerParameterIiv -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint *param); +typedef void(APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, + GLenum pname, + const GLuint *param); GLAPI PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv; #define glSamplerParameterIuiv glad_glSamplerParameterIuiv -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, + GLenum pname, + GLint *params); GLAPI PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv; #define glGetSamplerParameteriv glad_glGetSamplerParameteriv -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, + GLenum pname, + GLint *params); GLAPI PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv; #define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, + GLenum pname, + GLfloat *params); GLAPI PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv; #define glGetSamplerParameterfv glad_glGetSamplerParameterfv -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint *params); +typedef void(APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, + GLenum pname, + GLuint *params); GLAPI PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv; #define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target); +typedef void(APIENTRYP PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target); GLAPI PFNGLQUERYCOUNTERPROC glad_glQueryCounter; #define glQueryCounter glad_glQueryCounter -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 *params); +typedef void(APIENTRYP PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, + GLint64 *params); GLAPI PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v; #define glGetQueryObjecti64v glad_glGetQueryObjecti64v -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 *params); +typedef void(APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, + GLuint64 *params); GLAPI PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v; #define glGetQueryObjectui64v glad_glGetQueryObjectui64v -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor); +typedef void(APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, + GLuint divisor); GLAPI PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor; #define glVertexAttribDivisor glad_glVertexAttribDivisor -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, + GLboolean normalized, + GLuint value); GLAPI PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui; #define glVertexAttribP1ui glad_glVertexAttribP1ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); GLAPI PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv; #define glVertexAttribP1uiv glad_glVertexAttribP1uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, + GLboolean normalized, + GLuint value); GLAPI PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui; #define glVertexAttribP2ui glad_glVertexAttribP2ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); GLAPI PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv; #define glVertexAttribP2uiv glad_glVertexAttribP2uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, + GLboolean normalized, + GLuint value); GLAPI PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui; #define glVertexAttribP3ui glad_glVertexAttribP3ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); GLAPI PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv; #define glVertexAttribP3uiv glad_glVertexAttribP3uiv -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, + GLboolean normalized, + GLuint value); GLAPI PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui; #define glVertexAttribP4ui glad_glVertexAttribP4ui -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void(APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); GLAPI PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv; #define glVertexAttribP4uiv glad_glVertexAttribP4uiv -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value); +typedef void(APIENTRYP PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value); GLAPI PFNGLVERTEXP2UIPROC glad_glVertexP2ui; #define glVertexP2ui glad_glVertexP2ui -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint *value); +typedef void(APIENTRYP PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint *value); GLAPI PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv; #define glVertexP2uiv glad_glVertexP2uiv -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value); +typedef void(APIENTRYP PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value); GLAPI PFNGLVERTEXP3UIPROC glad_glVertexP3ui; #define glVertexP3ui glad_glVertexP3ui -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint *value); +typedef void(APIENTRYP PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint *value); GLAPI PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv; #define glVertexP3uiv glad_glVertexP3uiv -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value); +typedef void(APIENTRYP PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value); GLAPI PFNGLVERTEXP4UIPROC glad_glVertexP4ui; #define glVertexP4ui glad_glVertexP4ui -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint *value); +typedef void(APIENTRYP PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint *value); GLAPI PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv; #define glVertexP4uiv glad_glVertexP4uiv -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords); GLAPI PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui; #define glTexCoordP1ui glad_glTexCoordP1ui -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLTEXCOORDP1UIVPROC)(GLenum type, + const GLuint *coords); GLAPI PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv; #define glTexCoordP1uiv glad_glTexCoordP1uiv -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords); GLAPI PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui; #define glTexCoordP2ui glad_glTexCoordP2ui -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLTEXCOORDP2UIVPROC)(GLenum type, + const GLuint *coords); GLAPI PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv; #define glTexCoordP2uiv glad_glTexCoordP2uiv -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords); GLAPI PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui; #define glTexCoordP3ui glad_glTexCoordP3ui -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLTEXCOORDP3UIVPROC)(GLenum type, + const GLuint *coords); GLAPI PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv; #define glTexCoordP3uiv glad_glTexCoordP3uiv -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords); GLAPI PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui; #define glTexCoordP4ui glad_glTexCoordP4ui -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLTEXCOORDP4UIVPROC)(GLenum type, + const GLuint *coords); GLAPI PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv; #define glTexCoordP4uiv glad_glTexCoordP4uiv -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, + GLuint coords); GLAPI PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui; #define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, + const GLuint *coords); GLAPI PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv; #define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, + GLuint coords); GLAPI PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui; #define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, + const GLuint *coords); GLAPI PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv; #define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, + GLuint coords); GLAPI PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui; #define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, + const GLuint *coords); GLAPI PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv; #define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, + GLuint coords); GLAPI PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui; #define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, + const GLuint *coords); GLAPI PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv; #define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv -typedef void (APIENTRYP PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords); +typedef void(APIENTRYP PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords); GLAPI PFNGLNORMALP3UIPROC glad_glNormalP3ui; #define glNormalP3ui glad_glNormalP3ui -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint *coords); +typedef void(APIENTRYP PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint *coords); GLAPI PFNGLNORMALP3UIVPROC glad_glNormalP3uiv; #define glNormalP3uiv glad_glNormalP3uiv -typedef void (APIENTRYP PFNGLCOLORP3UIPROC)(GLenum type, GLuint color); +typedef void(APIENTRYP PFNGLCOLORP3UIPROC)(GLenum type, GLuint color); GLAPI PFNGLCOLORP3UIPROC glad_glColorP3ui; #define glColorP3ui glad_glColorP3ui -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint *color); +typedef void(APIENTRYP PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint *color); GLAPI PFNGLCOLORP3UIVPROC glad_glColorP3uiv; #define glColorP3uiv glad_glColorP3uiv -typedef void (APIENTRYP PFNGLCOLORP4UIPROC)(GLenum type, GLuint color); +typedef void(APIENTRYP PFNGLCOLORP4UIPROC)(GLenum type, GLuint color); GLAPI PFNGLCOLORP4UIPROC glad_glColorP4ui; #define glColorP4ui glad_glColorP4ui -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint *color); +typedef void(APIENTRYP PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint *color); GLAPI PFNGLCOLORP4UIVPROC glad_glColorP4uiv; #define glColorP4uiv glad_glColorP4uiv -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color); +typedef void(APIENTRYP PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color); GLAPI PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui; #define glSecondaryColorP3ui glad_glSecondaryColorP3ui -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint *color); +typedef void(APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, + const GLuint *color); GLAPI PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv; #define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv #endif #ifndef GL_VERSION_4_0 #define GL_VERSION_4_0 1 GLAPI int GLAD_GL_VERSION_4_0; -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC)(GLfloat value); +typedef void(APIENTRYP PFNGLMINSAMPLESHADINGPROC)(GLfloat value); GLAPI PFNGLMINSAMPLESHADINGPROC glad_glMinSampleShading; #define glMinSampleShading glad_glMinSampleShading -typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC)(GLuint buf, GLenum mode); +typedef void(APIENTRYP PFNGLBLENDEQUATIONIPROC)(GLuint buf, GLenum mode); GLAPI PFNGLBLENDEQUATIONIPROC glad_glBlendEquationi; #define glBlendEquationi glad_glBlendEquationi -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void(APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC)(GLuint buf, + GLenum modeRGB, + GLenum modeAlpha); GLAPI PFNGLBLENDEQUATIONSEPARATEIPROC glad_glBlendEquationSeparatei; #define glBlendEquationSeparatei glad_glBlendEquationSeparatei -typedef void (APIENTRYP PFNGLBLENDFUNCIPROC)(GLuint buf, GLenum src, GLenum dst); +typedef void(APIENTRYP PFNGLBLENDFUNCIPROC)(GLuint buf, GLenum src, GLenum dst); GLAPI PFNGLBLENDFUNCIPROC glad_glBlendFunci; #define glBlendFunci glad_glBlendFunci -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void(APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC)(GLuint buf, GLenum srcRGB, + GLenum dstRGB, + GLenum srcAlpha, + GLenum dstAlpha); GLAPI PFNGLBLENDFUNCSEPARATEIPROC glad_glBlendFuncSeparatei; #define glBlendFuncSeparatei glad_glBlendFuncSeparatei -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, const void *indirect); +typedef void(APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, + const void *indirect); GLAPI PFNGLDRAWARRAYSINDIRECTPROC glad_glDrawArraysIndirect; #define glDrawArraysIndirect glad_glDrawArraysIndirect -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void *indirect); +typedef void(APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, + const void *indirect); GLAPI PFNGLDRAWELEMENTSINDIRECTPROC glad_glDrawElementsIndirect; #define glDrawElementsIndirect glad_glDrawElementsIndirect -typedef void (APIENTRYP PFNGLUNIFORM1DPROC)(GLint location, GLdouble x); +typedef void(APIENTRYP PFNGLUNIFORM1DPROC)(GLint location, GLdouble x); GLAPI PFNGLUNIFORM1DPROC glad_glUniform1d; #define glUniform1d glad_glUniform1d -typedef void (APIENTRYP PFNGLUNIFORM2DPROC)(GLint location, GLdouble x, GLdouble y); +typedef void(APIENTRYP PFNGLUNIFORM2DPROC)(GLint location, GLdouble x, + GLdouble y); GLAPI PFNGLUNIFORM2DPROC glad_glUniform2d; #define glUniform2d glad_glUniform2d -typedef void (APIENTRYP PFNGLUNIFORM3DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLUNIFORM3DPROC)(GLint location, GLdouble x, + GLdouble y, GLdouble z); GLAPI PFNGLUNIFORM3DPROC glad_glUniform3d; #define glUniform3d glad_glUniform3d -typedef void (APIENTRYP PFNGLUNIFORM4DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(APIENTRYP PFNGLUNIFORM4DPROC)(GLint location, GLdouble x, + GLdouble y, GLdouble z, GLdouble w); GLAPI PFNGLUNIFORM4DPROC glad_glUniform4d; #define glUniform4d glad_glUniform4d -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORM1DVPROC)(GLint location, GLsizei count, + const GLdouble *value); GLAPI PFNGLUNIFORM1DVPROC glad_glUniform1dv; #define glUniform1dv glad_glUniform1dv -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORM2DVPROC)(GLint location, GLsizei count, + const GLdouble *value); GLAPI PFNGLUNIFORM2DVPROC glad_glUniform2dv; #define glUniform2dv glad_glUniform2dv -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORM3DVPROC)(GLint location, GLsizei count, + const GLdouble *value); GLAPI PFNGLUNIFORM3DVPROC glad_glUniform3dv; #define glUniform3dv glad_glUniform3dv -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC)(GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORM4DVPROC)(GLint location, GLsizei count, + const GLdouble *value); GLAPI PFNGLUNIFORM4DVPROC glad_glUniform4dv; #define glUniform4dv glad_glUniform4dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX2DVPROC)(GLint location, GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX2DVPROC glad_glUniformMatrix2dv; #define glUniformMatrix2dv glad_glUniformMatrix2dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX3DVPROC)(GLint location, GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX3DVPROC glad_glUniformMatrix3dv; #define glUniformMatrix3dv glad_glUniformMatrix3dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX4DVPROC)(GLint location, GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX4DVPROC glad_glUniformMatrix4dv; #define glUniformMatrix4dv glad_glUniformMatrix4dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX2X3DVPROC glad_glUniformMatrix2x3dv; #define glUniformMatrix2x3dv glad_glUniformMatrix2x3dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX2X4DVPROC glad_glUniformMatrix2x4dv; #define glUniformMatrix2x4dv glad_glUniformMatrix2x4dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX3X2DVPROC glad_glUniformMatrix3x2dv; #define glUniformMatrix3x2dv glad_glUniformMatrix3x2dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX3X4DVPROC glad_glUniformMatrix3x4dv; #define glUniformMatrix3x4dv glad_glUniformMatrix3x4dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX4X2DVPROC glad_glUniformMatrix4x2dv; #define glUniformMatrix4x2dv glad_glUniformMatrix4x2dv -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC)(GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLUNIFORMMATRIX4X3DVPROC glad_glUniformMatrix4x3dv; #define glUniformMatrix4x3dv glad_glUniformMatrix4x3dv -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC)(GLuint program, GLint location, GLdouble *params); +typedef void(APIENTRYP PFNGLGETUNIFORMDVPROC)(GLuint program, GLint location, + GLdouble *params); GLAPI PFNGLGETUNIFORMDVPROC glad_glGetUniformdv; #define glGetUniformdv glad_glGetUniformdv -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)(GLuint program, GLenum shadertype, const GLchar *name); +typedef GLint(APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)( + GLuint program, GLenum shadertype, const GLchar *name); GLAPI PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_glGetSubroutineUniformLocation; #define glGetSubroutineUniformLocation glad_glGetSubroutineUniformLocation -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC)(GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint(APIENTRYP PFNGLGETSUBROUTINEINDEXPROC)(GLuint program, + GLenum shadertype, + const GLchar *name); GLAPI PFNGLGETSUBROUTINEINDEXPROC glad_glGetSubroutineIndex; #define glGetSubroutineIndex glad_glGetSubroutineIndex -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)(GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void(APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)(GLuint program, + GLenum shadertype, + GLuint index, + GLenum pname, + GLint *values); GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv; #define glGetActiveSubroutineUniformiv glad_glGetActiveSubroutineUniformiv -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName; +typedef void(APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)( + GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, + GLsizei *length, GLchar *name); +GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC + glad_glGetActiveSubroutineUniformName; #define glGetActiveSubroutineUniformName glad_glGetActiveSubroutineUniformName -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void(APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC)( + GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, + GLsizei *length, GLchar *name); GLAPI PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName; #define glGetActiveSubroutineName glad_glGetActiveSubroutineName -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC)(GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void(APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC)(GLenum shadertype, + GLsizei count, + const GLuint *indices); GLAPI PFNGLUNIFORMSUBROUTINESUIVPROC glad_glUniformSubroutinesuiv; #define glUniformSubroutinesuiv glad_glUniformSubroutinesuiv -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC)(GLenum shadertype, GLint location, GLuint *params); +typedef void(APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC)(GLenum shadertype, + GLint location, + GLuint *params); GLAPI PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_glGetUniformSubroutineuiv; #define glGetUniformSubroutineuiv glad_glGetUniformSubroutineuiv -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC)(GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void(APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC)(GLuint program, + GLenum shadertype, + GLenum pname, GLint *values); GLAPI PFNGLGETPROGRAMSTAGEIVPROC glad_glGetProgramStageiv; #define glGetProgramStageiv glad_glGetProgramStageiv -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC)(GLenum pname, GLint value); +typedef void(APIENTRYP PFNGLPATCHPARAMETERIPROC)(GLenum pname, GLint value); GLAPI PFNGLPATCHPARAMETERIPROC glad_glPatchParameteri; #define glPatchParameteri glad_glPatchParameteri -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC)(GLenum pname, const GLfloat *values); +typedef void(APIENTRYP PFNGLPATCHPARAMETERFVPROC)(GLenum pname, + const GLfloat *values); GLAPI PFNGLPATCHPARAMETERFVPROC glad_glPatchParameterfv; #define glPatchParameterfv glad_glPatchParameterfv -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, GLuint id); +typedef void(APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, + GLuint id); GLAPI PFNGLBINDTRANSFORMFEEDBACKPROC glad_glBindTransformFeedback; #define glBindTransformFeedback glad_glBindTransformFeedback -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, const GLuint *ids); +typedef void(APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, + const GLuint *ids); GLAPI PFNGLDELETETRANSFORMFEEDBACKSPROC glad_glDeleteTransformFeedbacks; #define glDeleteTransformFeedbacks glad_glDeleteTransformFeedbacks -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint *ids); +typedef void(APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint *ids); GLAPI PFNGLGENTRANSFORMFEEDBACKSPROC glad_glGenTransformFeedbacks; #define glGenTransformFeedbacks glad_glGenTransformFeedbacks -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id); +typedef GLboolean(APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id); GLAPI PFNGLISTRANSFORMFEEDBACKPROC glad_glIsTransformFeedback; #define glIsTransformFeedback glad_glIsTransformFeedback -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC)(void); +typedef void(APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC)(void); GLAPI PFNGLPAUSETRANSFORMFEEDBACKPROC glad_glPauseTransformFeedback; #define glPauseTransformFeedback glad_glPauseTransformFeedback -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC)(void); +typedef void(APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC)(void); GLAPI PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback; #define glResumeTransformFeedback glad_glResumeTransformFeedback -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC)(GLenum mode, GLuint id); +typedef void(APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC)(GLenum mode, GLuint id); GLAPI PFNGLDRAWTRANSFORMFEEDBACKPROC glad_glDrawTransformFeedback; #define glDrawTransformFeedback glad_glDrawTransformFeedback -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)(GLenum mode, GLuint id, GLuint stream); +typedef void(APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)(GLenum mode, + GLuint id, + GLuint stream); GLAPI PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_glDrawTransformFeedbackStream; #define glDrawTransformFeedbackStream glad_glDrawTransformFeedbackStream -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC)(GLenum target, GLuint index, GLuint id); +typedef void(APIENTRYP PFNGLBEGINQUERYINDEXEDPROC)(GLenum target, GLuint index, + GLuint id); GLAPI PFNGLBEGINQUERYINDEXEDPROC glad_glBeginQueryIndexed; #define glBeginQueryIndexed glad_glBeginQueryIndexed -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC)(GLenum target, GLuint index); +typedef void(APIENTRYP PFNGLENDQUERYINDEXEDPROC)(GLenum target, GLuint index); GLAPI PFNGLENDQUERYINDEXEDPROC glad_glEndQueryIndexed; #define glEndQueryIndexed glad_glEndQueryIndexed -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC)(GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETQUERYINDEXEDIVPROC)(GLenum target, GLuint index, + GLenum pname, GLint *params); GLAPI PFNGLGETQUERYINDEXEDIVPROC glad_glGetQueryIndexediv; #define glGetQueryIndexediv glad_glGetQueryIndexediv #endif #ifndef GL_VERSION_4_1 #define GL_VERSION_4_1 1 GLAPI int GLAD_GL_VERSION_4_1; -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void); +typedef void(APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void); GLAPI PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler; #define glReleaseShaderCompiler glad_glReleaseShaderCompiler -typedef void (APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void(APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, + const GLuint *shaders, + GLenum binaryFormat, + const void *binary, + GLsizei length); GLAPI PFNGLSHADERBINARYPROC glad_glShaderBinary; #define glShaderBinary glad_glShaderBinary -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void(APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, + GLenum precisiontype, + GLint *range, + GLint *precision); GLAPI PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat; #define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); +typedef void(APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); GLAPI PFNGLDEPTHRANGEFPROC glad_glDepthRangef; #define glDepthRangef glad_glDepthRangef -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d); +typedef void(APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d); GLAPI PFNGLCLEARDEPTHFPROC glad_glClearDepthf; #define glClearDepthf glad_glClearDepthf -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void(APIENTRYP PFNGLGETPROGRAMBINARYPROC)(GLuint program, + GLsizei bufSize, + GLsizei *length, + GLenum *binaryFormat, + void *binary); GLAPI PFNGLGETPROGRAMBINARYPROC glad_glGetProgramBinary; #define glGetProgramBinary glad_glGetProgramBinary -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC)(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void(APIENTRYP PFNGLPROGRAMBINARYPROC)(GLuint program, + GLenum binaryFormat, + const void *binary, + GLsizei length); GLAPI PFNGLPROGRAMBINARYPROC glad_glProgramBinary; #define glProgramBinary glad_glProgramBinary -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC)(GLuint program, GLenum pname, GLint value); +typedef void(APIENTRYP PFNGLPROGRAMPARAMETERIPROC)(GLuint program, GLenum pname, + GLint value); GLAPI PFNGLPROGRAMPARAMETERIPROC glad_glProgramParameteri; #define glProgramParameteri glad_glProgramParameteri -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, GLbitfield stages, GLuint program); +typedef void(APIENTRYP PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, + GLbitfield stages, + GLuint program); GLAPI PFNGLUSEPROGRAMSTAGESPROC glad_glUseProgramStages; #define glUseProgramStages glad_glUseProgramStages -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, GLuint program); +typedef void(APIENTRYP PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, + GLuint program); GLAPI PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram; #define glActiveShaderProgram glad_glActiveShaderProgram -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC)(GLenum type, GLsizei count, const GLchar *const*strings); +typedef GLuint(APIENTRYP PFNGLCREATESHADERPROGRAMVPROC)( + GLenum type, GLsizei count, const GLchar *const *strings); GLAPI PFNGLCREATESHADERPROGRAMVPROC glad_glCreateShaderProgramv; #define glCreateShaderProgramv glad_glCreateShaderProgramv -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline); +typedef void(APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline); GLAPI PFNGLBINDPROGRAMPIPELINEPROC glad_glBindProgramPipeline; #define glBindProgramPipeline glad_glBindProgramPipeline -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC)(GLsizei n, const GLuint *pipelines); +typedef void(APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC)( + GLsizei n, const GLuint *pipelines); GLAPI PFNGLDELETEPROGRAMPIPELINESPROC glad_glDeleteProgramPipelines; #define glDeleteProgramPipelines glad_glDeleteProgramPipelines -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, GLuint *pipelines); +typedef void(APIENTRYP PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, + GLuint *pipelines); GLAPI PFNGLGENPROGRAMPIPELINESPROC glad_glGenProgramPipelines; #define glGenProgramPipelines glad_glGenProgramPipelines -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline); +typedef GLboolean(APIENTRYP PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline); GLAPI PFNGLISPROGRAMPIPELINEPROC glad_glIsProgramPipeline; #define glIsProgramPipeline glad_glIsProgramPipeline -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, + GLenum pname, + GLint *params); GLAPI PFNGLGETPROGRAMPIPELINEIVPROC glad_glGetProgramPipelineiv; #define glGetProgramPipelineiv glad_glGetProgramPipelineiv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, GLint location, GLint v0); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, + GLint location, GLint v0); GLAPI PFNGLPROGRAMUNIFORM1IPROC glad_glProgramUniform1i; #define glProgramUniform1i glad_glProgramUniform1i -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLint *value); GLAPI PFNGLPROGRAMUNIFORM1IVPROC glad_glProgramUniform1iv; #define glProgramUniform1iv glad_glProgramUniform1iv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, GLint location, GLfloat v0); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, + GLint location, GLfloat v0); GLAPI PFNGLPROGRAMUNIFORM1FPROC glad_glProgramUniform1f; #define glProgramUniform1f glad_glProgramUniform1f -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORM1FVPROC glad_glProgramUniform1fv; #define glProgramUniform1fv glad_glProgramUniform1fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC)(GLuint program, GLint location, GLdouble v0); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1DPROC)(GLuint program, + GLint location, GLdouble v0); GLAPI PFNGLPROGRAMUNIFORM1DPROC glad_glProgramUniform1d; #define glProgramUniform1d glad_glProgramUniform1d -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORM1DVPROC glad_glProgramUniform1dv; #define glProgramUniform1dv glad_glProgramUniform1dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, GLint location, GLuint v0); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, + GLint location, GLuint v0); GLAPI PFNGLPROGRAMUNIFORM1UIPROC glad_glProgramUniform1ui; #define glProgramUniform1ui glad_glProgramUniform1ui -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLuint *value); GLAPI PFNGLPROGRAMUNIFORM1UIVPROC glad_glProgramUniform1uiv; #define glProgramUniform1uiv glad_glProgramUniform1uiv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, GLint location, GLint v0, GLint v1); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, + GLint location, GLint v0, + GLint v1); GLAPI PFNGLPROGRAMUNIFORM2IPROC glad_glProgramUniform2i; #define glProgramUniform2i glad_glProgramUniform2i -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLint *value); GLAPI PFNGLPROGRAMUNIFORM2IVPROC glad_glProgramUniform2iv; #define glProgramUniform2iv glad_glProgramUniform2iv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, + GLint location, GLfloat v0, + GLfloat v1); GLAPI PFNGLPROGRAMUNIFORM2FPROC glad_glProgramUniform2f; #define glProgramUniform2f glad_glProgramUniform2f -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORM2FVPROC glad_glProgramUniform2fv; #define glProgramUniform2fv glad_glProgramUniform2fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2DPROC)(GLuint program, + GLint location, GLdouble v0, + GLdouble v1); GLAPI PFNGLPROGRAMUNIFORM2DPROC glad_glProgramUniform2d; #define glProgramUniform2d glad_glProgramUniform2d -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORM2DVPROC glad_glProgramUniform2dv; #define glProgramUniform2dv glad_glProgramUniform2dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, + GLint location, GLuint v0, + GLuint v1); GLAPI PFNGLPROGRAMUNIFORM2UIPROC glad_glProgramUniform2ui; #define glProgramUniform2ui glad_glProgramUniform2ui -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLuint *value); GLAPI PFNGLPROGRAMUNIFORM2UIVPROC glad_glProgramUniform2uiv; #define glProgramUniform2uiv glad_glProgramUniform2uiv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, + GLint location, GLint v0, + GLint v1, GLint v2); GLAPI PFNGLPROGRAMUNIFORM3IPROC glad_glProgramUniform3i; #define glProgramUniform3i glad_glProgramUniform3i -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLint *value); GLAPI PFNGLPROGRAMUNIFORM3IVPROC glad_glProgramUniform3iv; #define glProgramUniform3iv glad_glProgramUniform3iv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, + GLint location, GLfloat v0, + GLfloat v1, GLfloat v2); GLAPI PFNGLPROGRAMUNIFORM3FPROC glad_glProgramUniform3f; #define glProgramUniform3f glad_glProgramUniform3f -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORM3FVPROC glad_glProgramUniform3fv; #define glProgramUniform3fv glad_glProgramUniform3fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3DPROC)(GLuint program, + GLint location, GLdouble v0, + GLdouble v1, GLdouble v2); GLAPI PFNGLPROGRAMUNIFORM3DPROC glad_glProgramUniform3d; #define glProgramUniform3d glad_glProgramUniform3d -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORM3DVPROC glad_glProgramUniform3dv; #define glProgramUniform3dv glad_glProgramUniform3dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, + GLint location, GLuint v0, + GLuint v1, GLuint v2); GLAPI PFNGLPROGRAMUNIFORM3UIPROC glad_glProgramUniform3ui; #define glProgramUniform3ui glad_glProgramUniform3ui -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLuint *value); GLAPI PFNGLPROGRAMUNIFORM3UIVPROC glad_glProgramUniform3uiv; #define glProgramUniform3uiv glad_glProgramUniform3uiv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, + GLint location, GLint v0, + GLint v1, GLint v2, GLint v3); GLAPI PFNGLPROGRAMUNIFORM4IPROC glad_glProgramUniform4i; #define glProgramUniform4i glad_glProgramUniform4i -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLint *value); GLAPI PFNGLPROGRAMUNIFORM4IVPROC glad_glProgramUniform4iv; #define glProgramUniform4iv glad_glProgramUniform4iv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, + GLint location, GLfloat v0, + GLfloat v1, GLfloat v2, + GLfloat v3); GLAPI PFNGLPROGRAMUNIFORM4FPROC glad_glProgramUniform4f; #define glProgramUniform4f glad_glProgramUniform4f -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORM4FVPROC glad_glProgramUniform4fv; #define glProgramUniform4fv glad_glProgramUniform4fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4DPROC)(GLuint program, + GLint location, GLdouble v0, + GLdouble v1, GLdouble v2, + GLdouble v3); GLAPI PFNGLPROGRAMUNIFORM4DPROC glad_glProgramUniform4d; #define glProgramUniform4d glad_glProgramUniform4d -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORM4DVPROC glad_glProgramUniform4dv; #define glProgramUniform4dv glad_glProgramUniform4dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, + GLint location, GLuint v0, + GLuint v1, GLuint v2, + GLuint v3); GLAPI PFNGLPROGRAMUNIFORM4UIPROC glad_glProgramUniform4ui; #define glProgramUniform4ui glad_glProgramUniform4ui -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, + GLint location, + GLsizei count, + const GLuint *value); GLAPI PFNGLPROGRAMUNIFORM4UIVPROC glad_glProgramUniform4uiv; #define glProgramUniform4uiv glad_glProgramUniform4uiv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC)(GLuint program, + GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_glProgramUniformMatrix2fv; #define glProgramUniformMatrix2fv glad_glProgramUniformMatrix2fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC)(GLuint program, + GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_glProgramUniformMatrix3fv; #define glProgramUniformMatrix3fv glad_glProgramUniformMatrix3fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC)(GLuint program, + GLint location, + GLsizei count, + GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_glProgramUniformMatrix4fv; #define glProgramUniformMatrix4fv glad_glProgramUniformMatrix4fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC)(GLuint program, + GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_glProgramUniformMatrix2dv; #define glProgramUniformMatrix2dv glad_glProgramUniformMatrix2dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC)(GLuint program, + GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_glProgramUniformMatrix3dv; #define glProgramUniformMatrix3dv glad_glProgramUniformMatrix3dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC)(GLuint program, + GLint location, + GLsizei count, + GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_glProgramUniformMatrix4dv; #define glProgramUniformMatrix4dv glad_glProgramUniformMatrix4dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_glProgramUniformMatrix2x3fv; #define glProgramUniformMatrix2x3fv glad_glProgramUniformMatrix2x3fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_glProgramUniformMatrix3x2fv; #define glProgramUniformMatrix3x2fv glad_glProgramUniformMatrix3x2fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_glProgramUniformMatrix2x4fv; #define glProgramUniformMatrix2x4fv glad_glProgramUniformMatrix2x4fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_glProgramUniformMatrix4x2fv; #define glProgramUniformMatrix4x2fv glad_glProgramUniformMatrix4x2fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_glProgramUniformMatrix3x4fv; #define glProgramUniformMatrix3x4fv glad_glProgramUniformMatrix3x4fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_glProgramUniformMatrix4x3fv; #define glProgramUniformMatrix4x3fv glad_glProgramUniformMatrix4x3fv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_glProgramUniformMatrix2x3dv; #define glProgramUniformMatrix2x3dv glad_glProgramUniformMatrix2x3dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_glProgramUniformMatrix3x2dv; #define glProgramUniformMatrix3x2dv glad_glProgramUniformMatrix3x2dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_glProgramUniformMatrix2x4dv; #define glProgramUniformMatrix2x4dv glad_glProgramUniformMatrix2x4dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_glProgramUniformMatrix4x2dv; #define glProgramUniformMatrix4x2dv glad_glProgramUniformMatrix4x2dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_glProgramUniformMatrix3x4dv; #define glProgramUniformMatrix3x4dv glad_glProgramUniformMatrix3x4dv -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void(APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)( + GLuint program, GLint location, GLsizei count, GLboolean transpose, + const GLdouble *value); GLAPI PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_glProgramUniformMatrix4x3dv; #define glProgramUniformMatrix4x3dv glad_glProgramUniformMatrix4x3dv -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline); +typedef void(APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline); GLAPI PFNGLVALIDATEPROGRAMPIPELINEPROC glad_glValidateProgramPipeline; #define glValidateProgramPipeline glad_glValidateProgramPipeline -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void(APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, + GLsizei bufSize, + GLsizei *length, + GLchar *infoLog); GLAPI PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_glGetProgramPipelineInfoLog; #define glGetProgramPipelineInfoLog glad_glGetProgramPipelineInfoLog -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC)(GLuint index, GLdouble x); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL1DPROC)(GLuint index, GLdouble x); GLAPI PFNGLVERTEXATTRIBL1DPROC glad_glVertexAttribL1d; #define glVertexAttribL1d glad_glVertexAttribL1d -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL2DPROC)(GLuint index, GLdouble x, + GLdouble y); GLAPI PFNGLVERTEXATTRIBL2DPROC glad_glVertexAttribL2d; #define glVertexAttribL2d glad_glVertexAttribL2d -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL3DPROC)(GLuint index, GLdouble x, + GLdouble y, GLdouble z); GLAPI PFNGLVERTEXATTRIBL3DPROC glad_glVertexAttribL3d; #define glVertexAttribL3d glad_glVertexAttribL3d -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL4DPROC)(GLuint index, GLdouble x, + GLdouble y, GLdouble z, + GLdouble w); GLAPI PFNGLVERTEXATTRIBL4DPROC glad_glVertexAttribL4d; #define glVertexAttribL4d glad_glVertexAttribL4d -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL1DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIBL1DVPROC glad_glVertexAttribL1dv; #define glVertexAttribL1dv glad_glVertexAttribL1dv -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL2DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIBL2DVPROC glad_glVertexAttribL2dv; #define glVertexAttribL2dv glad_glVertexAttribL2dv -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL3DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIBL3DVPROC glad_glVertexAttribL3dv; #define glVertexAttribL3dv glad_glVertexAttribL3dv -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC)(GLuint index, const GLdouble *v); +typedef void(APIENTRYP PFNGLVERTEXATTRIBL4DVPROC)(GLuint index, + const GLdouble *v); GLAPI PFNGLVERTEXATTRIBL4DVPROC glad_glVertexAttribL4dv; #define glVertexAttribL4dv glad_glVertexAttribL4dv -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void(APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC)(GLuint index, GLint size, + GLenum type, + GLsizei stride, + const void *pointer); GLAPI PFNGLVERTEXATTRIBLPOINTERPROC glad_glVertexAttribLPointer; #define glVertexAttribLPointer glad_glVertexAttribLPointer -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC)(GLuint index, GLenum pname, GLdouble *params); +typedef void(APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC)(GLuint index, GLenum pname, + GLdouble *params); GLAPI PFNGLGETVERTEXATTRIBLDVPROC glad_glGetVertexAttribLdv; #define glGetVertexAttribLdv glad_glGetVertexAttribLdv -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC)(GLuint first, GLsizei count, const GLfloat *v); +typedef void(APIENTRYP PFNGLVIEWPORTARRAYVPROC)(GLuint first, GLsizei count, + const GLfloat *v); GLAPI PFNGLVIEWPORTARRAYVPROC glad_glViewportArrayv; #define glViewportArrayv glad_glViewportArrayv -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void(APIENTRYP PFNGLVIEWPORTINDEXEDFPROC)(GLuint index, GLfloat x, + GLfloat y, GLfloat w, + GLfloat h); GLAPI PFNGLVIEWPORTINDEXEDFPROC glad_glViewportIndexedf; #define glViewportIndexedf glad_glViewportIndexedf -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC)(GLuint index, const GLfloat *v); +typedef void(APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC)(GLuint index, + const GLfloat *v); GLAPI PFNGLVIEWPORTINDEXEDFVPROC glad_glViewportIndexedfv; #define glViewportIndexedfv glad_glViewportIndexedfv -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC)(GLuint first, GLsizei count, const GLint *v); +typedef void(APIENTRYP PFNGLSCISSORARRAYVPROC)(GLuint first, GLsizei count, + const GLint *v); GLAPI PFNGLSCISSORARRAYVPROC glad_glScissorArrayv; #define glScissorArrayv glad_glScissorArrayv -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLSCISSORINDEXEDPROC)(GLuint index, GLint left, + GLint bottom, GLsizei width, + GLsizei height); GLAPI PFNGLSCISSORINDEXEDPROC glad_glScissorIndexed; #define glScissorIndexed glad_glScissorIndexed -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC)(GLuint index, const GLint *v); +typedef void(APIENTRYP PFNGLSCISSORINDEXEDVPROC)(GLuint index, const GLint *v); GLAPI PFNGLSCISSORINDEXEDVPROC glad_glScissorIndexedv; #define glScissorIndexedv glad_glScissorIndexedv -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC)(GLuint first, GLsizei count, const GLdouble *v); +typedef void(APIENTRYP PFNGLDEPTHRANGEARRAYVPROC)(GLuint first, GLsizei count, + const GLdouble *v); GLAPI PFNGLDEPTHRANGEARRAYVPROC glad_glDepthRangeArrayv; #define glDepthRangeArrayv glad_glDepthRangeArrayv -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC)(GLuint index, GLdouble n, GLdouble f); +typedef void(APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC)(GLuint index, GLdouble n, + GLdouble f); GLAPI PFNGLDEPTHRANGEINDEXEDPROC glad_glDepthRangeIndexed; #define glDepthRangeIndexed glad_glDepthRangeIndexed -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC)(GLenum target, GLuint index, GLfloat *data); +typedef void(APIENTRYP PFNGLGETFLOATI_VPROC)(GLenum target, GLuint index, + GLfloat *data); GLAPI PFNGLGETFLOATI_VPROC glad_glGetFloati_v; #define glGetFloati_v glad_glGetFloati_v -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC)(GLenum target, GLuint index, GLdouble *data); +typedef void(APIENTRYP PFNGLGETDOUBLEI_VPROC)(GLenum target, GLuint index, + GLdouble *data); GLAPI PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v; #define glGetDoublei_v glad_glGetDoublei_v #endif #ifndef GL_VERSION_4_2 #define GL_VERSION_4_2 1 GLAPI int GLAD_GL_VERSION_4_2; -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -GLAPI PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_glDrawArraysInstancedBaseInstance; +typedef void(APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)( + GLenum mode, GLint first, GLsizei count, GLsizei instancecount, + GLuint baseinstance); +GLAPI PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC + glad_glDrawArraysInstancedBaseInstance; #define glDrawArraysInstancedBaseInstance glad_glDrawArraysInstancedBaseInstance -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_glDrawElementsInstancedBaseInstance; -#define glDrawElementsInstancedBaseInstance glad_glDrawElementsInstancedBaseInstance -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance; -#define glDrawElementsInstancedBaseVertexBaseInstance glad_glDrawElementsInstancedBaseVertexBaseInstance -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +typedef void(APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)( + GLenum mode, GLsizei count, GLenum type, const void *indices, + GLsizei instancecount, GLuint baseinstance); +GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC + glad_glDrawElementsInstancedBaseInstance; +#define glDrawElementsInstancedBaseInstance \ + glad_glDrawElementsInstancedBaseInstance +typedef void(APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)( + GLenum mode, GLsizei count, GLenum type, const void *indices, + GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC + glad_glDrawElementsInstancedBaseVertexBaseInstance; +#define glDrawElementsInstancedBaseVertexBaseInstance \ + glad_glDrawElementsInstancedBaseVertexBaseInstance +typedef void(APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, + GLenum internalformat, + GLenum pname, + GLsizei count, + GLint *params); GLAPI PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ; #define glGetInternalformativ glad_glGetInternalformativ -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)(GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -GLAPI PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_glGetActiveAtomicCounterBufferiv; +typedef void(APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)( + GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC + glad_glGetActiveAtomicCounterBufferiv; #define glGetActiveAtomicCounterBufferiv glad_glGetActiveAtomicCounterBufferiv -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void(APIENTRYP PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, GLuint texture, + GLint level, + GLboolean layered, + GLint layer, GLenum access, + GLenum format); GLAPI PFNGLBINDIMAGETEXTUREPROC glad_glBindImageTexture; #define glBindImageTexture glad_glBindImageTexture -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC)(GLbitfield barriers); +typedef void(APIENTRYP PFNGLMEMORYBARRIERPROC)(GLbitfield barriers); GLAPI PFNGLMEMORYBARRIERPROC glad_glMemoryBarrier; #define glMemoryBarrier glad_glMemoryBarrier -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void(APIENTRYP PFNGLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, + GLenum internalformat, + GLsizei width); GLAPI PFNGLTEXSTORAGE1DPROC glad_glTexStorage1D; #define glTexStorage1D glad_glTexStorage1D -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, + GLenum internalformat, + GLsizei width, GLsizei height); GLAPI PFNGLTEXSTORAGE2DPROC glad_glTexStorage2D; #define glTexStorage2D glad_glTexStorage2D -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void(APIENTRYP PFNGLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, + GLenum internalformat, + GLsizei width, GLsizei height, + GLsizei depth); GLAPI PFNGLTEXSTORAGE3DPROC glad_glTexStorage3D; #define glTexStorage3D glad_glTexStorage3D -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)(GLenum mode, GLuint id, GLsizei instancecount); -GLAPI PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_glDrawTransformFeedbackInstanced; +typedef void(APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)( + GLenum mode, GLuint id, GLsizei instancecount); +GLAPI PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC + glad_glDrawTransformFeedbackInstanced; #define glDrawTransformFeedbackInstanced glad_glDrawTransformFeedbackInstanced -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)(GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -GLAPI PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_glDrawTransformFeedbackStreamInstanced; -#define glDrawTransformFeedbackStreamInstanced glad_glDrawTransformFeedbackStreamInstanced +typedef void(APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)( + GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +GLAPI PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC + glad_glDrawTransformFeedbackStreamInstanced; +#define glDrawTransformFeedbackStreamInstanced \ + glad_glDrawTransformFeedbackStreamInstanced #endif #ifndef GL_VERSION_4_3 #define GL_VERSION_4_3 1 GLAPI int GLAD_GL_VERSION_4_3; -typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC)(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void(APIENTRYP PFNGLCLEARBUFFERDATAPROC)(GLenum target, + GLenum internalformat, + GLenum format, GLenum type, + const void *data); GLAPI PFNGLCLEARBUFFERDATAPROC glad_glClearBufferData; #define glClearBufferData glad_glClearBufferData -typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC)(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void(APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC)( + GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, + GLenum format, GLenum type, const void *data); GLAPI PFNGLCLEARBUFFERSUBDATAPROC glad_glClearBufferSubData; #define glClearBufferSubData glad_glClearBufferSubData -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void(APIENTRYP PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, + GLuint num_groups_y, + GLuint num_groups_z); GLAPI PFNGLDISPATCHCOMPUTEPROC glad_glDispatchCompute; #define glDispatchCompute glad_glDispatchCompute -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); +typedef void(APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); GLAPI PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_glDispatchComputeIndirect; #define glDispatchComputeIndirect glad_glDispatchComputeIndirect -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void(APIENTRYP PFNGLCOPYIMAGESUBDATAPROC)( + GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, + GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, + GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, + GLsizei srcDepth); GLAPI PFNGLCOPYIMAGESUBDATAPROC glad_glCopyImageSubData; #define glCopyImageSubData glad_glCopyImageSubData -typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, + GLenum pname, + GLint param); GLAPI PFNGLFRAMEBUFFERPARAMETERIPROC glad_glFramebufferParameteri; #define glFramebufferParameteri glad_glFramebufferParameteri -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, + GLenum pname, + GLint *params); GLAPI PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv; #define glGetFramebufferParameteriv glad_glGetFramebufferParameteriv -typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); +typedef void(APIENTRYP PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, + GLenum internalformat, + GLenum pname, + GLsizei count, + GLint64 *params); GLAPI PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v; #define glGetInternalformati64v glad_glGetInternalformati64v -typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void(APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth); GLAPI PFNGLINVALIDATETEXSUBIMAGEPROC glad_glInvalidateTexSubImage; #define glInvalidateTexSubImage glad_glInvalidateTexSubImage -typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC)(GLuint texture, GLint level); +typedef void(APIENTRYP PFNGLINVALIDATETEXIMAGEPROC)(GLuint texture, + GLint level); GLAPI PFNGLINVALIDATETEXIMAGEPROC glad_glInvalidateTexImage; #define glInvalidateTexImage glad_glInvalidateTexImage -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void(APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC)(GLuint buffer, + GLintptr offset, + GLsizeiptr length); GLAPI PFNGLINVALIDATEBUFFERSUBDATAPROC glad_glInvalidateBufferSubData; #define glInvalidateBufferSubData glad_glInvalidateBufferSubData -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer); +typedef void(APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer); GLAPI PFNGLINVALIDATEBUFFERDATAPROC glad_glInvalidateBufferData; #define glInvalidateBufferData glad_glInvalidateBufferData -typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void(APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC)( + GLenum target, GLsizei numAttachments, const GLenum *attachments); GLAPI PFNGLINVALIDATEFRAMEBUFFERPROC glad_glInvalidateFramebuffer; #define glInvalidateFramebuffer glad_glInvalidateFramebuffer -typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC)( + GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, + GLint y, GLsizei width, GLsizei height); GLAPI PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_glInvalidateSubFramebuffer; #define glInvalidateSubFramebuffer glad_glInvalidateSubFramebuffer -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC)(GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void(APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC)(GLenum mode, + const void *indirect, + GLsizei drawcount, + GLsizei stride); GLAPI PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_glMultiDrawArraysIndirect; #define glMultiDrawArraysIndirect glad_glMultiDrawArraysIndirect -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void(APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC)(GLenum mode, + GLenum type, + const void *indirect, + GLsizei drawcount, + GLsizei stride); GLAPI PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_glMultiDrawElementsIndirect; #define glMultiDrawElementsIndirect glad_glMultiDrawElementsIndirect -typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC)(GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC)(GLuint program, + GLenum programInterface, + GLenum pname, + GLint *params); GLAPI PFNGLGETPROGRAMINTERFACEIVPROC glad_glGetProgramInterfaceiv; #define glGetProgramInterfaceiv glad_glGetProgramInterfaceiv -typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC)(GLuint program, GLenum programInterface, const GLchar *name); +typedef GLuint(APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC)( + GLuint program, GLenum programInterface, const GLchar *name); GLAPI PFNGLGETPROGRAMRESOURCEINDEXPROC glad_glGetProgramResourceIndex; #define glGetProgramResourceIndex glad_glGetProgramResourceIndex -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void(APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC)( + GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, + GLsizei *length, GLchar *name); GLAPI PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName; #define glGetProgramResourceName glad_glGetProgramResourceName -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); +typedef void(APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC)( + GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, + const GLenum *props, GLsizei count, GLsizei *length, GLint *params); GLAPI PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv; #define glGetProgramResourceiv glad_glGetProgramResourceiv -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC)(GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint(APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC)( + GLuint program, GLenum programInterface, const GLchar *name); GLAPI PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_glGetProgramResourceLocation; #define glGetProgramResourceLocation glad_glGetProgramResourceLocation -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)(GLuint program, GLenum programInterface, const GLchar *name); -GLAPI PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_glGetProgramResourceLocationIndex; +typedef GLint(APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)( + GLuint program, GLenum programInterface, const GLchar *name); +GLAPI PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC + glad_glGetProgramResourceLocationIndex; #define glGetProgramResourceLocationIndex glad_glGetProgramResourceLocationIndex -typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void(APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC)( + GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); GLAPI PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_glShaderStorageBlockBinding; #define glShaderStorageBlockBinding glad_glShaderStorageBlockBinding -typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void(APIENTRYP PFNGLTEXBUFFERRANGEPROC)(GLenum target, + GLenum internalformat, + GLuint buffer, GLintptr offset, + GLsizeiptr size); GLAPI PFNGLTEXBUFFERRANGEPROC glad_glTexBufferRange; #define glTexBufferRange glad_glTexBufferRange -typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void(APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC)( + GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height, GLboolean fixedsamplelocations); GLAPI PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_glTexStorage2DMultisample; #define glTexStorage2DMultisample glad_glTexStorage2DMultisample -typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void(APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC)( + GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample; #define glTexStorage3DMultisample glad_glTexStorage3DMultisample -typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void(APIENTRYP PFNGLTEXTUREVIEWPROC)(GLuint texture, GLenum target, + GLuint origtexture, + GLenum internalformat, + GLuint minlevel, GLuint numlevels, + GLuint minlayer, GLuint numlayers); GLAPI PFNGLTEXTUREVIEWPROC glad_glTextureView; #define glTextureView glad_glTextureView -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void(APIENTRYP PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, + GLuint buffer, + GLintptr offset, + GLsizei stride); GLAPI PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer; #define glBindVertexBuffer glad_glBindVertexBuffer -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void(APIENTRYP PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, + GLint size, GLenum type, + GLboolean normalized, + GLuint relativeoffset); GLAPI PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat; #define glVertexAttribFormat glad_glVertexAttribFormat -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void(APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, + GLint size, GLenum type, + GLuint relativeoffset); GLAPI PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat; #define glVertexAttribIFormat glad_glVertexAttribIFormat -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void(APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, + GLint size, GLenum type, + GLuint relativeoffset); GLAPI PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat; #define glVertexAttribLFormat glad_glVertexAttribLFormat -typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, GLuint bindingindex); +typedef void(APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, + GLuint bindingindex); GLAPI PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding; #define glVertexAttribBinding glad_glVertexAttribBinding -typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLuint divisor); +typedef void(APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, + GLuint divisor); GLAPI PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor; #define glVertexBindingDivisor glad_glVertexBindingDivisor -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void(APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, + GLenum severity, + GLsizei count, + const GLuint *ids, + GLboolean enabled); GLAPI PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl; #define glDebugMessageControl glad_glDebugMessageControl -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void(APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, + GLuint id, GLenum severity, + GLsizei length, + const GLchar *buf); GLAPI PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert; #define glDebugMessageInsert glad_glDebugMessageInsert -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void *userParam); +typedef void(APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, + const void *userParam); GLAPI PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback; #define glDebugMessageCallback glad_glDebugMessageCallback -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef GLuint(APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC)( + GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, + GLenum *severities, GLsizei *lengths, GLchar *messageLog); GLAPI PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog; #define glGetDebugMessageLog glad_glGetDebugMessageLog -typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void(APIENTRYP PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, + GLsizei length, + const GLchar *message); GLAPI PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup; #define glPushDebugGroup glad_glPushDebugGroup -typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC)(void); +typedef void(APIENTRYP PFNGLPOPDEBUGGROUPPROC)(void); GLAPI PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup; #define glPopDebugGroup glad_glPopDebugGroup -typedef void (APIENTRYP PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void(APIENTRYP PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, + GLsizei length, + const GLchar *label); GLAPI PFNGLOBJECTLABELPROC glad_glObjectLabel; #define glObjectLabel glad_glObjectLabel -typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void(APIENTRYP PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, + GLsizei bufSize, + GLsizei *length, GLchar *label); GLAPI PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel; #define glGetObjectLabel glad_glGetObjectLabel -typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC)(const void *ptr, GLsizei length, const GLchar *label); +typedef void(APIENTRYP PFNGLOBJECTPTRLABELPROC)(const void *ptr, GLsizei length, + const GLchar *label); GLAPI PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel; #define glObjectPtrLabel glad_glObjectPtrLabel -typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC)(const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void(APIENTRYP PFNGLGETOBJECTPTRLABELPROC)(const void *ptr, + GLsizei bufSize, + GLsizei *length, + GLchar *label); GLAPI PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel; #define glGetObjectPtrLabel glad_glGetObjectPtrLabel #endif #ifndef GL_VERSION_4_4 #define GL_VERSION_4_4 1 GLAPI int GLAD_GL_VERSION_4_4; -typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void(APIENTRYP PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, + const void *data, + GLbitfield flags); GLAPI PFNGLBUFFERSTORAGEPROC glad_glBufferStorage; #define glBufferStorage glad_glBufferStorage -typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void(APIENTRYP PFNGLCLEARTEXIMAGEPROC)(GLuint texture, GLint level, + GLenum format, GLenum type, + const void *data); GLAPI PFNGLCLEARTEXIMAGEPROC glad_glClearTexImage; #define glClearTexImage glad_glClearTexImage -typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void(APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC)(GLuint texture, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const void *data); GLAPI PFNGLCLEARTEXSUBIMAGEPROC glad_glClearTexSubImage; #define glClearTexSubImage glad_glClearTexSubImage -typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void(APIENTRYP PFNGLBINDBUFFERSBASEPROC)(GLenum target, GLuint first, + GLsizei count, + const GLuint *buffers); GLAPI PFNGLBINDBUFFERSBASEPROC glad_glBindBuffersBase; #define glBindBuffersBase glad_glBindBuffersBase -typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void(APIENTRYP PFNGLBINDBUFFERSRANGEPROC)(GLenum target, GLuint first, + GLsizei count, + const GLuint *buffers, + const GLintptr *offsets, + const GLsizeiptr *sizes); GLAPI PFNGLBINDBUFFERSRANGEPROC glad_glBindBuffersRange; #define glBindBuffersRange glad_glBindBuffersRange -typedef void (APIENTRYP PFNGLBINDTEXTURESPROC)(GLuint first, GLsizei count, const GLuint *textures); +typedef void(APIENTRYP PFNGLBINDTEXTURESPROC)(GLuint first, GLsizei count, + const GLuint *textures); GLAPI PFNGLBINDTEXTURESPROC glad_glBindTextures; #define glBindTextures glad_glBindTextures -typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC)(GLuint first, GLsizei count, const GLuint *samplers); +typedef void(APIENTRYP PFNGLBINDSAMPLERSPROC)(GLuint first, GLsizei count, + const GLuint *samplers); GLAPI PFNGLBINDSAMPLERSPROC glad_glBindSamplers; #define glBindSamplers glad_glBindSamplers -typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC)(GLuint first, GLsizei count, const GLuint *textures); +typedef void(APIENTRYP PFNGLBINDIMAGETEXTURESPROC)(GLuint first, GLsizei count, + const GLuint *textures); GLAPI PFNGLBINDIMAGETEXTURESPROC glad_glBindImageTextures; #define glBindImageTextures glad_glBindImageTextures -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC)(GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void(APIENTRYP PFNGLBINDVERTEXBUFFERSPROC)(GLuint first, GLsizei count, + const GLuint *buffers, + const GLintptr *offsets, + const GLsizei *strides); GLAPI PFNGLBINDVERTEXBUFFERSPROC glad_glBindVertexBuffers; #define glBindVertexBuffers glad_glBindVertexBuffers #endif #ifndef GL_VERSION_4_5 #define GL_VERSION_4_5 1 GLAPI int GLAD_GL_VERSION_4_5; -typedef void (APIENTRYP PFNGLCLIPCONTROLPROC)(GLenum origin, GLenum depth); +typedef void(APIENTRYP PFNGLCLIPCONTROLPROC)(GLenum origin, GLenum depth); GLAPI PFNGLCLIPCONTROLPROC glad_glClipControl; #define glClipControl glad_glClipControl -typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint *ids); +typedef void(APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC)(GLsizei n, + GLuint *ids); GLAPI PFNGLCREATETRANSFORMFEEDBACKSPROC glad_glCreateTransformFeedbacks; #define glCreateTransformFeedbacks glad_glCreateTransformFeedbacks -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC)(GLuint xfb, GLuint index, GLuint buffer); +typedef void(APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC)(GLuint xfb, + GLuint index, + GLuint buffer); GLAPI PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC glad_glTransformFeedbackBufferBase; #define glTransformFeedbackBufferBase glad_glTransformFeedbackBufferBase -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC)(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void(APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC)( + GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC glad_glTransformFeedbackBufferRange; #define glTransformFeedbackBufferRange glad_glTransformFeedbackBufferRange -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC)(GLuint xfb, GLenum pname, GLint *param); +typedef void(APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC)(GLuint xfb, + GLenum pname, + GLint *param); GLAPI PFNGLGETTRANSFORMFEEDBACKIVPROC glad_glGetTransformFeedbackiv; #define glGetTransformFeedbackiv glad_glGetTransformFeedbackiv -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC)(GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void(APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC)(GLuint xfb, + GLenum pname, + GLuint index, + GLint *param); GLAPI PFNGLGETTRANSFORMFEEDBACKI_VPROC glad_glGetTransformFeedbacki_v; #define glGetTransformFeedbacki_v glad_glGetTransformFeedbacki_v -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC)(GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void(APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC)(GLuint xfb, + GLenum pname, + GLuint index, + GLint64 *param); GLAPI PFNGLGETTRANSFORMFEEDBACKI64_VPROC glad_glGetTransformFeedbacki64_v; #define glGetTransformFeedbacki64_v glad_glGetTransformFeedbacki64_v -typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC)(GLsizei n, GLuint *buffers); +typedef void(APIENTRYP PFNGLCREATEBUFFERSPROC)(GLsizei n, GLuint *buffers); GLAPI PFNGLCREATEBUFFERSPROC glad_glCreateBuffers; #define glCreateBuffers glad_glCreateBuffers -typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC)(GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void(APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC)(GLuint buffer, + GLsizeiptr size, + const void *data, + GLbitfield flags); GLAPI PFNGLNAMEDBUFFERSTORAGEPROC glad_glNamedBufferStorage; #define glNamedBufferStorage glad_glNamedBufferStorage -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC)(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void(APIENTRYP PFNGLNAMEDBUFFERDATAPROC)(GLuint buffer, GLsizeiptr size, + const void *data, + GLenum usage); GLAPI PFNGLNAMEDBUFFERDATAPROC glad_glNamedBufferData; #define glNamedBufferData glad_glNamedBufferData -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void(APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC)(GLuint buffer, + GLintptr offset, + GLsizeiptr size, + const void *data); GLAPI PFNGLNAMEDBUFFERSUBDATAPROC glad_glNamedBufferSubData; #define glNamedBufferSubData glad_glNamedBufferSubData -typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC)(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void(APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC)(GLuint readBuffer, + GLuint writeBuffer, + GLintptr readOffset, + GLintptr writeOffset, + GLsizeiptr size); GLAPI PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_glCopyNamedBufferSubData; #define glCopyNamedBufferSubData glad_glCopyNamedBufferSubData -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC)(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void(APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC)(GLuint buffer, + GLenum internalformat, + GLenum format, + GLenum type, + const void *data); GLAPI PFNGLCLEARNAMEDBUFFERDATAPROC glad_glClearNamedBufferData; #define glClearNamedBufferData glad_glClearNamedBufferData -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void(APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC)( + GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, + GLenum format, GLenum type, const void *data); GLAPI PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_glClearNamedBufferSubData; #define glClearNamedBufferSubData glad_glClearNamedBufferSubData -typedef void * (APIENTRYP PFNGLMAPNAMEDBUFFERPROC)(GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC)(GLuint buffer, GLenum access); GLAPI PFNGLMAPNAMEDBUFFERPROC glad_glMapNamedBuffer; #define glMapNamedBuffer glad_glMapNamedBuffer -typedef void * (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC)(GLuint buffer, + GLintptr offset, + GLsizeiptr length, + GLbitfield access); GLAPI PFNGLMAPNAMEDBUFFERRANGEPROC glad_glMapNamedBufferRange; #define glMapNamedBufferRange glad_glMapNamedBufferRange -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC)(GLuint buffer); +typedef GLboolean(APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC)(GLuint buffer); GLAPI PFNGLUNMAPNAMEDBUFFERPROC glad_glUnmapNamedBuffer; #define glUnmapNamedBuffer glad_glUnmapNamedBuffer -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void(APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC)(GLuint buffer, + GLintptr offset, + GLsizeiptr length); GLAPI PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_glFlushMappedNamedBufferRange; #define glFlushMappedNamedBufferRange glad_glFlushMappedNamedBufferRange -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC)(GLuint buffer, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC)(GLuint buffer, + GLenum pname, + GLint *params); GLAPI PFNGLGETNAMEDBUFFERPARAMETERIVPROC glad_glGetNamedBufferParameteriv; #define glGetNamedBufferParameteriv glad_glGetNamedBufferParameteriv -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC)(GLuint buffer, GLenum pname, GLint64 *params); +typedef void(APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC)(GLuint buffer, + GLenum pname, + GLint64 *params); GLAPI PFNGLGETNAMEDBUFFERPARAMETERI64VPROC glad_glGetNamedBufferParameteri64v; #define glGetNamedBufferParameteri64v glad_glGetNamedBufferParameteri64v -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC)(GLuint buffer, GLenum pname, void **params); +typedef void(APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC)(GLuint buffer, + GLenum pname, + void **params); GLAPI PFNGLGETNAMEDBUFFERPOINTERVPROC glad_glGetNamedBufferPointerv; #define glGetNamedBufferPointerv glad_glGetNamedBufferPointerv -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void(APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC)(GLuint buffer, + GLintptr offset, + GLsizeiptr size, + void *data); GLAPI PFNGLGETNAMEDBUFFERSUBDATAPROC glad_glGetNamedBufferSubData; #define glGetNamedBufferSubData glad_glGetNamedBufferSubData -typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers); +typedef void(APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC)(GLsizei n, + GLuint *framebuffers); GLAPI PFNGLCREATEFRAMEBUFFERSPROC glad_glCreateFramebuffers; #define glCreateFramebuffers glad_glCreateFramebuffers -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC)(GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void(APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC)( + GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer); GLAPI PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC glad_glNamedFramebufferRenderbuffer; #define glNamedFramebufferRenderbuffer glad_glNamedFramebufferRenderbuffer -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC)(GLuint framebuffer, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC)(GLuint framebuffer, + GLenum pname, + GLint param); GLAPI PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glad_glNamedFramebufferParameteri; #define glNamedFramebufferParameteri glad_glNamedFramebufferParameteri -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void(APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)(GLuint framebuffer, + GLenum attachment, + GLuint texture, + GLint level); GLAPI PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_glNamedFramebufferTexture; #define glNamedFramebufferTexture glad_glNamedFramebufferTexture -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC)(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void(APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC)( + GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, + GLint layer); GLAPI PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_glNamedFramebufferTextureLayer; #define glNamedFramebufferTextureLayer glad_glNamedFramebufferTextureLayer -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC)(GLuint framebuffer, GLenum buf); +typedef void(APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC)(GLuint framebuffer, + GLenum buf); GLAPI PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC glad_glNamedFramebufferDrawBuffer; #define glNamedFramebufferDrawBuffer glad_glNamedFramebufferDrawBuffer -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC)(GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void(APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC)( + GLuint framebuffer, GLsizei n, const GLenum *bufs); GLAPI PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glad_glNamedFramebufferDrawBuffers; #define glNamedFramebufferDrawBuffers glad_glNamedFramebufferDrawBuffers -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC)(GLuint framebuffer, GLenum src); +typedef void(APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC)(GLuint framebuffer, + GLenum src); GLAPI PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glad_glNamedFramebufferReadBuffer; #define glNamedFramebufferReadBuffer glad_glNamedFramebufferReadBuffer -typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC)(GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); -GLAPI PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_glInvalidateNamedFramebufferData; +typedef void(APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC)( + GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC + glad_glInvalidateNamedFramebufferData; #define glInvalidateNamedFramebufferData glad_glInvalidateNamedFramebufferData -typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC)(GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_glInvalidateNamedFramebufferSubData; -#define glInvalidateNamedFramebufferSubData glad_glInvalidateNamedFramebufferSubData -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void(APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC)( + GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, + GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC + glad_glInvalidateNamedFramebufferSubData; +#define glInvalidateNamedFramebufferSubData \ + glad_glInvalidateNamedFramebufferSubData +typedef void(APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC)(GLuint framebuffer, + GLenum buffer, + GLint drawbuffer, + const GLint *value); GLAPI PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glad_glClearNamedFramebufferiv; #define glClearNamedFramebufferiv glad_glClearNamedFramebufferiv -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void(APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC)(GLuint framebuffer, + GLenum buffer, + GLint drawbuffer, + const GLuint *value); GLAPI PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glad_glClearNamedFramebufferuiv; #define glClearNamedFramebufferuiv glad_glClearNamedFramebufferuiv -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void(APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC)(GLuint framebuffer, + GLenum buffer, + GLint drawbuffer, + const GLfloat *value); GLAPI PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glad_glClearNamedFramebufferfv; #define glClearNamedFramebufferfv glad_glClearNamedFramebufferfv -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void(APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC)(GLuint framebuffer, + GLenum buffer, + GLint drawbuffer, + GLfloat depth, + GLint stencil); GLAPI PFNGLCLEARNAMEDFRAMEBUFFERFIPROC glad_glClearNamedFramebufferfi; #define glClearNamedFramebufferfi glad_glClearNamedFramebufferfi -typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC)(GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void(APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC)( + GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, + GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, + GLint dstY1, GLbitfield mask, GLenum filter); GLAPI PFNGLBLITNAMEDFRAMEBUFFERPROC glad_glBlitNamedFramebuffer; #define glBlitNamedFramebuffer glad_glBlitNamedFramebuffer -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)(GLuint framebuffer, GLenum target); +typedef GLenum(APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)( + GLuint framebuffer, GLenum target); GLAPI PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glad_glCheckNamedFramebufferStatus; #define glCheckNamedFramebufferStatus glad_glCheckNamedFramebufferStatus -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC)(GLuint framebuffer, GLenum pname, GLint *param); -GLAPI PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC glad_glGetNamedFramebufferParameteriv; +typedef void(APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC)( + GLuint framebuffer, GLenum pname, GLint *param); +GLAPI PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC + glad_glGetNamedFramebufferParameteriv; #define glGetNamedFramebufferParameteriv glad_glGetNamedFramebufferParameteriv -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetNamedFramebufferAttachmentParameteriv; -#define glGetNamedFramebufferAttachmentParameteriv glad_glGetNamedFramebufferAttachmentParameteriv -typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers); +typedef void(APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC)( + GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC + glad_glGetNamedFramebufferAttachmentParameteriv; +#define glGetNamedFramebufferAttachmentParameteriv \ + glad_glGetNamedFramebufferAttachmentParameteriv +typedef void(APIENTRYP PFNGLCREATERENDERBUFFERSPROC)(GLsizei n, + GLuint *renderbuffers); GLAPI PFNGLCREATERENDERBUFFERSPROC glad_glCreateRenderbuffers; #define glCreateRenderbuffers glad_glCreateRenderbuffers -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC)(GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC)(GLuint renderbuffer, + GLenum internalformat, + GLsizei width, + GLsizei height); GLAPI PFNGLNAMEDRENDERBUFFERSTORAGEPROC glad_glNamedRenderbufferStorage; #define glNamedRenderbufferStorage glad_glNamedRenderbufferStorage -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glNamedRenderbufferStorageMultisample; -#define glNamedRenderbufferStorageMultisample glad_glNamedRenderbufferStorageMultisample -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC)(GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC glad_glGetNamedRenderbufferParameteriv; +typedef void(APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC)( + GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height); +GLAPI PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC + glad_glNamedRenderbufferStorageMultisample; +#define glNamedRenderbufferStorageMultisample \ + glad_glNamedRenderbufferStorageMultisample +typedef void(APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC)( + GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC + glad_glGetNamedRenderbufferParameteriv; #define glGetNamedRenderbufferParameteriv glad_glGetNamedRenderbufferParameteriv -typedef void (APIENTRYP PFNGLCREATETEXTURESPROC)(GLenum target, GLsizei n, GLuint *textures); +typedef void(APIENTRYP PFNGLCREATETEXTURESPROC)(GLenum target, GLsizei n, + GLuint *textures); GLAPI PFNGLCREATETEXTURESPROC glad_glCreateTextures; #define glCreateTextures glad_glCreateTextures -typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC)(GLuint texture, GLenum internalformat, GLuint buffer); +typedef void(APIENTRYP PFNGLTEXTUREBUFFERPROC)(GLuint texture, + GLenum internalformat, + GLuint buffer); GLAPI PFNGLTEXTUREBUFFERPROC glad_glTextureBuffer; #define glTextureBuffer glad_glTextureBuffer -typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC)(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void(APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC)(GLuint texture, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size); GLAPI PFNGLTEXTUREBUFFERRANGEPROC glad_glTextureBufferRange; #define glTextureBufferRange glad_glTextureBufferRange -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void(APIENTRYP PFNGLTEXTURESTORAGE1DPROC)(GLuint texture, + GLsizei levels, + GLenum internalformat, + GLsizei width); GLAPI PFNGLTEXTURESTORAGE1DPROC glad_glTextureStorage1D; #define glTextureStorage1D glad_glTextureStorage1D -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLTEXTURESTORAGE2DPROC)(GLuint texture, + GLsizei levels, + GLenum internalformat, + GLsizei width, + GLsizei height); GLAPI PFNGLTEXTURESTORAGE2DPROC glad_glTextureStorage2D; #define glTextureStorage2D glad_glTextureStorage2D -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void(APIENTRYP PFNGLTEXTURESTORAGE3DPROC)(GLuint texture, + GLsizei levels, + GLenum internalformat, + GLsizei width, GLsizei height, + GLsizei depth); GLAPI PFNGLTEXTURESTORAGE3DPROC glad_glTextureStorage3D; #define glTextureStorage3D glad_glTextureStorage3D -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC)(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void(APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC)( + GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height, GLboolean fixedsamplelocations); GLAPI PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC glad_glTextureStorage2DMultisample; #define glTextureStorage2DMultisample glad_glTextureStorage2DMultisample -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC)(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void(APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC)( + GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC glad_glTextureStorage3DMultisample; #define glTextureStorage3DMultisample glad_glTextureStorage3DMultisample -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const void *pixels); GLAPI PFNGLTEXTURESUBIMAGE1DPROC glad_glTextureSubImage1D; #define glTextureSubImage1D glad_glTextureSubImage1D -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, const void *pixels); GLAPI PFNGLTEXTURESUBIMAGE2DPROC glad_glTextureSubImage2D; #define glTextureSubImage2D glad_glTextureSubImage2D -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void(APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, + const void *pixels); GLAPI PFNGLTEXTURESUBIMAGE3DPROC glad_glTextureSubImage3D; #define glTextureSubImage3D glad_glTextureSubImage3D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC)( + GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, + GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC glad_glCompressedTextureSubImage1D; #define glCompressedTextureSubImage1D glad_glCompressedTextureSubImage1D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC glad_glCompressedTextureSubImage2D; #define glCompressedTextureSubImage2D glad_glCompressedTextureSubImage2D -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void(APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const void *data); GLAPI PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC glad_glCompressedTextureSubImage3D; #define glCompressedTextureSubImage3D glad_glCompressedTextureSubImage3D -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void(APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC)(GLuint texture, + GLint level, + GLint xoffset, GLint x, + GLint y, GLsizei width); GLAPI PFNGLCOPYTEXTURESUBIMAGE1DPROC glad_glCopyTextureSubImage1D; #define glCopyTextureSubImage1D glad_glCopyTextureSubImage1D -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, + GLsizei width, GLsizei height); GLAPI PFNGLCOPYTEXTURESUBIMAGE2DPROC glad_glCopyTextureSubImage2D; #define glCopyTextureSubImage2D glad_glCopyTextureSubImage2D -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void(APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height); GLAPI PFNGLCOPYTEXTURESUBIMAGE3DPROC glad_glCopyTextureSubImage3D; #define glCopyTextureSubImage3D glad_glCopyTextureSubImage3D -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC)(GLuint texture, GLenum pname, GLfloat param); +typedef void(APIENTRYP PFNGLTEXTUREPARAMETERFPROC)(GLuint texture, GLenum pname, + GLfloat param); GLAPI PFNGLTEXTUREPARAMETERFPROC glad_glTextureParameterf; #define glTextureParameterf glad_glTextureParameterf -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC)(GLuint texture, GLenum pname, const GLfloat *param); +typedef void(APIENTRYP PFNGLTEXTUREPARAMETERFVPROC)(GLuint texture, + GLenum pname, + const GLfloat *param); GLAPI PFNGLTEXTUREPARAMETERFVPROC glad_glTextureParameterfv; #define glTextureParameterfv glad_glTextureParameterfv -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC)(GLuint texture, GLenum pname, GLint param); +typedef void(APIENTRYP PFNGLTEXTUREPARAMETERIPROC)(GLuint texture, GLenum pname, + GLint param); GLAPI PFNGLTEXTUREPARAMETERIPROC glad_glTextureParameteri; #define glTextureParameteri glad_glTextureParameteri -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC)(GLuint texture, GLenum pname, const GLint *params); +typedef void(APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC)(GLuint texture, + GLenum pname, + const GLint *params); GLAPI PFNGLTEXTUREPARAMETERIIVPROC glad_glTextureParameterIiv; #define glTextureParameterIiv glad_glTextureParameterIiv -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC)(GLuint texture, GLenum pname, const GLuint *params); +typedef void(APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC)(GLuint texture, + GLenum pname, + const GLuint *params); GLAPI PFNGLTEXTUREPARAMETERIUIVPROC glad_glTextureParameterIuiv; #define glTextureParameterIuiv glad_glTextureParameterIuiv -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC)(GLuint texture, GLenum pname, const GLint *param); +typedef void(APIENTRYP PFNGLTEXTUREPARAMETERIVPROC)(GLuint texture, + GLenum pname, + const GLint *param); GLAPI PFNGLTEXTUREPARAMETERIVPROC glad_glTextureParameteriv; #define glTextureParameteriv glad_glTextureParameteriv -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC)(GLuint texture); +typedef void(APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC)(GLuint texture); GLAPI PFNGLGENERATETEXTUREMIPMAPPROC glad_glGenerateTextureMipmap; #define glGenerateTextureMipmap glad_glGenerateTextureMipmap -typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC)(GLuint unit, GLuint texture); +typedef void(APIENTRYP PFNGLBINDTEXTUREUNITPROC)(GLuint unit, GLuint texture); GLAPI PFNGLBINDTEXTUREUNITPROC glad_glBindTextureUnit; #define glBindTextureUnit glad_glBindTextureUnit -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void(APIENTRYP PFNGLGETTEXTUREIMAGEPROC)(GLuint texture, GLint level, + GLenum format, GLenum type, + GLsizei bufSize, void *pixels); GLAPI PFNGLGETTEXTUREIMAGEPROC glad_glGetTextureImage; #define glGetTextureImage glad_glGetTextureImage -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC)(GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void(APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC)(GLuint texture, + GLint level, + GLsizei bufSize, + void *pixels); GLAPI PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC glad_glGetCompressedTextureImage; #define glGetCompressedTextureImage glad_glGetCompressedTextureImage -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC)(GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC)(GLuint texture, + GLint level, + GLenum pname, + GLfloat *params); GLAPI PFNGLGETTEXTURELEVELPARAMETERFVPROC glad_glGetTextureLevelParameterfv; #define glGetTextureLevelParameterfv glad_glGetTextureLevelParameterfv -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC)(GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC)(GLuint texture, + GLint level, + GLenum pname, + GLint *params); GLAPI PFNGLGETTEXTURELEVELPARAMETERIVPROC glad_glGetTextureLevelParameteriv; #define glGetTextureLevelParameteriv glad_glGetTextureLevelParameteriv -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC)(GLuint texture, GLenum pname, GLfloat *params); +typedef void(APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC)(GLuint texture, + GLenum pname, + GLfloat *params); GLAPI PFNGLGETTEXTUREPARAMETERFVPROC glad_glGetTextureParameterfv; #define glGetTextureParameterfv glad_glGetTextureParameterfv -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC)(GLuint texture, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC)(GLuint texture, + GLenum pname, + GLint *params); GLAPI PFNGLGETTEXTUREPARAMETERIIVPROC glad_glGetTextureParameterIiv; #define glGetTextureParameterIiv glad_glGetTextureParameterIiv -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC)(GLuint texture, GLenum pname, GLuint *params); +typedef void(APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC)(GLuint texture, + GLenum pname, + GLuint *params); GLAPI PFNGLGETTEXTUREPARAMETERIUIVPROC glad_glGetTextureParameterIuiv; #define glGetTextureParameterIuiv glad_glGetTextureParameterIuiv -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC)(GLuint texture, GLenum pname, GLint *params); +typedef void(APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC)(GLuint texture, + GLenum pname, + GLint *params); GLAPI PFNGLGETTEXTUREPARAMETERIVPROC glad_glGetTextureParameteriv; #define glGetTextureParameteriv glad_glGetTextureParameteriv -typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays); +typedef void(APIENTRYP PFNGLCREATEVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays); GLAPI PFNGLCREATEVERTEXARRAYSPROC glad_glCreateVertexArrays; #define glCreateVertexArrays glad_glCreateVertexArrays -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, GLuint index); +typedef void(APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, + GLuint index); GLAPI PFNGLDISABLEVERTEXARRAYATTRIBPROC glad_glDisableVertexArrayAttrib; #define glDisableVertexArrayAttrib glad_glDisableVertexArrayAttrib -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, GLuint index); +typedef void(APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, + GLuint index); GLAPI PFNGLENABLEVERTEXARRAYATTRIBPROC glad_glEnableVertexArrayAttrib; #define glEnableVertexArrayAttrib glad_glEnableVertexArrayAttrib -typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC)(GLuint vaobj, GLuint buffer); +typedef void(APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC)(GLuint vaobj, + GLuint buffer); GLAPI PFNGLVERTEXARRAYELEMENTBUFFERPROC glad_glVertexArrayElementBuffer; #define glVertexArrayElementBuffer glad_glVertexArrayElementBuffer -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC)(GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void(APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC)(GLuint vaobj, + GLuint bindingindex, + GLuint buffer, + GLintptr offset, + GLsizei stride); GLAPI PFNGLVERTEXARRAYVERTEXBUFFERPROC glad_glVertexArrayVertexBuffer; #define glVertexArrayVertexBuffer glad_glVertexArrayVertexBuffer -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC)(GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void(APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC)( + GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, + const GLintptr *offsets, const GLsizei *strides); GLAPI PFNGLVERTEXARRAYVERTEXBUFFERSPROC glad_glVertexArrayVertexBuffers; #define glVertexArrayVertexBuffers glad_glVertexArrayVertexBuffers -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC)(GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void(APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC)(GLuint vaobj, + GLuint attribindex, + GLuint bindingindex); GLAPI PFNGLVERTEXARRAYATTRIBBINDINGPROC glad_glVertexArrayAttribBinding; #define glVertexArrayAttribBinding glad_glVertexArrayAttribBinding -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void(APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC)( + GLuint vaobj, GLuint attribindex, GLint size, GLenum type, + GLboolean normalized, GLuint relativeoffset); GLAPI PFNGLVERTEXARRAYATTRIBFORMATPROC glad_glVertexArrayAttribFormat; #define glVertexArrayAttribFormat glad_glVertexArrayAttribFormat -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void(APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC)( + GLuint vaobj, GLuint attribindex, GLint size, GLenum type, + GLuint relativeoffset); GLAPI PFNGLVERTEXARRAYATTRIBIFORMATPROC glad_glVertexArrayAttribIFormat; #define glVertexArrayAttribIFormat glad_glVertexArrayAttribIFormat -typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void(APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC)( + GLuint vaobj, GLuint attribindex, GLint size, GLenum type, + GLuint relativeoffset); GLAPI PFNGLVERTEXARRAYATTRIBLFORMATPROC glad_glVertexArrayAttribLFormat; #define glVertexArrayAttribLFormat glad_glVertexArrayAttribLFormat -typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC)(GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void(APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC)(GLuint vaobj, + GLuint bindingindex, + GLuint divisor); GLAPI PFNGLVERTEXARRAYBINDINGDIVISORPROC glad_glVertexArrayBindingDivisor; #define glVertexArrayBindingDivisor glad_glVertexArrayBindingDivisor -typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC)(GLuint vaobj, GLenum pname, GLint *param); +typedef void(APIENTRYP PFNGLGETVERTEXARRAYIVPROC)(GLuint vaobj, GLenum pname, + GLint *param); GLAPI PFNGLGETVERTEXARRAYIVPROC glad_glGetVertexArrayiv; #define glGetVertexArrayiv glad_glGetVertexArrayiv -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC)(GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void(APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC)(GLuint vaobj, + GLuint index, + GLenum pname, + GLint *param); GLAPI PFNGLGETVERTEXARRAYINDEXEDIVPROC glad_glGetVertexArrayIndexediv; #define glGetVertexArrayIndexediv glad_glGetVertexArrayIndexediv -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC)(GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void(APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC)(GLuint vaobj, + GLuint index, + GLenum pname, + GLint64 *param); GLAPI PFNGLGETVERTEXARRAYINDEXED64IVPROC glad_glGetVertexArrayIndexed64iv; #define glGetVertexArrayIndexed64iv glad_glGetVertexArrayIndexed64iv -typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC)(GLsizei n, GLuint *samplers); +typedef void(APIENTRYP PFNGLCREATESAMPLERSPROC)(GLsizei n, GLuint *samplers); GLAPI PFNGLCREATESAMPLERSPROC glad_glCreateSamplers; #define glCreateSamplers glad_glCreateSamplers -typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC)(GLsizei n, GLuint *pipelines); +typedef void(APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC)(GLsizei n, + GLuint *pipelines); GLAPI PFNGLCREATEPROGRAMPIPELINESPROC glad_glCreateProgramPipelines; #define glCreateProgramPipelines glad_glCreateProgramPipelines -typedef void (APIENTRYP PFNGLCREATEQUERIESPROC)(GLenum target, GLsizei n, GLuint *ids); +typedef void(APIENTRYP PFNGLCREATEQUERIESPROC)(GLenum target, GLsizei n, + GLuint *ids); GLAPI PFNGLCREATEQUERIESPROC glad_glCreateQueries; #define glCreateQueries glad_glCreateQueries -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void(APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC)(GLuint id, + GLuint buffer, + GLenum pname, + GLintptr offset); GLAPI PFNGLGETQUERYBUFFEROBJECTI64VPROC glad_glGetQueryBufferObjecti64v; #define glGetQueryBufferObjecti64v glad_glGetQueryBufferObjecti64v -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void(APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC)(GLuint id, + GLuint buffer, + GLenum pname, + GLintptr offset); GLAPI PFNGLGETQUERYBUFFEROBJECTIVPROC glad_glGetQueryBufferObjectiv; #define glGetQueryBufferObjectiv glad_glGetQueryBufferObjectiv -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void(APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC)(GLuint id, + GLuint buffer, + GLenum pname, + GLintptr offset); GLAPI PFNGLGETQUERYBUFFEROBJECTUI64VPROC glad_glGetQueryBufferObjectui64v; #define glGetQueryBufferObjectui64v glad_glGetQueryBufferObjectui64v -typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void(APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC)(GLuint id, + GLuint buffer, + GLenum pname, + GLintptr offset); GLAPI PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv; #define glGetQueryBufferObjectuiv glad_glGetQueryBufferObjectuiv -typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC)(GLbitfield barriers); +typedef void(APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC)(GLbitfield barriers); GLAPI PFNGLMEMORYBARRIERBYREGIONPROC glad_glMemoryBarrierByRegion; #define glMemoryBarrierByRegion glad_glMemoryBarrierByRegion -typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void(APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, + GLsizei bufSize, void *pixels); GLAPI PFNGLGETTEXTURESUBIMAGEPROC glad_glGetTextureSubImage; #define glGetTextureSubImage glad_glGetTextureSubImage -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef void(APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)( + GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, + void *pixels); GLAPI PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC glad_glGetCompressedTextureSubImage; #define glGetCompressedTextureSubImage glad_glGetCompressedTextureSubImage -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC)(void); +typedef GLenum(APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC)(void); GLAPI PFNGLGETGRAPHICSRESETSTATUSPROC glad_glGetGraphicsResetStatus; #define glGetGraphicsResetStatus glad_glGetGraphicsResetStatus -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void(APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC)(GLenum target, + GLint lod, + GLsizei bufSize, + void *pixels); GLAPI PFNGLGETNCOMPRESSEDTEXIMAGEPROC glad_glGetnCompressedTexImage; #define glGetnCompressedTexImage glad_glGetnCompressedTexImage -typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void(APIENTRYP PFNGLGETNTEXIMAGEPROC)(GLenum target, GLint level, + GLenum format, GLenum type, + GLsizei bufSize, void *pixels); GLAPI PFNGLGETNTEXIMAGEPROC glad_glGetnTexImage; #define glGetnTexImage glad_glGetnTexImage -typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC)(GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void(APIENTRYP PFNGLGETNUNIFORMDVPROC)(GLuint program, GLint location, + GLsizei bufSize, + GLdouble *params); GLAPI PFNGLGETNUNIFORMDVPROC glad_glGetnUniformdv; #define glGetnUniformdv glad_glGetnUniformdv -typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void(APIENTRYP PFNGLGETNUNIFORMFVPROC)(GLuint program, GLint location, + GLsizei bufSize, + GLfloat *params); GLAPI PFNGLGETNUNIFORMFVPROC glad_glGetnUniformfv; #define glGetnUniformfv glad_glGetnUniformfv -typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC)(GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void(APIENTRYP PFNGLGETNUNIFORMIVPROC)(GLuint program, GLint location, + GLsizei bufSize, GLint *params); GLAPI PFNGLGETNUNIFORMIVPROC glad_glGetnUniformiv; #define glGetnUniformiv glad_glGetnUniformiv -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void(APIENTRYP PFNGLGETNUNIFORMUIVPROC)(GLuint program, GLint location, + GLsizei bufSize, + GLuint *params); GLAPI PFNGLGETNUNIFORMUIVPROC glad_glGetnUniformuiv; #define glGetnUniformuiv glad_glGetnUniformuiv -typedef void (APIENTRYP PFNGLREADNPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void(APIENTRYP PFNGLREADNPIXELSPROC)(GLint x, GLint y, GLsizei width, + GLsizei height, GLenum format, + GLenum type, GLsizei bufSize, + void *data); GLAPI PFNGLREADNPIXELSPROC glad_glReadnPixels; #define glReadnPixels glad_glReadnPixels -typedef void (APIENTRYP PFNGLGETNMAPDVPROC)(GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void(APIENTRYP PFNGLGETNMAPDVPROC)(GLenum target, GLenum query, + GLsizei bufSize, GLdouble *v); GLAPI PFNGLGETNMAPDVPROC glad_glGetnMapdv; #define glGetnMapdv glad_glGetnMapdv -typedef void (APIENTRYP PFNGLGETNMAPFVPROC)(GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void(APIENTRYP PFNGLGETNMAPFVPROC)(GLenum target, GLenum query, + GLsizei bufSize, GLfloat *v); GLAPI PFNGLGETNMAPFVPROC glad_glGetnMapfv; #define glGetnMapfv glad_glGetnMapfv -typedef void (APIENTRYP PFNGLGETNMAPIVPROC)(GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void(APIENTRYP PFNGLGETNMAPIVPROC)(GLenum target, GLenum query, + GLsizei bufSize, GLint *v); GLAPI PFNGLGETNMAPIVPROC glad_glGetnMapiv; #define glGetnMapiv glad_glGetnMapiv -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC)(GLenum map, GLsizei bufSize, GLfloat *values); +typedef void(APIENTRYP PFNGLGETNPIXELMAPFVPROC)(GLenum map, GLsizei bufSize, + GLfloat *values); GLAPI PFNGLGETNPIXELMAPFVPROC glad_glGetnPixelMapfv; #define glGetnPixelMapfv glad_glGetnPixelMapfv -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC)(GLenum map, GLsizei bufSize, GLuint *values); +typedef void(APIENTRYP PFNGLGETNPIXELMAPUIVPROC)(GLenum map, GLsizei bufSize, + GLuint *values); GLAPI PFNGLGETNPIXELMAPUIVPROC glad_glGetnPixelMapuiv; #define glGetnPixelMapuiv glad_glGetnPixelMapuiv -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC)(GLenum map, GLsizei bufSize, GLushort *values); +typedef void(APIENTRYP PFNGLGETNPIXELMAPUSVPROC)(GLenum map, GLsizei bufSize, + GLushort *values); GLAPI PFNGLGETNPIXELMAPUSVPROC glad_glGetnPixelMapusv; #define glGetnPixelMapusv glad_glGetnPixelMapusv -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC)(GLsizei bufSize, GLubyte *pattern); +typedef void(APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC)(GLsizei bufSize, + GLubyte *pattern); GLAPI PFNGLGETNPOLYGONSTIPPLEPROC glad_glGetnPolygonStipple; #define glGetnPolygonStipple glad_glGetnPolygonStipple -typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void(APIENTRYP PFNGLGETNCOLORTABLEPROC)(GLenum target, GLenum format, + GLenum type, GLsizei bufSize, + void *table); GLAPI PFNGLGETNCOLORTABLEPROC glad_glGetnColorTable; #define glGetnColorTable glad_glGetnColorTable -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void(APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC)( + GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); GLAPI PFNGLGETNCONVOLUTIONFILTERPROC glad_glGetnConvolutionFilter; #define glGetnConvolutionFilter glad_glGetnConvolutionFilter -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC)(GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void(APIENTRYP PFNGLGETNSEPARABLEFILTERPROC)( + GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, + GLsizei columnBufSize, void *column, void *span); GLAPI PFNGLGETNSEPARABLEFILTERPROC glad_glGetnSeparableFilter; #define glGetnSeparableFilter glad_glGetnSeparableFilter -typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void(APIENTRYP PFNGLGETNHISTOGRAMPROC)(GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLsizei bufSize, void *values); GLAPI PFNGLGETNHISTOGRAMPROC glad_glGetnHistogram; #define glGetnHistogram glad_glGetnHistogram -typedef void (APIENTRYP PFNGLGETNMINMAXPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void(APIENTRYP PFNGLGETNMINMAXPROC)(GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLsizei bufSize, void *values); GLAPI PFNGLGETNMINMAXPROC glad_glGetnMinmax; #define glGetnMinmax glad_glGetnMinmax -typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC)(void); +typedef void(APIENTRYP PFNGLTEXTUREBARRIERPROC)(void); GLAPI PFNGLTEXTUREBARRIERPROC glad_glTextureBarrier; #define glTextureBarrier glad_glTextureBarrier #endif #ifndef GL_VERSION_4_6 #define GL_VERSION_4_6 1 GLAPI int GLAD_GL_VERSION_4_6; -typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC)(GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void(APIENTRYP PFNGLSPECIALIZESHADERPROC)( + GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, + const GLuint *pConstantIndex, const GLuint *pConstantValue); GLAPI PFNGLSPECIALIZESHADERPROC glad_glSpecializeShader; #define glSpecializeShader glad_glSpecializeShader -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC)(GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void(APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC)( + GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, + GLsizei stride); GLAPI PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC glad_glMultiDrawArraysIndirectCount; #define glMultiDrawArraysIndirectCount glad_glMultiDrawArraysIndirectCount -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC)(GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC glad_glMultiDrawElementsIndirectCount; +typedef void(APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC)( + GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, + GLsizei maxdrawcount, GLsizei stride); +GLAPI PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC + glad_glMultiDrawElementsIndirectCount; #define glMultiDrawElementsIndirectCount glad_glMultiDrawElementsIndirectCount -typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC)(GLfloat factor, GLfloat units, GLfloat clamp); +typedef void(APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC)(GLfloat factor, + GLfloat units, + GLfloat clamp); GLAPI PFNGLPOLYGONOFFSETCLAMPPROC glad_glPolygonOffsetClamp; #define glPolygonOffsetClamp glad_glPolygonOffsetClamp #endif diff --git a/Sources/MaterialX/include/MaterialX/KHRPlatform.h b/Sources/MaterialX/include/MaterialX/KHRPlatform.h index 01646449..598ebb8f 100644 --- a/Sources/MaterialX/include/MaterialX/KHRPlatform.h +++ b/Sources/MaterialX/include/MaterialX/KHRPlatform.h @@ -91,7 +91,7 @@ */ #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) -# define KHRONOS_STATIC 1 +#define KHRONOS_STATIC 1 #endif /*------------------------------------------------------------------------- @@ -100,17 +100,17 @@ * This precedes the return type of the function in the function prototype. */ #if defined(KHRONOS_STATIC) - /* If the preprocessor constant KHRONOS_STATIC is defined, make the - * header compatible with static linking. */ -# define KHRONOS_APICALL +/* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +#define KHRONOS_APICALL #elif defined(_WIN32) -# define KHRONOS_APICALL __declspec(dllimport) -#elif defined (__SYMBIAN32__) -# define KHRONOS_APICALL IMPORT_C +#define KHRONOS_APICALL __declspec(dllimport) +#elif defined(__SYMBIAN32__) +#define KHRONOS_APICALL IMPORT_C #elif defined(__ANDROID__) -# define KHRONOS_APICALL __attribute__((visibility("default"))) +#define KHRONOS_APICALL __attribute__((visibility("default"))) #else -# define KHRONOS_APICALL +#define KHRONOS_APICALL #endif /*------------------------------------------------------------------------- @@ -120,10 +120,10 @@ * name in the function prototype. */ #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) - /* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall +/* Win32 but not WinCE */ +#define KHRONOS_APIENTRY __stdcall #else -# define KHRONOS_APIENTRY +#define KHRONOS_APIENTRY #endif /*------------------------------------------------------------------------- @@ -131,7 +131,7 @@ *------------------------------------------------------------------------- * This follows the closing parenthesis of the function prototype arguments. */ -#if defined (__ARMCC_2__) +#if defined(__ARMCC_2__) #define KHRONOS_APIATTRIBUTES __softfp #else #define KHRONOS_APIATTRIBUTES @@ -140,19 +140,19 @@ /*------------------------------------------------------------------------- * basic type definitions *-----------------------------------------------------------------------*/ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) /* * Using */ #include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 /* * To support platform where unsigned long cannot be used interchangeably with * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. @@ -168,57 +168,57 @@ typedef uint64_t khronos_uint64_t; #endif #endif -#elif defined(__VMS ) || defined(__sgi) +#elif defined(__VMS) || defined(__sgi) /* * Using */ #include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) /* * Win32 */ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 #elif defined(__sun__) || defined(__digital__) /* * Sun or Digital */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; #if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; #else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; #endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 #elif 0 /* * Hypothetical platform with no float or int64 support */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 #else @@ -226,23 +226,22 @@ typedef unsigned int khronos_uint32_t; * Generic fallback */ #include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 #endif - /* * Types that are (so far) the same on all platforms */ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; /* * Types that differ between LLP64 and LP64 architectures - in LLP64, @@ -250,29 +249,29 @@ typedef unsigned short int khronos_uint16_t; * to be the only LLP64 architecture in current use. */ #ifdef KHRONOS_USE_INTPTR_T -typedef intptr_t khronos_intptr_t; -typedef uintptr_t khronos_uintptr_t; +typedef intptr_t khronos_intptr_t; +typedef uintptr_t khronos_uintptr_t; #elif defined(_WIN64) -typedef signed long long int khronos_intptr_t; +typedef signed long long int khronos_intptr_t; typedef unsigned long long int khronos_uintptr_t; #else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; #endif #if defined(_WIN64) -typedef signed long long int khronos_ssize_t; +typedef signed long long int khronos_ssize_t; typedef unsigned long long int khronos_usize_t; #else -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; #endif #if KHRONOS_SUPPORT_FLOAT /* * Float type */ -typedef float khronos_float_t; +typedef float khronos_float_t; #endif #if KHRONOS_SUPPORT_INT64 @@ -285,8 +284,8 @@ typedef float khronos_float_t; * 64 bit value that wraps back to 0 every 584 years. Time intervals * may be either signed or unsigned. */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; #endif /* @@ -303,9 +302,9 @@ typedef khronos_int64_t khronos_stime_nanoseconds_t; * comparisons should not be made against KHRONOS_TRUE. */ typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM } khronos_boolean_enum_t; #endif /* __khrplatform_h_ */ diff --git a/Sources/MaterialX/include/MaterialX/MXCoreGenerated.h b/Sources/MaterialX/include/MaterialX/MXCoreGenerated.h index 36d5b753..fd97e3db 100644 --- a/Sources/MaterialX/include/MaterialX/MXCoreGenerated.h +++ b/Sources/MaterialX/include/MaterialX/MXCoreGenerated.h @@ -13,11 +13,10 @@ /* #undef MATERIALX_BUILD_SHARED_LIBS */ // Establish namespace: -namespace MaterialX_v1_38_8 -{ -} +namespace MaterialX_v1_38_8 {} -// Establish alias to allow downstream clients to still use the MaterialX namespace: +// Establish alias to allow downstream clients to still use the MaterialX +// namespace: namespace MaterialX = MaterialX_v1_38_8; // All code in this project must use these macros for opening and closing the diff --git a/Sources/MaterialX/include/MaterialX/MXGraphEditorGraph.h b/Sources/MaterialX/include/MaterialX/MXGraphEditorGraph.h index 693c8697..570f0f81 100644 --- a/Sources/MaterialX/include/MaterialX/MXGraphEditorGraph.h +++ b/Sources/MaterialX/include/MaterialX/MXGraphEditorGraph.h @@ -68,7 +68,7 @@ class Graph { void setFontScale(float val) { _fontScale = val; } - ~Graph(){}; + ~Graph() {}; private: mx::ElementPredicate getElementPredicate() const; diff --git a/Sources/MaterialX/include/MaterialX/MXGraphEditorUiNode.h b/Sources/MaterialX/include/MaterialX/MXGraphEditorUiNode.h index 3921d9f0..21d11085 100644 --- a/Sources/MaterialX/include/MaterialX/MXGraphEditorUiNode.h +++ b/Sources/MaterialX/include/MaterialX/MXGraphEditorUiNode.h @@ -97,7 +97,7 @@ class UiNode { public: UiNode(); UiNode(const std::string &name, int id); - ~UiNode(){}; + ~UiNode() {}; std::string getName() { return _name; } ImVec2 getPos() { return _nodePos; } diff --git a/Sources/MaterialX/include/MaterialX/MXRenderGlslGLCocoaWrappers.h b/Sources/MaterialX/include/MaterialX/MXRenderGlslGLCocoaWrappers.h index 39629b84..4e0d1949 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderGlslGLCocoaWrappers.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderGlslGLCocoaWrappers.h @@ -14,24 +14,27 @@ extern "C" { #endif // OpenGL specific routines -void* NSOpenGLChoosePixelFormatWrapper(bool allRenders, int bufferType, int colorSize, int depthFormat, - int stencilFormat, int auxBuffers, int accumSize, bool minimumPolicy, - bool accelerated, bool mp_safe, bool stereo, bool supportMultiSample); -void NSOpenGLReleasePixelFormat(void* pPixelFormat); -void NSOpenGLReleaseContext(void* pContext); -void* NSOpenGLCreateContextWrapper(void* pPixelFormat, void *pDummyContext); -void NSOpenGLSetDrawable(void* pContext, void* pView); -void NSOpenGLMakeCurrent(void* pContext); -void* NSOpenGLGetCurrentContextWrapper(); -void NSOpenGLSwapBuffers(void* pContext); +void *NSOpenGLChoosePixelFormatWrapper(bool allRenders, int bufferType, + int colorSize, int depthFormat, + int stencilFormat, int auxBuffers, + int accumSize, bool minimumPolicy, + bool accelerated, bool mp_safe, + bool stereo, bool supportMultiSample); +void NSOpenGLReleasePixelFormat(void *pPixelFormat); +void NSOpenGLReleaseContext(void *pContext); +void *NSOpenGLCreateContextWrapper(void *pPixelFormat, void *pDummyContext); +void NSOpenGLSetDrawable(void *pContext, void *pView); +void NSOpenGLMakeCurrent(void *pContext); +void *NSOpenGLGetCurrentContextWrapper(); +void NSOpenGLSwapBuffers(void *pContext); void NSOpenGLClearCurrentContext(); -void NSOpenGLDestroyContext(void** pContext); -void NSOpenGLDestroyCurrentContext(void** pContext); -void NSOpenGLClearDrawable(void* pContext); -void NSOpenGLDescribePixelFormat(void* pPixelFormat, int attrib, int* vals); -void NSOpenGLGetInteger(void* pContext, int param, int* vals); -void NSOpenGLUpdate(void* pContext); -void* NSOpenGLGetWindow(void* pView); +void NSOpenGLDestroyContext(void **pContext); +void NSOpenGLDestroyCurrentContext(void **pContext); +void NSOpenGLClearDrawable(void *pContext); +void NSOpenGLDescribePixelFormat(void *pPixelFormat, int attrib, int *vals); +void NSOpenGLGetInteger(void *pContext, int param, int *vals); +void NSOpenGLUpdate(void *pContext); +void *NSOpenGLGetWindow(void *pView); void NSOpenGLInitializeGLLibrary(); #ifdef __cplusplus diff --git a/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h b/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h index 25066671..86d11884 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h @@ -16,7 +16,7 @@ #if defined(__APPLE__) #include #if !TARGET_OS_IPHONE -# include +#include #endif /* !TARGET_OS_IPHONE */ #elif defined(__linux__) || defined(__FreeBSD__) #include diff --git a/Sources/MaterialX/include/MaterialX/MXRenderHwWindowCocoaWrappers.h b/Sources/MaterialX/include/MaterialX/MXRenderHwWindowCocoaWrappers.h index 8fac992a..2c73a9f9 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderHwWindowCocoaWrappers.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderHwWindowCocoaWrappers.h @@ -13,12 +13,13 @@ extern "C" { #endif -void* NSUtilGetView(void* pWindow); -void* NSUtilCreateWindow(unsigned int width, unsigned int height, const char* title, bool batchMode); -void NSUtilShowWindow(void* pWindow); -void NSUtilHideWindow(void* pWindow); -void NSUtilSetFocus(void* pWindow); -void NSUtilDisposeWindow(void* pWindow); +void *NSUtilGetView(void *pWindow); +void *NSUtilCreateWindow(unsigned int width, unsigned int height, + const char *title, bool batchMode); +void NSUtilShowWindow(void *pWindow); +void NSUtilHideWindow(void *pWindow); +void NSUtilSetFocus(void *pWindow); +void NSUtilDisposeWindow(void *pWindow); #ifdef __cplusplus } diff --git a/Sources/MaterialX/include/MaterialX/MXRenderMslMetalFramebuffer.h b/Sources/MaterialX/include/MaterialX/MXRenderMslMetalFramebuffer.h index 8aa6af68..bcbe25a1 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderMslMetalFramebuffer.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderMslMetalFramebuffer.h @@ -13,7 +13,7 @@ #include -#include +#import MATERIALX_NAMESPACE_BEGIN @@ -28,10 +28,10 @@ class MX_RENDERMSL_API MetalFramebuffer { public: /// Create a new framebuffer static MetalFramebufferPtr - create(MTL::Device *device, unsigned int width, unsigned int height, + create(id device, unsigned int width, unsigned int height, unsigned int channelCount, Image::BaseType baseType, - MTL::Texture *colorTexture = nil, bool encodeSrgb = false, - MTL::PixelFormat pixelFormat = MTL::PixelFormatInvalid); + id colorTexture = nil, bool encodeSrgb = false, + MTLPixelFormat pixelFormat = MTLPixelFormatInvalid); /// Destructor virtual ~MetalFramebuffer(); @@ -39,8 +39,8 @@ class MX_RENDERMSL_API MetalFramebuffer { /// Resize the framebuffer void resize(unsigned int width, unsigned int height, bool forceRecreate = false, - MTL::PixelFormat pixelFormat = MTL::PixelFormatInvalid, - MTL::Texture *extColorTexture = nil); + MTLPixelFormat pixelFormat = MTLPixelFormatInvalid, + id extColorTexture = nil); /// Set the encode sRGB flag, which controls whether values written /// to the framebuffer are encoded to the sRGB color space. @@ -61,40 +61,43 @@ class MX_RENDERMSL_API MetalFramebuffer { unsigned int getHeight() const { return _height; } /// Bind the framebuffer for rendering. - void bind(MTL::RenderPassDescriptor *renderpassDesc); + void bind(MTLRenderPassDescriptor *renderpassDesc); /// Unbind the frame buffer after rendering. void unbind(); /// Return our color texture handle. - MTL::Texture *getColorTexture() const { return _colorTexture; } + id getColorTexture() const { return _colorTexture; } - void setColorTexture(MTL::Texture *newColorTexture) { - auto sameDim = [](MTL::Texture *tex0, MTL::Texture *tex1) -> bool { - return tex0->width() == tex1->width() && tex0->height() == tex1->height(); + void setColorTexture(id newColorTexture) { + auto sameDim = [](id tex0, id tex1) -> bool { + return tex0.width == tex1.width && tex0.height == tex1.height; }; if ((!_colorTextureOwned || sameDim(_colorTexture, newColorTexture)) && sameDim(newColorTexture, _depthTexture)) { if (_colorTextureOwned) - _colorTexture->release(); +#if !__has_feature(objc_arc) + _colorTexture.release(); +#endif // __has_feature(objc_arc) _colorTexture = newColorTexture; } } /// Return our depth texture handle. - MTL::Texture *getDepthTexture() const { return _depthTexture; } + id getDepthTexture() const { return _depthTexture; } /// Return the color data of this framebuffer as an image. /// If an input image is provided, it will be used to store the color data; /// otherwise a new image of the required format will be created. - ImagePtr getColorImage(MTL::CommandQueue *cmdQueue = nil, + ImagePtr getColorImage(id cmdQueue = nil, ImagePtr image = nullptr); protected: - MetalFramebuffer(MTL::Device *device, unsigned int width, unsigned int height, - unsigned int channelCount, Image::BaseType baseType, - MTL::Texture *colorTexture = nil, bool encodeSrgb = false, - MTL::PixelFormat pixelFormat = MTL::PixelFormatInvalid); + MetalFramebuffer(id device, unsigned int width, + unsigned int height, unsigned int channelCount, + Image::BaseType baseType, id colorTexture = nil, + bool encodeSrgb = false, + MTLPixelFormat pixelFormat = MTLPixelFormatInvalid); protected: unsigned int _width; @@ -103,9 +106,9 @@ class MX_RENDERMSL_API MetalFramebuffer { Image::BaseType _baseType; bool _encodeSrgb; - MTL::Device *_device = nil; - MTL::Texture *_colorTexture = nil; - MTL::Texture *_depthTexture = nil; + id _device = nil; + id _colorTexture = nil; + id _depthTexture = nil; bool _colorTextureOwned = false; }; diff --git a/Sources/MaterialX/include/MaterialX/MXRenderMslMetalState.h b/Sources/MaterialX/include/MaterialX/MXRenderMslMetalState.h index 69f2cbfc..f4142bfb 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderMslMetalState.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderMslMetalState.h @@ -11,7 +11,7 @@ #include #include -#include +#import #include @@ -31,12 +31,12 @@ struct MetalState { MetalState(); - void initialize(MTL::Device *mtlDevice, MTL::CommandQueue *mtlCmdQueue); + void initialize(id mtlDevice, id mtlCmdQueue); void initLinearToSRGBKernel(); void triggerProgrammaticCapture(); void stopProgrammaticCapture(); void beginCommandBuffer(); - void beginEncoder(MTL::RenderPassDescriptor *renderpassDesc); + void beginEncoder(MTLRenderPassDescriptor *renderpassDesc); void endEncoder(); void endCommandBuffer(); @@ -46,18 +46,18 @@ struct MetalState { static std::unique_ptr singleton; - MTL::Device *device = nil; - MTL::CommandQueue *cmdQueue = nil; - MTL::CommandBuffer *cmdBuffer = nil; - MTL::RenderPipelineState *linearToSRGB_pso = nil; - MTL::RenderCommandEncoder *renderCmdEncoder = nil; + id device = nil; + id cmdQueue = nil; + id cmdBuffer = nil; + id linearToSRGB_pso = nil; + id renderCmdEncoder = nil; std::stack framebufferStack; bool supportsTiledPipeline; - MTL::DepthStencilState *opaqueDepthStencilState = nil; - MTL::DepthStencilState *transparentDepthStencilState = nil; - MTL::DepthStencilState *envMapDepthStencilState = nil; + id opaqueDepthStencilState = nil; + id transparentDepthStencilState = nil; + id envMapDepthStencilState = nil; std::condition_variable inFlightCV; std::mutex inFlightMutex; diff --git a/Sources/MaterialX/include/MaterialX/MXRenderMslMetalTextureHandler.h b/Sources/MaterialX/include/MaterialX/MXRenderMslMetalTextureHandler.h index 9f9ba32f..c8de9614 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderMslMetalTextureHandler.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderMslMetalTextureHandler.h @@ -16,7 +16,7 @@ #include #include -#include +#import MATERIALX_NAMESPACE_BEGIN @@ -29,7 +29,7 @@ class MX_RENDERMSL_API MetalTextureHandler : public ImageHandler { friend class MslProgram; public: - static MetalTextureHandlerPtr create(MTL::Device *device, + static MetalTextureHandlerPtr create(id device, ImageLoaderPtr imageLoader) { return MetalTextureHandlerPtr(new MetalTextureHandler(device, imageLoader)); } @@ -44,18 +44,18 @@ class MX_RENDERMSL_API MetalTextureHandler : public ImageHandler { /// Bind an image. This method will bind the texture to an active texture /// unit as defined by the corresponding image description. The method /// will fail if there are not enough available image units to bind to. - bool bindImage(MTL::RenderCommandEncoder *renderCmdEncoder, int textureUnit, + bool bindImage(id renderCmdEncoder, int textureUnit, ImagePtr image); public: - MTL::SamplerState * + id getSamplerState(const ImageSamplingProperties &samplingProperties); /// Unbind an image. bool unbindImage(ImagePtr image) override; - MTL::Texture *getMTLTextureForImage(unsigned int index) const; - MTL::SamplerState *getMTLSamplerStateForImage(unsigned int index); + id getMTLTextureForImage(unsigned int index) const; + id getMTLSamplerStateForImage(unsigned int index); /// Create rendering resources for the given image. bool createRenderResources(ImagePtr image, bool generateMipMaps) override; @@ -68,39 +68,40 @@ class MX_RENDERMSL_API MetalTextureHandler : public ImageHandler { int getBoundTextureLocation(unsigned int resourceId); /// Utility to map an address mode enumeration to an Metal address mode - static MTL::SamplerAddressMode + static MTLSamplerAddressMode mapAddressModeToMetal(ImageSamplingProperties::AddressMode addressModeEnum); /// Utility to map a filter type enumeration to an Metal filter type - static void mapFilterTypeToMetal( - ImageSamplingProperties::FilterType filterTypeEnum, bool enableMipmaps, - MTL::SamplerMinMagFilter &minMagFilter, MTL::SamplerMipFilter &mipFilter); + static void + mapFilterTypeToMetal(ImageSamplingProperties::FilterType filterTypeEnum, + bool enableMipmaps, MTLSamplerMinMagFilter &minMagFilter, + MTLSamplerMipFilter &mipFilter); /// Utility to map generic texture properties to Metal texture formats. static void mapTextureFormatToMetal(Image::BaseType baseType, unsigned int channelCount, bool srgb, - MTL::DataType &dataType, - MTL::PixelFormat &pixelFormat); + MTLDataType &dataType, + MTLPixelFormat &pixelFormat); static size_t getTextureBaseTypeSize(Image::BaseType baseType); - MTL::Texture *getAssociatedMetalTexture(ImagePtr image); + id getAssociatedMetalTexture(ImagePtr image); protected: // Protected constructor - MetalTextureHandler(MTL::Device *device, ImageLoaderPtr imageLoader); + MetalTextureHandler(id device, ImageLoaderPtr imageLoader); protected: std::vector _boundTextureLocations; - std::unordered_map _metalTextureMap; + std::unordered_map> _metalTextureMap; std::unordered_map> _imageBindingInfo; - std::unordered_map, ImageSamplingKeyHasher> _imageSamplerStateMap; - MTL::Device *_device = nil; + id _device = nil; }; MATERIALX_NAMESPACE_END diff --git a/Sources/MaterialX/include/MaterialX/MXRenderMslPipelineStateObject.h b/Sources/MaterialX/include/MaterialX/MXRenderMslPipelineStateObject.h index 08dd830a..cd8606d2 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderMslPipelineStateObject.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderMslPipelineStateObject.h @@ -18,7 +18,7 @@ #include -#include +#import MATERIALX_NAMESPACE_BEGIN @@ -73,8 +73,8 @@ class MX_RENDERMSL_API MslProgram { /// An exception is thrown if the program cannot be created. /// The exception will contain a list of program creation errors. /// @return Pipeline State Object identifier. - MTL::RenderPipelineState *build(MTL::Device *device, - MetalFramebufferPtr frameBuffer); + id build(id device, + MetalFramebufferPtr frameBuffer); /// Structure to hold information about program inputs. /// The structure is populated by directly scanning the program so may not @@ -145,7 +145,7 @@ class MX_RENDERMSL_API MslProgram { /// Bind the pipeline state object to the command encoder. /// @param renderCmdEncoder encoder that binds the pipeline state object. /// @return False if failed - bool bind(MTL::RenderCommandEncoder *renderCmdEncoder); + bool bind(id renderCmdEncoder); /// Bind inputs /// @param renderCmdEncoder encoder that inputs will be bound to. @@ -154,7 +154,7 @@ class MX_RENDERMSL_API MslProgram { /// @param imageHandler /// @param lightHandler /// @return void - No return value - void prepareUsedResources(MTL::RenderCommandEncoder *renderCmdEncoder, + void prepareUsedResources(id renderCmdEncoder, CameraPtr cam, GeometryHandlerPtr geometryHandler, ImageHandlerPtr imageHandler, LightHandlerPtr lightHandler); @@ -173,17 +173,17 @@ class MX_RENDERMSL_API MslProgram { /// being bind to /// @param inputs Attribute inputs to bind to /// @param mesh Mesh containing streams to bind - void bindAttribute(MTL::RenderCommandEncoder *renderCmdEncoder, + void bindAttribute(id renderCmdEncoder, const MslProgram::InputMap &inputs, MeshPtr mesh); /// Bind input geometry partition (indexing) void bindPartition(MeshPartitionPtr partition); /// Bind input geometry streams - void bindMesh(MTL::RenderCommandEncoder *renderCmdEncoder, MeshPtr mesh); + void bindMesh(id renderCmdEncoder, MeshPtr mesh); /// Queries the index buffer assinged to a mesh partition - MTL::Buffer *getIndexBuffer(MeshPartitionPtr mesh) { + id getIndexBuffer(MeshPartitionPtr mesh) { if (_indexBufferIds.find(mesh) != _indexBufferIds.end()) return _indexBufferIds[mesh]; return nil; @@ -193,7 +193,7 @@ class MX_RENDERMSL_API MslProgram { void unbindGeometry(); /// Bind any input textures - void bindTextures(MTL::RenderCommandEncoder *renderCmdEncoder, + void bindTextures(id renderCmdEncoder, LightHandlerPtr lightHandler, ImageHandlerPtr imageHandler); void bindTexture(ImageHandlerPtr imageHandler, string shaderTextureName, @@ -251,24 +251,24 @@ class MX_RENDERMSL_API MslProgram { const InputMap &uniformList); // Bind an individual texture to a program uniform location - ImagePtr bindTexture(MTL::RenderCommandEncoder *renderCmdEncoder, + ImagePtr bindTexture(id renderCmdEncoder, unsigned int uniformLocation, const FilePath &filePath, ImageSamplingProperties samplingProperties, ImageHandlerPtr imageHandler); // Bind an individual texture to a program uniform location - ImagePtr bindTexture(MTL::RenderCommandEncoder *renderCmdEncoder, + ImagePtr bindTexture(id renderCmdEncoder, unsigned int uniformLocation, ImagePtr imagePtr, ImageHandlerPtr imageHandler); - void bindUniformBuffers(MTL::RenderCommandEncoder *renderCmdEncoder, + void bindUniformBuffers(id renderCmdEncoder, LightHandlerPtr lightHandler, CameraPtr camera); // Delete any currently created pso void reset(); // Utility to map a MaterialX type to an METAL type - static MTL::DataType mapTypeToMetalType(const TypeDesc *type); + static MTLDataType mapTypeToMetalType(const TypeDesc *type); private: // Stages used to create program @@ -277,8 +277,8 @@ class MX_RENDERMSL_API MslProgram { // Generated pipeline state object. A non-zero number indicates a valid shader // program. - MTL::RenderPipelineState *_pso = nil; - MTL::RenderPipelineReflection *_psoReflection = nil; + id _pso = nil; + MTLRenderPipelineReflection *_psoReflection = nil; // List of program input uniforms InputMap _uniformList; @@ -293,16 +293,16 @@ class MX_RENDERMSL_API MslProgram { // Attribute buffer resource handles // for each attribute identifier in the program - std::unordered_map _attributeBufferIds; + std::unordered_map> _attributeBufferIds; // Attribute indexing buffer handle - std::map _indexBufferIds; + std::map> _indexBufferIds; // Program texture map std::unordered_map _programTextures; // Metal Device Object - MTL::Device *_device = nil; + id _device = nil; // Currently bound mesh MeshPtr _boundMesh = nullptr; diff --git a/Sources/MaterialX/include/MaterialX/MXRenderMslRenderer.h b/Sources/MaterialX/include/MaterialX/MXRenderMslRenderer.h index a1861c3b..5f402928 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderMslRenderer.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderMslRenderer.h @@ -17,7 +17,7 @@ #include -#include +#import MATERIALX_NAMESPACE_BEGIN @@ -58,7 +58,7 @@ class MX_RENDERMSL_API MslRenderer : public ShaderRenderer { } /// Returns Metal Device used for rendering - MTL::Device *getMetalDevice() const; + id getMetalDevice() const; /// Destructor virtual ~MslRenderer() {} @@ -133,9 +133,9 @@ class MX_RENDERMSL_API MslRenderer : public ShaderRenderer { private: MslProgramPtr _program; - MTL::Device *_device = nil; - MTL::CommandQueue *_cmdQueue = nil; - MTL::CommandBuffer *_cmdBuffer = nil; + id _device = nil; + id _cmdQueue = nil; + id _cmdBuffer = nil; MetalFramebufferPtr _framebuffer; diff --git a/Sources/MaterialX/include/MaterialX/MaterialX.h b/Sources/MaterialX/include/MaterialX/MaterialX.h index d91cad2e..52beee67 100644 --- a/Sources/MaterialX/include/MaterialX/MaterialX.h +++ b/Sources/MaterialX/include/MaterialX/MaterialX.h @@ -142,8 +142,8 @@ #include #endif /* defined(__APPLE__) */ #include -#include #include +#include #include #include #include @@ -193,13 +193,13 @@ #include #if defined(__APPLE__) -# include -# include -# include +#include +#include +#include #else /* defined(__APPLE__) */ -# include -# include -# include +#include +#include +#include #endif /* !defined(__APPLE__) */ #include diff --git a/Sources/MaterialX/include/MaterialX/StbImage.h b/Sources/MaterialX/include/MaterialX/StbImage.h index 196dfd5c..16e27947 100644 --- a/Sources/MaterialX/include/MaterialX/StbImage.h +++ b/Sources/MaterialX/include/MaterialX/StbImage.h @@ -3,7 +3,8 @@ Do this: #define STB_IMAGE_IMPLEMENTATION - before you include this file in *one* C or C++ file to create the implementation. + before you include this file in *one* C or C++ file to create the +implementation. // i.e. it should look like this: #include ... @@ -13,15 +14,16 @@ #include "stb_image.h" You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. - And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free + And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using +malloc,realloc,free QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface - JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) - PNG 1/2/4/8/16-bit-per-channel + JPEG baseline & progressive (12 bpc/arithmetic not supported, same as +stock IJG lib) PNG 1/2/4/8/16-bit-per-channel TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE @@ -51,21 +53,18 @@ RECENT REVISION HISTORY: 2.23 (2019-08-11) fix clang static analysis warning 2.22 (2019-03-04) gif fixes, fix warnings 2.21 (2019-02-25) fix typo in comment - 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs - 2.19 (2018-02-11) fix warning - 2.18 (2018-01-30) fix warnings + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and +platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings - 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes - 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC - 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs - 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes - 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes - 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 - RGB-format JPEG; remove white matting in PSD; - allocate large structures on the stack; - correct channel count for PNG & BMP - 2.10 (2016-01-22) avoid warning introduced in 2.09 - 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED + 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; +bugfixes 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE +detection on GCC 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for +Imagenet JPGs 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; +fixes 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 +(2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 RGB-format JPEG; remove +white matting in PSD; allocate large structures on the stack; correct channel +count for PNG & BMP 2.10 (2016-01-22) avoid warning introduced in 2.09 2.09 +(2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED See end of file for full revision history. @@ -83,29 +82,29 @@ RECENT REVISION HISTORY: github:urraka (animated gif) Junggon Kim (PNM comments) Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) socks-the-fox (16-bit PNG) - Jeremy Sawicki (handle all ImageNet JPGs) - Optimizations & bugfixes Mikhail Morozov (1-bit BMP) + Jeremy Sawicki (handle all ImageNet +JPGs) Optimizations & bugfixes Mikhail Morozov (1-bit BMP) Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) Arseny Kapoulkine John-Mark Allen Carmelo J Fdez-Aguera Bug & warning fixes - Marc LeBlanc David Woo Guillaume George Martins Mozeiko - Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan - Dave Moore Roy Eltham Hayaki Saito Nathan Reed + Marc LeBlanc David Woo Guillaume George Martins +Mozeiko Christpher Lloyd Jerry Jansson Joseph Thomson Phil +Jordan Dave Moore Roy Eltham Hayaki Saito Nathan Reed Won Chun Luke Graham Johan Duparc Nick Verigakis the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh - Janez Zemva John Bartholomew Michal Cichon github:romigrou + Janez Zemva John Bartholomew Michal Cichon github:romigrou Jonathan Blow Ken Hamada Tero Hanninen github:svdijk Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex Ryamond Barbiero Paul Du Bois Engin Manap github:grim210 Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus - Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo - Christian Floisand Kevin Schmidt JR Smith github:darealshinji - Blazej Dariusz Roszkowski github:Michaelangel007 + Julian Raschke Gregory Mullen Baldur Karlsson +github:poppolopoppo Christian Floisand Kevin Schmidt JR Smith +github:darealshinji Blazej Dariusz Roszkowski github:Michaelangel007 */ #ifndef STBI_INCLUDE_STB_IMAGE_H @@ -124,14 +123,15 @@ RECENT REVISION HISTORY: // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel -// // ... but 'n' will always be the number that it would have been if you said 0 -// stbi_image_free(data) +// // ... but 'n' will always be the number that it would have been if you +// said 0 stbi_image_free(data) // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *channels_in_file -- outputs # of image components in image file -// int desired_channels -- if non-zero, # of image components requested in result +// int desired_channels -- if non-zero, # of image components requested in +// result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data, or NULL on an allocation failure or if the image is @@ -159,8 +159,8 @@ RECENT REVISION HISTORY: // and *x, *y, *channels_in_file will be unchanged. The function // stbi_failure_reason() can be queried for an extremely brief, end-user // unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS -// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly -// more user-friendly ones. +// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get +// slightly more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // @@ -184,11 +184,12 @@ RECENT REVISION HISTORY: // 2. easy to maintain // 3. good performance // -// Sometimes I let "good performance" creep up in priority over "easy to maintain", -// and for best performance I may provide less-easy-to-use APIs that give higher -// performance, in addition to the easy-to-use ones. Nevertheless, it's important -// to keep in mind that from the standpoint of you, a client of this library, -// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. +// Sometimes I let "good performance" creep up in priority over "easy to +// maintain", and for best performance I may provide less-easy-to-use APIs that +// give higher performance, in addition to the easy-to-use ones. Nevertheless, +// it's important to keep in mind that from the standpoint of you, a client of +// this library, all you care about is #1 and #3, and stb libraries DO NOT +// emphasize #3 above all. // // Some secondary priorities arise directly from the first two, some of which // provide more explicit reasons why performance can't be emphasized. @@ -207,7 +208,8 @@ RECENT REVISION HISTORY: // overhead. // // The three functions you must define are "read" (reads some bytes of data), -// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). +// "skip" (skips some bytes of data), "eof" (reports if the stream is at the +// end). // // =========================================================================== // @@ -235,10 +237,11 @@ RECENT REVISION HISTORY: // HDR image support (disable by defining STBI_NO_HDR) // // stb_image supports loading HDR images in general, and currently the Radiance -// .HDR file format specifically. You can still load any file through the existing -// interface; if you attempt to load an HDR file, it will be automatically remapped -// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; -// both of these constants can be reconfigured through this interface: +// .HDR file format specifically. You can still load any file through the +// existing interface; if you attempt to load an HDR file, it will be +// automatically remapped to LDR, assuming gamma 2.2 and an arbitrary scale +// factor defaulting to 1; both of these constants can be reconfigured through +// this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); @@ -316,21 +319,19 @@ RECENT REVISION HISTORY: // want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB // - #ifndef STBI_NO_STDIO #include #endif // STBI_NO_STDIO #define STBI_VERSION 1 -enum -{ - STBI_default = 0, // only used for desired_channels +enum { + STBI_default = 0, // only used for desired_channels - STBI_grey = 1, - STBI_grey_alpha = 2, - STBI_rgb = 3, - STBI_rgb_alpha = 4 + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4 }; #include @@ -358,11 +359,13 @@ extern "C" { // load image by filename, open file, or memory buffer // -typedef struct -{ - int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read - void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative - int (*eof) (void *user); // returns nonzero if we are at end of file/data +typedef struct { + int (*read)(void *user, char *data, + int size); // fill 'data' with 'size' bytes. return number of + // bytes actually read + void (*skip)(void *user, int n); // skip the next 'n' bytes, or 'unget' the + // last -n bytes if negative + int (*eof)(void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; //////////////////////////////////// @@ -370,21 +373,33 @@ typedef struct // 8-bits-per-channel interface // -STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, + int *y, int *channels_in_file, + int desired_channels); +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, + void *user, int *x, int *y, + int *channels_in_file, + int desired_channels); #ifndef STBI_NO_STDIO -STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); -// for stbi_load_from_file, file pointer is left pointing immediately after image +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, + int *channels_in_file, int desired_channels); +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, + int *channels_in_file, + int desired_channels); +// for stbi_load_from_file, file pointer is left pointing immediately after +// image #endif #ifndef STBI_NO_GIF -STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, + int **delays, int *x, int *y, int *z, + int *comp, int req_comp); #endif #ifdef STBI_WINDOWS_UTF8 -STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, + const wchar_t *input); #endif //////////////////////////////////// @@ -392,12 +407,20 @@ STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wch // 16-bits-per-channel interface // -STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, + int *x, int *y, int *channels_in_file, + int desired_channels); +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, + void *user, int *x, int *y, + int *channels_in_file, + int desired_channels); #ifndef STBI_NO_STDIO -STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, + int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, + int *channels_in_file, + int desired_channels); #endif //////////////////////////////////// @@ -405,78 +428,96 @@ STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_i // float-per-channel interface // #ifndef STBI_NO_LINEAR - STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); - STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, + int *y, int *channels_in_file, + int desired_channels); +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, + void *user, int *x, int *y, + int *channels_in_file, + int desired_channels); - #ifndef STBI_NO_STDIO - STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); - STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); - #endif +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, + int *channels_in_file, int desired_channels); +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, + int *channels_in_file, + int desired_channels); +#endif #endif #ifndef STBI_NO_HDR - STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); - STBIDEF void stbi_hdr_to_ldr_scale(float scale); +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); +STBIDEF void stbi_hdr_to_ldr_scale(float scale); #endif // STBI_NO_HDR #ifndef STBI_NO_LINEAR - STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); - STBIDEF void stbi_ldr_to_hdr_scale(float scale); +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); +STBIDEF void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_LINEAR // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, + void *user); +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename); -STBIDEF int stbi_is_hdr_from_file(FILE *f); +STBIDEF int stbi_is_hdr(char const *filename); +STBIDEF int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO - // get a VERY brief reason for failure // NOT THREADSAFE -STBIDEF const char *stbi_failure_reason (void); +STBIDEF const char *stbi_failure_reason(void); // free the loaded image -- this is just free() -STBIDEF void stbi_image_free (void *retval_from_stbi_load); +STBIDEF void stbi_image_free(void *retval_from_stbi_load); // get image dimensions & components without fully decoding -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); -STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); -STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, + int *y, int *comp); +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, + int *x, int *y, int *comp); +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, + void *user); #ifndef STBI_NO_STDIO -STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); -STBIDEF int stbi_is_16_bit (char const *filename); -STBIDEF int stbi_is_16_bit_from_file(FILE *f); +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp); +STBIDEF int stbi_is_16_bit(char const *filename); +STBIDEF int stbi_is_16_bit_from_file(FILE *f); #endif - - // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); +STBIDEF void +stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); -// flip the image vertically, so the first pixel in the output array is the bottom left +// flip the image vertically, so the first pixel in the output array is the +// bottom left STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); // ZLIB client - used by PNG, available for other purposes -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, + int initial_size, int *outlen); +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, + int len, + int initial_size, + int *outlen, + int parse_header); STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, + const char *ibuffer, int ilen); +STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, + int *outlen); +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, + const char *ibuffer, int ilen); #ifdef __cplusplus } @@ -489,52 +530,53 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch #ifdef STB_IMAGE_IMPLEMENTATION -#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ - || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ - || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ - || defined(STBI_ONLY_ZLIB) - #ifndef STBI_ONLY_JPEG - #define STBI_NO_JPEG - #endif - #ifndef STBI_ONLY_PNG - #define STBI_NO_PNG - #endif - #ifndef STBI_ONLY_BMP - #define STBI_NO_BMP - #endif - #ifndef STBI_ONLY_PSD - #define STBI_NO_PSD - #endif - #ifndef STBI_ONLY_TGA - #define STBI_NO_TGA - #endif - #ifndef STBI_ONLY_GIF - #define STBI_NO_GIF - #endif - #ifndef STBI_ONLY_HDR - #define STBI_NO_HDR - #endif - #ifndef STBI_ONLY_PIC - #define STBI_NO_PIC - #endif - #ifndef STBI_ONLY_PNM - #define STBI_NO_PNM - #endif +#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || \ + defined(STBI_ONLY_BMP) || defined(STBI_ONLY_TGA) || \ + defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) || \ + defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || \ + defined(STBI_ONLY_PNM) || defined(STBI_ONLY_ZLIB) +#ifndef STBI_ONLY_JPEG +#define STBI_NO_JPEG +#endif +#ifndef STBI_ONLY_PNG +#define STBI_NO_PNG +#endif +#ifndef STBI_ONLY_BMP +#define STBI_NO_BMP +#endif +#ifndef STBI_ONLY_PSD +#define STBI_NO_PSD +#endif +#ifndef STBI_ONLY_TGA +#define STBI_NO_TGA +#endif +#ifndef STBI_ONLY_GIF +#define STBI_NO_GIF +#endif +#ifndef STBI_ONLY_HDR +#define STBI_NO_HDR +#endif +#ifndef STBI_ONLY_PIC +#define STBI_NO_PIC +#endif +#ifndef STBI_ONLY_PNM +#define STBI_NO_PNM +#endif #endif -#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) +#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && \ + !defined(STBI_NO_ZLIB) #define STBI_NO_ZLIB #endif - +#include #include #include // ptrdiff_t on osx #include #include -#include #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -#include // ldexp, pow +#include // ldexp, pow #endif #ifndef STBI_NO_STDIO @@ -552,38 +594,36 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch #define STBI_EXTERN extern #endif - #ifndef _MSC_VER - #ifdef __cplusplus - #define stbi_inline inline - #else - #define stbi_inline - #endif +#ifdef __cplusplus +#define stbi_inline inline #else - #define stbi_inline __forceinline +#define stbi_inline +#endif +#else +#define stbi_inline __forceinline #endif - #ifdef _MSC_VER typedef unsigned short stbi__uint16; -typedef signed short stbi__int16; -typedef unsigned int stbi__uint32; -typedef signed int stbi__int32; +typedef signed short stbi__int16; +typedef unsigned int stbi__uint32; +typedef signed int stbi__int32; #else #include typedef uint16_t stbi__uint16; -typedef int16_t stbi__int16; +typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; -typedef int32_t stbi__int32; +typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong -typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; +typedef unsigned char validate_uint32[sizeof(stbi__uint32) == 4 ? 1 : -1]; #ifdef _MSC_VER -#define STBI_NOTUSED(v) (void)(v) +#define STBI_NOTUSED(v) (void)(v) #else -#define STBI_NOTUSED(v) (void)sizeof(v) +#define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER @@ -591,27 +631,30 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #endif #ifdef STBI_HAS_LROTL - #define stbi_lrot(x,y) _lrotl(x,y) +#define stbi_lrot(x, y) _lrotl(x, y) #else - #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) +#define stbi_lrot(x, y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif -#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) +#if defined(STBI_MALLOC) && defined(STBI_FREE) && \ + (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) // ok -#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) +#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && \ + !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) // ok #else -#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." +#error \ + "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." #endif #ifndef STBI_MALLOC -#define STBI_MALLOC(sz) malloc(sz) -#define STBI_REALLOC(p,newsz) realloc(p,newsz) -#define STBI_FREE(p) free(p) +#define STBI_MALLOC(sz) malloc(sz) +#define STBI_REALLOC(p, newsz) realloc(p, newsz) +#define STBI_FREE(p) free(p) #endif #ifndef STBI_REALLOC_SIZED -#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) +#define STBI_REALLOC_SIZED(p, oldsz, newsz) STBI_REALLOC(p, newsz) #endif // x86/x64 detection @@ -621,7 +664,8 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #define STBI__X86_TARGET #endif -#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && \ + !defined(STBI_NO_SIMD) // gcc doesn't support sse2 intrinsics unless you compile with -msse2, // which in turn means it gets to use SSE2 everywhere. This is unfortunate, // but previous attempts to provide the SSE2 functions with runtime @@ -632,8 +676,10 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #define STBI_NO_SIMD #endif -#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) -// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET +#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && \ + !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid +// STBI__X64_TARGET // // 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the // Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. @@ -643,44 +689,43 @@ typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; // See https://github.com/nothings/stb/issues/81 for more information. // // So default to no SSE2 on 32-bit MinGW. If you've read this far and added -// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. +// -mstackrealign to your build settings, feel free to #define +// STBI_MINGW_ENABLE_SSE2. #define STBI_NO_SIMD #endif -#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) +#if !defined(STBI_NO_SIMD) && \ + (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) #define STBI_SSE2 #include #ifdef _MSC_VER -#if _MSC_VER >= 1400 // not VC6 -#include // __cpuid -static int stbi__cpuid3(void) -{ - int info[4]; - __cpuid(info,1); - return info[3]; +#if _MSC_VER >= 1400 // not VC6 +#include // __cpuid +static int stbi__cpuid3(void) { + int info[4]; + __cpuid(info, 1); + return info[3]; } #else -static int stbi__cpuid3(void) -{ - int res; - __asm { +static int stbi__cpuid3(void) { + int res; + __asm { mov eax,1 cpuid mov res,edx - } - return res; + } + return res; } #endif #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) -static int stbi__sse2_available(void) -{ - int info3 = stbi__cpuid3(); - return ((info3 >> 26) & 1) != 0; +static int stbi__sse2_available(void) { + int info3 = stbi__cpuid3(); + return ((info3 >> 26) & 1) != 0; } #endif @@ -688,12 +733,11 @@ static int stbi__sse2_available(void) #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) -static int stbi__sse2_available(void) -{ - // If we're even attempting to compile this on GCC/Clang, that means - // -msse2 is on, which means the compiler is allowed to use SSE2 - // instructions at will, and so are we. - return 1; +static int stbi__sse2_available(void) { + // If we're even attempting to compile this on GCC/Clang, that means + // -msse2 is on, which means the compiler is allowed to use SSE2 + // instructions at will, and so are we. + return 1; } #endif @@ -721,176 +765,164 @@ static int stbi__sse2_available(void) // stbi__context structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information -typedef struct -{ - stbi__uint32 img_x, img_y; - int img_n, img_out_n; +typedef struct { + stbi__uint32 img_x, img_y; + int img_n, img_out_n; - stbi_io_callbacks io; - void *io_user_data; + stbi_io_callbacks io; + void *io_user_data; - int read_from_callbacks; - int buflen; - stbi_uc buffer_start[128]; + int read_from_callbacks; + int buflen; + stbi_uc buffer_start[128]; - stbi_uc *img_buffer, *img_buffer_end; - stbi_uc *img_buffer_original, *img_buffer_original_end; + stbi_uc *img_buffer, *img_buffer_end; + stbi_uc *img_buffer_original, *img_buffer_original_end; } stbi__context; - static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context -static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) -{ - s->io.read = NULL; - s->read_from_callbacks = 0; - s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; - s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; +static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { + s->io.read = NULL; + s->read_from_callbacks = 0; + s->img_buffer = s->img_buffer_original = (stbi_uc *)buffer; + s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *)buffer + len; } // initialize a callback-based context -static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) -{ - s->io = *c; - s->io_user_data = user; - s->buflen = sizeof(s->buffer_start); - s->read_from_callbacks = 1; - s->img_buffer_original = s->buffer_start; - stbi__refill_buffer(s); - s->img_buffer_original_end = s->img_buffer_end; +static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, + void *user) { + s->io = *c; + s->io_user_data = user; + s->buflen = sizeof(s->buffer_start); + s->read_from_callbacks = 1; + s->img_buffer_original = s->buffer_start; + stbi__refill_buffer(s); + s->img_buffer_original_end = s->img_buffer_end; } #ifndef STBI_NO_STDIO -static int stbi__stdio_read(void *user, char *data, int size) -{ - return (int) fread(data,1,size,(FILE*) user); +static int stbi__stdio_read(void *user, char *data, int size) { + return (int)fread(data, 1, size, (FILE *)user); } -static void stbi__stdio_skip(void *user, int n) -{ - fseek((FILE*) user, n, SEEK_CUR); +static void stbi__stdio_skip(void *user, int n) { + fseek((FILE *)user, n, SEEK_CUR); } -static int stbi__stdio_eof(void *user) -{ - return feof((FILE*) user); -} +static int stbi__stdio_eof(void *user) { return feof((FILE *)user); } -static stbi_io_callbacks stbi__stdio_callbacks = -{ - stbi__stdio_read, - stbi__stdio_skip, - stbi__stdio_eof, +static stbi_io_callbacks stbi__stdio_callbacks = { + stbi__stdio_read, + stbi__stdio_skip, + stbi__stdio_eof, }; -static void stbi__start_file(stbi__context *s, FILE *f) -{ - stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); +static void stbi__start_file(stbi__context *s, FILE *f) { + stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *)f); } -//static void stop_file(stbi__context *s) { } +// static void stop_file(stbi__context *s) { } #endif // !STBI_NO_STDIO -static void stbi__rewind(stbi__context *s) -{ - // conceptually rewind SHOULD rewind to the beginning of the stream, - // but we just rewind to the beginning of the initial buffer, because - // we only use it after doing 'test', which only ever looks at at most 92 bytes - s->img_buffer = s->img_buffer_original; - s->img_buffer_end = s->img_buffer_original_end; +static void stbi__rewind(stbi__context *s) { + // conceptually rewind SHOULD rewind to the beginning of the stream, + // but we just rewind to the beginning of the initial buffer, because + // we only use it after doing 'test', which only ever looks at at most 92 + // bytes + s->img_buffer = s->img_buffer_original; + s->img_buffer_end = s->img_buffer_original_end; } -enum -{ - STBI_ORDER_RGB, - STBI_ORDER_BGR -}; +enum { STBI_ORDER_RGB, STBI_ORDER_BGR }; -typedef struct -{ - int bits_per_channel; - int num_channels; - int channel_order; +typedef struct { + int bits_per_channel; + int num_channels; + int channel_order; } stbi__result_info; #ifndef STBI_NO_JPEG -static int stbi__jpeg_test(stbi__context *s); -static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__jpeg_test(stbi__context *s); +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNG -static int stbi__png_test(stbi__context *s); -static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); -static int stbi__png_is16(stbi__context *s); +static int stbi__png_test(stbi__context *s); +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__png_is16(stbi__context *s); #endif #ifndef STBI_NO_BMP -static int stbi__bmp_test(stbi__context *s); -static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__bmp_test(stbi__context *s); +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_TGA -static int stbi__tga_test(stbi__context *s); -static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__tga_test(stbi__context *s); +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s); -static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); -static int stbi__psd_is16(stbi__context *s); +static int stbi__psd_test(stbi__context *s); +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri, int bpc); +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__psd_is16(stbi__context *s); #endif #ifndef STBI_NO_HDR -static int stbi__hdr_test(stbi__context *s); -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__hdr_test(stbi__context *s); +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PIC -static int stbi__pic_test(stbi__context *s); -static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__pic_test(stbi__context *s); +static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_GIF -static int stbi__gif_test(stbi__context *s); -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__gif_test(stbi__context *s); +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, + int *z, int *comp, int req_comp); +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNM -static int stbi__pnm_test(stbi__context *s); -static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__pnm_test(stbi__context *s); +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri); +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); #endif // this is not threadsafe static const char *stbi__g_failure_reason; -STBIDEF const char *stbi_failure_reason(void) -{ - return stbi__g_failure_reason; -} +STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } -static int stbi__err(const char *str) -{ - stbi__g_failure_reason = str; - return 0; +static int stbi__err(const char *str) { + stbi__g_failure_reason = str; + return 0; } -static void *stbi__malloc(size_t size) -{ - return STBI_MALLOC(size); -} +static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } // stb_image uses ints pervasively, including for offset calculations. // therefore the largest decoded image size we can support with the @@ -904,66 +936,66 @@ static void *stbi__malloc(size_t size) // return 1 if the sum is valid, 0 on overflow. // negative terms are considered invalid. -static int stbi__addsizes_valid(int a, int b) -{ - if (b < 0) return 0; - // now 0 <= b <= INT_MAX, hence also - // 0 <= INT_MAX - b <= INTMAX. - // And "a + b <= INT_MAX" (which might overflow) is the - // same as a <= INT_MAX - b (no overflow) - return a <= INT_MAX - b; +static int stbi__addsizes_valid(int a, int b) { + if (b < 0) + return 0; + // now 0 <= b <= INT_MAX, hence also + // 0 <= INT_MAX - b <= INTMAX. + // And "a + b <= INT_MAX" (which might overflow) is the + // same as a <= INT_MAX - b (no overflow) + return a <= INT_MAX - b; } // returns 1 if the product is valid, 0 on overflow. // negative factors are considered invalid. -static int stbi__mul2sizes_valid(int a, int b) -{ - if (a < 0 || b < 0) return 0; - if (b == 0) return 1; // mul-by-0 is always safe - // portable way to check for no overflows in a*b - return a <= INT_MAX/b; +static int stbi__mul2sizes_valid(int a, int b) { + if (a < 0 || b < 0) + return 0; + if (b == 0) + return 1; // mul-by-0 is always safe + // portable way to check for no overflows in a*b + return a <= INT_MAX / b; } // returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow -static int stbi__mad2sizes_valid(int a, int b, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); +static int stbi__mad2sizes_valid(int a, int b, int add) { + return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a * b, add); } // returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow -static int stbi__mad3sizes_valid(int a, int b, int c, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && - stbi__addsizes_valid(a*b*c, add); +static int stbi__mad3sizes_valid(int a, int b, int c, int add) { + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a * b, c) && + stbi__addsizes_valid(a * b * c, add); } -// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow +// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't +// overflow #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && - stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); +static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) { + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a * b, c) && + stbi__mul2sizes_valid(a * b * c, d) && + stbi__addsizes_valid(a * b * c * d, add); } #endif // mallocs with size overflow checking -static void *stbi__malloc_mad2(int a, int b, int add) -{ - if (!stbi__mad2sizes_valid(a, b, add)) return NULL; - return stbi__malloc(a*b + add); +static void *stbi__malloc_mad2(int a, int b, int add) { + if (!stbi__mad2sizes_valid(a, b, add)) + return NULL; + return stbi__malloc(a * b + add); } -static void *stbi__malloc_mad3(int a, int b, int c, int add) -{ - if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; - return stbi__malloc(a*b*c + add); +static void *stbi__malloc_mad3(int a, int b, int c, int add) { + if (!stbi__mad3sizes_valid(a, b, c, add)) + return NULL; + return stbi__malloc(a * b * c + add); } #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) -{ - if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; - return stbi__malloc(a*b*c*d + add); +static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) { + if (!stbi__mad4sizes_valid(a, b, c, d, add)) + return NULL; + return stbi__malloc(a * b * c * d + add); } #endif @@ -972,395 +1004,435 @@ static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) // stbi__errpuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS - #define stbi__err(x,y) 0 +#define stbi__err(x, y) 0 #elif defined(STBI_FAILURE_USERMSG) - #define stbi__err(x,y) stbi__err(y) +#define stbi__err(x, y) stbi__err(y) #else - #define stbi__err(x,y) stbi__err(x) +#define stbi__err(x, y) stbi__err(x) #endif -#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) -#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) +#define stbi__errpf(x, y) ((float *)(size_t)(stbi__err(x, y) ? NULL : NULL)) +#define stbi__errpuc(x, y) \ + ((unsigned char *)(size_t)(stbi__err(x, y) ? NULL : NULL)) -STBIDEF void stbi_image_free(void *retval_from_stbi_load) -{ - STBI_FREE(retval_from_stbi_load); +STBIDEF void stbi_image_free(void *retval_from_stbi_load) { + STBI_FREE(retval_from_stbi_load); } #ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); #endif #ifndef STBI_NO_HDR -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); #endif static int stbi__vertically_flip_on_load = 0; -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) -{ - stbi__vertically_flip_on_load = flag_true_if_should_flip; -} - -static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) -{ - memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields - ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed - ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order - ri->num_channels = 0; - - #ifndef STBI_NO_JPEG - if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PNG - if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_BMP - if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_GIF - if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PSD - if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); - #endif - #ifndef STBI_NO_PIC - if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PNM - if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); - #endif - - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); - return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - - #ifndef STBI_NO_TGA - // test tga last because it's a crappy test! - if (stbi__tga_test(s)) - return stbi__tga_load(s,x,y,comp,req_comp, ri); - #endif - - return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); -} - -static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) -{ - int i; - int img_len = w * h * channels; - stbi_uc *reduced; - - reduced = (stbi_uc *) stbi__malloc(img_len); - if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); - - for (i = 0; i < img_len; ++i) - reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling - - STBI_FREE(orig); - return reduced; +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { + stbi__vertically_flip_on_load = flag_true_if_should_flip; } -static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) -{ - int i; - int img_len = w * h * channels; - stbi__uint16 *enlarged; +static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri, int bpc) { + memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields + ri->bits_per_channel = + 8; // default is 8 so most paths don't have to be changed + ri->channel_order = + STBI_ORDER_RGB; // all current input & output are this, but this is here + // so we can add BGR order + ri->num_channels = 0; - enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); - if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); +#ifndef STBI_NO_JPEG + if (stbi__jpeg_test(s)) + return stbi__jpeg_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PNG + if (stbi__png_test(s)) + return stbi__png_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_BMP + if (stbi__bmp_test(s)) + return stbi__bmp_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_GIF + if (stbi__gif_test(s)) + return stbi__gif_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PSD + if (stbi__psd_test(s)) + return stbi__psd_load(s, x, y, comp, req_comp, ri, bpc); +#endif +#ifndef STBI_NO_PIC + if (stbi__pic_test(s)) + return stbi__pic_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PNM + if (stbi__pnm_test(s)) + return stbi__pnm_load(s, x, y, comp, req_comp, ri); +#endif - for (i = 0; i < img_len; ++i) - enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff +#ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + float *hdr = stbi__hdr_load(s, x, y, comp, req_comp, ri); + return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } +#endif - STBI_FREE(orig); - return enlarged; -} +#ifndef STBI_NO_TGA + // test tga last because it's a crappy test! + if (stbi__tga_test(s)) + return stbi__tga_load(s, x, y, comp, req_comp, ri); +#endif -static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) -{ - int row; - size_t bytes_per_row = (size_t)w * bytes_per_pixel; - stbi_uc temp[2048]; - stbi_uc *bytes = (stbi_uc *)image; - - for (row = 0; row < (h>>1); row++) { - stbi_uc *row0 = bytes + row*bytes_per_row; - stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; - // swap row0 with row1 - size_t bytes_left = bytes_per_row; - while (bytes_left) { - size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); - memcpy(temp, row0, bytes_copy); - memcpy(row0, row1, bytes_copy); - memcpy(row1, temp, bytes_copy); - row0 += bytes_copy; - row1 += bytes_copy; - bytes_left -= bytes_copy; - } - } + return stbi__errpuc("unknown image type", + "Image not of any known type, or corrupt"); +} + +static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, + int channels) { + int i; + int img_len = w * h * channels; + stbi_uc *reduced; + + reduced = (stbi_uc *)stbi__malloc(img_len); + if (reduced == NULL) + return stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + reduced[i] = + (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient + // approx of 16->8 bit scaling + + STBI_FREE(orig); + return reduced; +} + +static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, + int channels) { + int i; + int img_len = w * h * channels; + stbi__uint16 *enlarged; + + enlarged = (stbi__uint16 *)stbi__malloc(img_len * 2); + if (enlarged == NULL) + return (stbi__uint16 *)stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + enlarged[i] = (stbi__uint16)((orig[i] << 8) + + orig[i]); // replicate to high and low byte, + // maps 0->0, 255->0xffff + + STBI_FREE(orig); + return enlarged; +} + +static void stbi__vertical_flip(void *image, int w, int h, + int bytes_per_pixel) { + int row; + size_t bytes_per_row = (size_t)w * bytes_per_pixel; + stbi_uc temp[2048]; + stbi_uc *bytes = (stbi_uc *)image; + + for (row = 0; row < (h >> 1); row++) { + stbi_uc *row0 = bytes + row * bytes_per_row; + stbi_uc *row1 = bytes + (h - row - 1) * bytes_per_row; + // swap row0 with row1 + size_t bytes_left = bytes_per_row; + while (bytes_left) { + size_t bytes_copy = + (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); + memcpy(temp, row0, bytes_copy); + memcpy(row0, row1, bytes_copy); + memcpy(row1, temp, bytes_copy); + row0 += bytes_copy; + row1 += bytes_copy; + bytes_left -= bytes_copy; + } + } } #ifndef STBI_NO_GIF -static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) -{ - int slice; - int slice_size = w * h * bytes_per_pixel; +static void stbi__vertical_flip_slices(void *image, int w, int h, int z, + int bytes_per_pixel) { + int slice; + int slice_size = w * h * bytes_per_pixel; - stbi_uc *bytes = (stbi_uc *)image; - for (slice = 0; slice < z; ++slice) { - stbi__vertical_flip(bytes, w, h, bytes_per_pixel); - bytes += slice_size; - } + stbi_uc *bytes = (stbi_uc *)image; + for (slice = 0; slice < z; ++slice) { + stbi__vertical_flip(bytes, w, h, bytes_per_pixel); + bytes += slice_size; + } } #endif -static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__result_info ri; - void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); +static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, + int *y, int *comp, + int req_comp) { + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); - if (result == NULL) - return NULL; + if (result == NULL) + return NULL; - if (ri.bits_per_channel != 8) { - STBI_ASSERT(ri.bits_per_channel == 16); - result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); - ri.bits_per_channel = 8; - } + if (ri.bits_per_channel != 8) { + STBI_ASSERT(ri.bits_per_channel == 16); + result = stbi__convert_16_to_8((stbi__uint16 *)result, *x, *y, + req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 8; + } - // @TODO: move stbi__convert_format to here + // @TODO: move stbi__convert_format to here - if (stbi__vertically_flip_on_load) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); - } + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); + } - return (unsigned char *) result; + return (unsigned char *)result; } -static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__result_info ri; - void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); +static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, + int *y, int *comp, + int req_comp) { + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); - if (result == NULL) - return NULL; + if (result == NULL) + return NULL; - if (ri.bits_per_channel != 16) { - STBI_ASSERT(ri.bits_per_channel == 8); - result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); - ri.bits_per_channel = 16; - } + if (ri.bits_per_channel != 16) { + STBI_ASSERT(ri.bits_per_channel == 8); + result = stbi__convert_8_to_16((stbi_uc *)result, *x, *y, + req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 16; + } - // @TODO: move stbi__convert_format16 to here - // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision + // @TODO: move stbi__convert_format16 to here + // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to + // keep more precision - if (stbi__vertically_flip_on_load) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); - } + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); + } - return (stbi__uint16 *) result; + return (stbi__uint16 *)result; } #if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) -static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) -{ - if (stbi__vertically_flip_on_load && result != NULL) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); - } +static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, + int req_comp) { + if (stbi__vertically_flip_on_load && result != NULL) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); + } } #endif #ifndef STBI_NO_STDIO #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) -STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); -STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); +STBI_EXTERN __declspec(dllimport) int __stdcall +MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, + int cbmb, wchar_t *widestr, int cchwide); +STBI_EXTERN __declspec(dllimport) int __stdcall +WideCharToMultiByte(unsigned int cp, unsigned long flags, + const wchar_t *widestr, int cchwide, char *str, int cbmb, + const char *defchar, int *used_default); #endif #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) -STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) -{ - return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, + const wchar_t *input) { + return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, + (int)bufferlen, NULL, NULL); } #endif -static FILE *stbi__fopen(char const *filename, char const *mode) -{ - FILE *f; +static FILE *stbi__fopen(char const *filename, char const *mode) { + FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) - wchar_t wMode[64]; - wchar_t wFilename[1024]; - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) - return 0; - - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) - return 0; + wchar_t wMode[64]; + wchar_t wFilename[1024]; + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, + sizeof(wFilename))) + return 0; + + if (0 == + MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) + return 0; #if _MSC_VER >= 1400 - if (0 != _wfopen_s(&f, wFilename, wMode)) - f = 0; + if (0 != _wfopen_s(&f, wFilename, wMode)) + f = 0; #else - f = _wfopen(wFilename, wMode); + f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 - if (0 != fopen_s(&f, filename, mode)) - f=0; + if (0 != fopen_s(&f, filename, mode)) + f = 0; #else - f = fopen(filename, mode); + f = fopen(filename, mode); #endif - return f; -} - - -STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - unsigned char *result; - if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *result; - stbi__context s; - stbi__start_file(&s,f); - result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); - if (result) { - // need to 'unget' all the characters in the IO buffer - fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); - } - return result; -} - -STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi__uint16 *result; - stbi__context s; - stbi__start_file(&s,f); - result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); - if (result) { - // need to 'unget' all the characters in the IO buffer - fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); - } - return result; -} - -STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - stbi__uint16 *result; - if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file_16(f,x,y,comp,req_comp); - fclose(f); - return result; -} - - -#endif //!STBI_NO_STDIO - -STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); -} - -STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); - return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); -} - -STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); -} - -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); + return f; +} + +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, + int req_comp) { + FILE *f = stbi__fopen(filename, "rb"); + unsigned char *result; + if (!f) + return stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, + int req_comp) { + unsigned char *result; + stbi__context s; + stbi__start_file(&s, f); + result = stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, -(int)(s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, + int req_comp) { + stbi__uint16 *result; + stbi__context s; + stbi__start_file(&s, f); + result = stbi__load_and_postprocess_16bit(&s, x, y, comp, req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, -(int)(s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, + int req_comp) { + FILE *f = stbi__fopen(filename, "rb"); + stbi__uint16 *result; + if (!f) + return (stbi_us *)stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file_16(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +#endif //! STBI_NO_STDIO + +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, + int *x, int *y, int *channels_in_file, + int desired_channels) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__load_and_postprocess_16bit(&s, x, y, channels_in_file, + desired_channels); +} + +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, + void *user, int *x, int *y, + int *channels_in_file, + int desired_channels) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_16bit(&s, x, y, channels_in_file, + desired_channels); +} + +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, + int *y, int *comp, int req_comp) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); +} + +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, + void *user, int *x, int *y, int *comp, + int req_comp) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); } #ifndef STBI_NO_GIF -STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) -{ - unsigned char *result; - stbi__context s; - stbi__start_mem(&s,buffer,len); - - result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); - if (stbi__vertically_flip_on_load) { - stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); - } +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, + int **delays, int *x, int *y, int *z, + int *comp, int req_comp) { + unsigned char *result; + stbi__context s; + stbi__start_mem(&s, buffer, len); + + result = + (unsigned char *)stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); + if (stbi__vertically_flip_on_load) { + stbi__vertical_flip_slices(result, *x, *y, *z, *comp); + } - return result; + return result; } #endif #ifndef STBI_NO_LINEAR -static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - stbi__result_info ri; - float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); - if (hdr_data) - stbi__float_postprocess(hdr_data,x,y,comp,req_comp); - return hdr_data; - } - #endif - data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); - if (data) - return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); -} - -STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__loadf_main(&s,x,y,comp,req_comp); +static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, + int req_comp) { + unsigned char *data; +#ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + stbi__result_info ri; + float *hdr_data = stbi__hdr_load(s, x, y, comp, req_comp, &ri); + if (hdr_data) + stbi__float_postprocess(hdr_data, x, y, comp, req_comp); + return hdr_data; + } +#endif + data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); + if (data) + return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return stbi__errpf("unknown image type", + "Image not of any known type, or corrupt"); } -STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__loadf_main(&s,x,y,comp,req_comp); +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, + int *y, int *comp, int req_comp) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__loadf_main(&s, x, y, comp, req_comp); } -#ifndef STBI_NO_STDIO -STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - float *result; - FILE *f = stbi__fopen(filename, "rb"); - if (!f) return stbi__errpf("can't fopen", "Unable to open file"); - result = stbi_loadf_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, + void *user, int *x, int *y, int *comp, + int req_comp) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__loadf_main(&s, x, y, comp, req_comp); } -STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_file(&s,f); - return stbi__loadf_main(&s,x,y,comp,req_comp); +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, + int req_comp) { + float *result; + FILE *f = stbi__fopen(filename, "rb"); + if (!f) + return stbi__errpf("can't fopen", "Unable to open file"); + result = stbi_loadf_from_file(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, + int req_comp) { + stbi__context s; + stbi__start_file(&s, f); + return stbi__loadf_main(&s, x, y, comp, req_comp); } #endif // !STBI_NO_STDIO @@ -1370,198 +1442,186 @@ STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_ // defined, for API simplicity; if STBI_NO_LINEAR is defined, it always // reports false! -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(buffer); - STBI_NOTUSED(len); - return 0; - #endif +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { +#ifndef STBI_NO_HDR + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__hdr_test(&s); +#else + STBI_NOTUSED(buffer); + STBI_NOTUSED(len); + return 0; +#endif } #ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result=0; - if (f) { - result = stbi_is_hdr_from_file(f); - fclose(f); - } - return result; +STBIDEF int stbi_is_hdr(char const *filename) { + FILE *f = stbi__fopen(filename, "rb"); + int result = 0; + if (f) { + result = stbi_is_hdr_from_file(f); + fclose(f); + } + return result; } -STBIDEF int stbi_is_hdr_from_file(FILE *f) -{ - #ifndef STBI_NO_HDR - long pos = ftell(f); - int res; - stbi__context s; - stbi__start_file(&s,f); - res = stbi__hdr_test(&s); - fseek(f, pos, SEEK_SET); - return res; - #else - STBI_NOTUSED(f); - return 0; - #endif +STBIDEF int stbi_is_hdr_from_file(FILE *f) { +#ifndef STBI_NO_HDR + long pos = ftell(f); + int res; + stbi__context s; + stbi__start_file(&s, f); + res = stbi__hdr_test(&s); + fseek(f, pos, SEEK_SET); + return res; +#else + STBI_NOTUSED(f); + return 0; +#endif } #endif // !STBI_NO_STDIO -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(clbk); - STBI_NOTUSED(user); - return 0; - #endif +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, + void *user) { +#ifndef STBI_NO_HDR + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__hdr_test(&s); +#else + STBI_NOTUSED(clbk); + STBI_NOTUSED(user); + return 0; +#endif } #ifndef STBI_NO_LINEAR -static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; +static float stbi__l2h_gamma = 2.2f, stbi__l2h_scale = 1.0f; -STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } -STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } +STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif -static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; - -STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } -STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } +static float stbi__h2l_gamma_i = 1.0f / 2.2f, stbi__h2l_scale_i = 1.0f; +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { + stbi__h2l_gamma_i = 1 / gamma; +} +STBIDEF void stbi_hdr_to_ldr_scale(float scale) { + stbi__h2l_scale_i = 1 / scale; +} ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // -enum -{ - STBI__SCAN_load=0, - STBI__SCAN_type, - STBI__SCAN_header -}; - -static void stbi__refill_buffer(stbi__context *s) -{ - int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); - if (n == 0) { - // at end of file, treat same as if from memory, but need to handle case - // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file - s->read_from_callbacks = 0; - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start+1; - *s->img_buffer = 0; - } else { - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start + n; - } -} - -stbi_inline static stbi_uc stbi__get8(stbi__context *s) -{ - if (s->img_buffer < s->img_buffer_end) - return *s->img_buffer++; - if (s->read_from_callbacks) { - stbi__refill_buffer(s); - return *s->img_buffer++; - } - return 0; -} - -stbi_inline static int stbi__at_eof(stbi__context *s) -{ - if (s->io.read) { - if (!(s->io.eof)(s->io_user_data)) return 0; - // if feof() is true, check if buffer = end - // special case: we've only got the special 0 character at the end - if (s->read_from_callbacks == 0) return 1; - } +enum { STBI__SCAN_load = 0, STBI__SCAN_type, STBI__SCAN_header }; + +static void stbi__refill_buffer(stbi__context *s) { + int n = (s->io.read)(s->io_user_data, (char *)s->buffer_start, s->buflen); + if (n == 0) { + // at end of file, treat same as if from memory, but need to handle case + // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + 1; + *s->img_buffer = 0; + } else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +stbi_inline static stbi_uc stbi__get8(stbi__context *s) { + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + stbi__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +stbi_inline static int stbi__at_eof(stbi__context *s) { + if (s->io.read) { + if (!(s->io.eof)(s->io_user_data)) + return 0; + // if feof() is true, check if buffer = end + // special case: we've only got the special 0 character at the end + if (s->read_from_callbacks == 0) + return 1; + } - return s->img_buffer >= s->img_buffer_end; + return s->img_buffer >= s->img_buffer_end; } -static void stbi__skip(stbi__context *s, int n) -{ - if (n < 0) { +static void stbi__skip(stbi__context *s, int n) { + if (n < 0) { + s->img_buffer = s->img_buffer_end; + return; + } + if (s->io.read) { + int blen = (int)(s->img_buffer_end - s->img_buffer); + if (blen < n) { s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); return; - } - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - s->img_buffer = s->img_buffer_end; - (s->io.skip)(s->io_user_data, n - blen); - return; - } - } - s->img_buffer += n; + } + } + s->img_buffer += n; } -static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) -{ - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - int res, count; +static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { + if (s->io.read) { + int blen = (int)(s->img_buffer_end - s->img_buffer); + if (blen < n) { + int res, count; - memcpy(buffer, s->img_buffer, blen); + memcpy(buffer, s->img_buffer, blen); - count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); - res = (count == (n-blen)); - s->img_buffer = s->img_buffer_end; - return res; - } - } + count = (s->io.read)(s->io_user_data, (char *)buffer + blen, n - blen); + res = (count == (n - blen)); + s->img_buffer = s->img_buffer_end; + return res; + } + } - if (s->img_buffer+n <= s->img_buffer_end) { - memcpy(buffer, s->img_buffer, n); - s->img_buffer += n; - return 1; - } else - return 0; + if (s->img_buffer + n <= s->img_buffer_end) { + memcpy(buffer, s->img_buffer, n); + s->img_buffer += n; + return 1; + } else + return 0; } -static int stbi__get16be(stbi__context *s) -{ - int z = stbi__get8(s); - return (z << 8) + stbi__get8(s); +static int stbi__get16be(stbi__context *s) { + int z = stbi__get8(s); + return (z << 8) + stbi__get8(s); } -static stbi__uint32 stbi__get32be(stbi__context *s) -{ - stbi__uint32 z = stbi__get16be(s); - return (z << 16) + stbi__get16be(s); +static stbi__uint32 stbi__get32be(stbi__context *s) { + stbi__uint32 z = stbi__get16be(s); + return (z << 16) + stbi__get16be(s); } #if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) // nothing #else -static int stbi__get16le(stbi__context *s) -{ - int z = stbi__get8(s); - return z + (stbi__get8(s) << 8); +static int stbi__get16le(stbi__context *s) { + int z = stbi__get8(s); + return z + (stbi__get8(s) << 8); } #endif #ifndef STBI_NO_BMP -static stbi__uint32 stbi__get32le(stbi__context *s) -{ - stbi__uint32 z = stbi__get16le(s); - return z + (stbi__get16le(s) << 16); +static stbi__uint32 stbi__get32le(stbi__context *s) { + stbi__uint32 z = stbi__get16le(s); + return z + (stbi__get16le(s) << 16); } #endif -#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings - +#define STBI__BYTECAST(x) \ + ((stbi_uc)((x) & 255)) // truncate int to byte without warnings ////////////////////////////////////////////////////////////////////////////// // @@ -1574,156 +1634,259 @@ static stbi__uint32 stbi__get32le(stbi__context *s) // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing -static stbi_uc stbi__compute_y(int r, int g, int b) -{ - return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); -} - -static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) -{ - int i,j; - unsigned char *good; - - if (req_comp == img_n) return data; - STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - - good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); - if (good == NULL) { - STBI_FREE(data); - return stbi__errpuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - unsigned char *src = data + j * x * img_n ; - unsigned char *dest = good + j * x * req_comp; - - #define STBI__COMBO(a,b) ((a)*8+(b)) - #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (STBI__COMBO(img_n, req_comp)) { - STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; - STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; - STBI__CASE(2,1) { dest[0]=src[0]; } break; - STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; - STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; - STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; - STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; - STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; - STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; - STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; - default: STBI_ASSERT(0); +static stbi_uc stbi__compute_y(int r, int g, int b) { + return (stbi_uc)(((r * 77) + (g * 150) + (29 * b)) >> 8); +} + +static unsigned char *stbi__convert_format(unsigned char *data, int img_n, + int req_comp, unsigned int x, + unsigned int y) { + int i, j; + unsigned char *good; + + if (req_comp == img_n) + return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *)stbi__malloc_mad3(req_comp, x, y, 0); + if (good == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + + for (j = 0; j < (int)y; ++j) { + unsigned char *src = data + j * x * img_n; + unsigned char *dest = good + j * x * req_comp; + +#define STBI__COMBO(a, b) ((a) * 8 + (b)) +#define STBI__CASE(a, b) \ + case STBI__COMBO(a, b): \ + for (i = x - 1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp + // components; avoid switch per pixel, so use switch per scanline and + // massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1, 2) { + dest[0] = src[0]; + dest[1] = 255; } - #undef STBI__CASE - } - - STBI_FREE(data); - return good; -} - -static stbi__uint16 stbi__compute_y_16(int r, int g, int b) -{ - return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); -} - -static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) -{ - int i,j; - stbi__uint16 *good; - - if (req_comp == img_n) return data; - STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - - good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); - if (good == NULL) { - STBI_FREE(data); - return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - stbi__uint16 *src = data + j * x * img_n ; - stbi__uint16 *dest = good + j * x * req_comp; - - #define STBI__COMBO(a,b) ((a)*8+(b)) - #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (STBI__COMBO(img_n, req_comp)) { - STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; - STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; - STBI__CASE(2,1) { dest[0]=src[0]; } break; - STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; - STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; - STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; - STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; - STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; - STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; - STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; - default: STBI_ASSERT(0); + break; + STBI__CASE(1, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(1, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = 255; + } + break; + STBI__CASE(2, 1) { dest[0] = src[0]; } + break; + STBI__CASE(2, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(2, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = src[1]; + } + break; + STBI__CASE(3, 4) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + dest[3] = 255; + } + break; + STBI__CASE(3, 1) { dest[0] = stbi__compute_y(src[0], src[1], src[2]); } + break; + STBI__CASE(3, 2) { + dest[0] = stbi__compute_y(src[0], src[1], src[2]); + dest[1] = 255; + } + break; + STBI__CASE(4, 1) { dest[0] = stbi__compute_y(src[0], src[1], src[2]); } + break; + STBI__CASE(4, 2) { + dest[0] = stbi__compute_y(src[0], src[1], src[2]); + dest[1] = src[3]; } - #undef STBI__CASE - } + break; + STBI__CASE(4, 3) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + } + break; + default: + STBI_ASSERT(0); + } +#undef STBI__CASE + } + + STBI_FREE(data); + return good; +} + +static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { + return (stbi__uint16)(((r * 77) + (g * 150) + (29 * b)) >> 8); +} + +static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, + int req_comp, unsigned int x, + unsigned int y) { + int i, j; + stbi__uint16 *good; + + if (req_comp == img_n) + return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (stbi__uint16 *)stbi__malloc(req_comp * x * y * 2); + if (good == NULL) { + STBI_FREE(data); + return (stbi__uint16 *)stbi__errpuc("outofmem", "Out of memory"); + } + + for (j = 0; j < (int)y; ++j) { + stbi__uint16 *src = data + j * x * img_n; + stbi__uint16 *dest = good + j * x * req_comp; + +#define STBI__COMBO(a, b) ((a) * 8 + (b)) +#define STBI__CASE(a, b) \ + case STBI__COMBO(a, b): \ + for (i = x - 1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp + // components; avoid switch per pixel, so use switch per scanline and + // massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1, 2) { + dest[0] = src[0]; + dest[1] = 0xffff; + } + break; + STBI__CASE(1, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(1, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = 0xffff; + } + break; + STBI__CASE(2, 1) { dest[0] = src[0]; } + break; + STBI__CASE(2, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(2, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = src[1]; + } + break; + STBI__CASE(3, 4) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + dest[3] = 0xffff; + } + break; + STBI__CASE(3, 1) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); } + break; + STBI__CASE(3, 2) { + dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); + dest[1] = 0xffff; + } + break; + STBI__CASE(4, 1) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); } + break; + STBI__CASE(4, 2) { + dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); + dest[1] = src[3]; + } + break; + STBI__CASE(4, 3) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + } + break; + default: + STBI_ASSERT(0); + } +#undef STBI__CASE + } - STBI_FREE(data); - return good; + STBI_FREE(data); + return good; } #ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) -{ - int i,k,n; - float *output; - if (!data) return NULL; - output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); - if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); - } - } - if (n < comp) { - for (i=0; i < x*y; ++i) { - output[i*comp + n] = data[i*comp + n]/255.0f; - } - } - STBI_FREE(data); - return output; +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { + int i, k, n; + float *output; + if (!data) + return NULL; + output = (float *)stbi__malloc_mad4(x, y, comp, sizeof(float), 0); + if (output == NULL) { + STBI_FREE(data); + return stbi__errpf("outofmem", "Out of memory"); + } + // compute number of non-alpha components + if (comp & 1) + n = comp; + else + n = comp - 1; + for (i = 0; i < x * y; ++i) { + for (k = 0; k < n; ++k) { + output[i * comp + k] = + (float)(pow(data[i * comp + k] / 255.0f, stbi__l2h_gamma) * + stbi__l2h_scale); + } + } + if (n < comp) { + for (i = 0; i < x * y; ++i) { + output[i * comp + n] = data[i * comp + n] / 255.0f; + } + } + STBI_FREE(data); + return output; } #endif #ifndef STBI_NO_HDR -#define stbi__float2int(x) ((int) (x)) -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) -{ - int i,k,n; - stbi_uc *output; - if (!data) return NULL; - output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); - if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - if (k < comp) { - float z = data[i*comp+k] * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - } - STBI_FREE(data); - return output; +#define stbi__float2int(x) ((int)(x)) +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { + int i, k, n; + stbi_uc *output; + if (!data) + return NULL; + output = (stbi_uc *)stbi__malloc_mad3(x, y, comp, 0); + if (output == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + // compute number of non-alpha components + if (comp & 1) + n = comp; + else + n = comp - 1; + for (i = 0; i < x * y; ++i) { + for (k = 0; k < n; ++k) { + float z = (float)pow(data[i * comp + k] * stbi__h2l_scale_i, + stbi__h2l_gamma_i) * + 255 + + 0.5f; + if (z < 0) + z = 0; + if (z > 255) + z = 255; + output[i * comp + k] = (stbi_uc)stbi__float2int(z); + } + if (k < comp) { + float z = data[i * comp + k] * 255 + 0.5f; + if (z < 0) + z = 0; + if (z > 255) + z = 255; + output[i * comp + k] = (stbi_uc)stbi__float2int(z); + } + } + STBI_FREE(data); + return output; } #endif @@ -1751,749 +1914,788 @@ static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) #ifndef STBI_NO_JPEG // huffman decoding acceleration -#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache - -typedef struct -{ - stbi_uc fast[1 << FAST_BITS]; - // weirdly, repacking this into AoS is a 10% speed loss, instead of a win - stbi__uint16 code[256]; - stbi_uc values[256]; - stbi_uc size[257]; - unsigned int maxcode[18]; - int delta[17]; // old 'firstsymbol' - old 'firstcode' +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct { + stbi_uc fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + stbi__uint16 code[256]; + stbi_uc values[256]; + stbi_uc size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' } stbi__huffman; -typedef struct -{ - stbi__context *s; - stbi__huffman huff_dc[4]; - stbi__huffman huff_ac[4]; - stbi__uint16 dequant[4][64]; - stbi__int16 fast_ac[4][1 << FAST_BITS]; - -// sizes for components, interleaved MCUs - int img_h_max, img_v_max; - int img_mcu_x, img_mcu_y; - int img_mcu_w, img_mcu_h; - -// definition of jpeg image component - struct - { - int id; - int h,v; - int tq; - int hd,ha; - int dc_pred; - - int x,y,w2,h2; - stbi_uc *data; - void *raw_data, *raw_coeff; - stbi_uc *linebuf; - short *coeff; // progressive only - int coeff_w, coeff_h; // number of 8x8 coefficient blocks - } img_comp[4]; - - stbi__uint32 code_buffer; // jpeg entropy-coded buffer - int code_bits; // number of valid bits - unsigned char marker; // marker seen while filling entropy buffer - int nomore; // flag if we saw a marker so must stop - - int progressive; - int spec_start; - int spec_end; - int succ_high; - int succ_low; - int eob_run; - int jfif; - int app14_color_transform; // Adobe APP14 tag - int rgb; - - int scan_n, order[4]; - int restart_interval, todo; - -// kernels - void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); - void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); - stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); +typedef struct { + stbi__context *s; + stbi__huffman huff_dc[4]; + stbi__huffman huff_ac[4]; + stbi__uint16 dequant[4][64]; + stbi__int16 fast_ac[4][1 << FAST_BITS]; + + // sizes for components, interleaved MCUs + int img_h_max, img_v_max; + int img_mcu_x, img_mcu_y; + int img_mcu_w, img_mcu_h; + + // definition of jpeg image component + struct { + int id; + int h, v; + int tq; + int hd, ha; + int dc_pred; + + int x, y, w2, h2; + stbi_uc *data; + void *raw_data, *raw_coeff; + stbi_uc *linebuf; + short *coeff; // progressive only + int coeff_w, coeff_h; // number of 8x8 coefficient blocks + } img_comp[4]; + + stbi__uint32 code_buffer; // jpeg entropy-coded buffer + int code_bits; // number of valid bits + unsigned char marker; // marker seen while filling entropy buffer + int nomore; // flag if we saw a marker so must stop + + int progressive; + int spec_start; + int spec_end; + int succ_high; + int succ_low; + int eob_run; + int jfif; + int app14_color_transform; // Adobe APP14 tag + int rgb; + + int scan_n, order[4]; + int restart_interval, todo; + + // kernels + void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); + void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, + const stbi_uc *pcb, const stbi_uc *pcr, int count, + int step); + stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, + stbi_uc *in_far, int w, int hs); } stbi__jpeg; -static int stbi__build_huffman(stbi__huffman *h, int *count) -{ - int i,j,k=0; - unsigned int code; - // build size list for each symbol (from JPEG spec) - for (i=0; i < 16; ++i) - for (j=0; j < count[i]; ++j) - h->size[k++] = (stbi_uc) (i+1); - h->size[k] = 0; - - // compute actual symbols (from jpeg spec) - code = 0; - k = 0; - for(j=1; j <= 16; ++j) { - // compute delta to add to code to compute symbol id - h->delta[j] = k - code; - if (h->size[k] == j) { - while (h->size[k] == j) - h->code[k++] = (stbi__uint16) (code++); - if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); - } - // compute largest code + 1 for this size, preshifted as needed later - h->maxcode[j] = code << (16-j); - code <<= 1; - } - h->maxcode[j] = 0xffffffff; - - // build non-spec acceleration table; 255 is flag for not-accelerated - memset(h->fast, 255, 1 << FAST_BITS); - for (i=0; i < k; ++i) { - int s = h->size[i]; - if (s <= FAST_BITS) { - int c = h->code[i] << (FAST_BITS-s); - int m = 1 << (FAST_BITS-s); - for (j=0; j < m; ++j) { - h->fast[c+j] = (stbi_uc) i; - } +static int stbi__build_huffman(stbi__huffman *h, int *count) { + int i, j, k = 0; + unsigned int code; + // build size list for each symbol (from JPEG spec) + for (i = 0; i < 16; ++i) + for (j = 0; j < count[i]; ++j) + h->size[k++] = (stbi_uc)(i + 1); + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for (j = 1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (stbi__uint16)(code++); + if (code - 1 >= (1u << j)) + return stbi__err("bad code lengths", "Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16 - j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i = 0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS - s); + int m = 1 << (FAST_BITS - s); + for (j = 0; j < m; ++j) { + h->fast[c + j] = (stbi_uc)i; } - } - return 1; + } + } + return 1; } // build a table that decodes both magnitude and value of small ACs in // one go. -static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) -{ - int i; - for (i=0; i < (1 << FAST_BITS); ++i) { - stbi_uc fast = h->fast[i]; - fast_ac[i] = 0; - if (fast < 255) { - int rs = h->values[fast]; - int run = (rs >> 4) & 15; - int magbits = rs & 15; - int len = h->size[fast]; - - if (magbits && len + magbits <= FAST_BITS) { - // magnitude code followed by receive_extend code - int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); - int m = 1 << (magbits - 1); - if (k < m) k += (~0U << magbits) + 1; - // if the result is small enough, we can fit it in fast_ac table - if (k >= -128 && k <= 127) - fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); - } +static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { + int i; + for (i = 0; i < (1 << FAST_BITS); ++i) { + stbi_uc fast = h->fast[i]; + fast_ac[i] = 0; + if (fast < 255) { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; + + if (magbits && len + magbits <= FAST_BITS) { + // magnitude code followed by receive_extend code + int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); + int m = 1 << (magbits - 1); + if (k < m) + k += (~0U << magbits) + 1; + // if the result is small enough, we can fit it in fast_ac table + if (k >= -128 && k <= 127) + fast_ac[i] = (stbi__int16)((k * 256) + (run * 16) + (len + magbits)); } - } -} - -static void stbi__grow_buffer_unsafe(stbi__jpeg *j) -{ - do { - unsigned int b = j->nomore ? 0 : stbi__get8(j->s); - if (b == 0xff) { - int c = stbi__get8(j->s); - while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes - if (c != 0) { - j->marker = (unsigned char) c; - j->nomore = 1; - return; - } + } + } +} + +static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { + do { + unsigned int b = j->nomore ? 0 : stbi__get8(j->s); + if (b == 0xff) { + int c = stbi__get8(j->s); + while (c == 0xff) + c = stbi__get8(j->s); // consume fill bytes + if (c != 0) { + j->marker = (unsigned char)c; + j->nomore = 1; + return; } - j->code_buffer |= b << (24 - j->code_bits); - j->code_bits += 8; - } while (j->code_bits <= 24); + } + j->code_buffer |= b << (24 - j->code_bits); + j->code_bits += 8; + } while (j->code_bits <= 24); } // (1 << n) - 1 -static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; +static const stbi__uint32 stbi__bmask[17] = { + 0, 1, 3, 7, 15, 31, 63, 127, 255, + 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535}; // decode a jpeg huffman value from the bitstream -stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) -{ - unsigned int temp; - int c,k; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - - // look at the top FAST_BITS and determine what symbol ID it is, - // if the code is <= FAST_BITS - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - k = h->fast[c]; - if (k < 255) { - int s = h->size[k]; - if (s > j->code_bits) - return -1; - j->code_buffer <<= s; - j->code_bits -= s; - return h->values[k]; - } - - // naive test is to shift the code_buffer down so k bits are - // valid, then test against maxcode. To speed this up, we've - // preshifted maxcode left so that it has (16-k) 0s at the - // end; in other words, regardless of the number of bits, it - // wants to be compared against something shifted to have 16; - // that way we don't need to shift inside the loop. - temp = j->code_buffer >> 16; - for (k=FAST_BITS+1 ; ; ++k) - if (temp < h->maxcode[k]) - break; - if (k == 17) { - // error! code not found - j->code_bits -= 16; +stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { + unsigned int temp; + int c, k; + + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + k = h->fast[c]; + if (k < 255) { + int s = h->size[k]; + if (s > j->code_bits) return -1; - } - - if (k > j->code_bits) - return -1; - - // convert the huffman code to the symbol id - c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; - STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); - - // convert the id to a symbol - j->code_bits -= k; - j->code_buffer <<= k; - return h->values[c]; + j->code_buffer <<= s; + j->code_bits -= s; + return h->values[k]; + } + + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + temp = j->code_buffer >> 16; + for (k = FAST_BITS + 1;; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + j->code_bits -= 16; + return -1; + } + + if (k > j->code_bits) + return -1; + + // convert the huffman code to the symbol id + c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; + STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & + stbi__bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + j->code_bits -= k; + j->code_buffer <<= k; + return h->values[c]; } // bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); +stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n) { + unsigned int k; + int sgn; + if (j->code_bits < n) + stbi__grow_buffer_unsafe(j); - sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB - k = stbi_lrot(j->code_buffer, n); - STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k + (stbi__jbias[n] & ~sgn); + sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB + k = stbi_lrot(j->code_buffer, n); + STBI_ASSERT(n >= 0 && n < (int)(sizeof(stbi__bmask) / sizeof(*stbi__bmask))); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k + (stbi__jbias[n] & ~sgn); } // get some unsigned bits -stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) -{ - unsigned int k; - if (j->code_bits < n) stbi__grow_buffer_unsafe(j); - k = stbi_lrot(j->code_buffer, n); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k; -} - -stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) -{ - unsigned int k; - if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); - k = j->code_buffer; - j->code_buffer <<= 1; - --j->code_bits; - return k & 0x80000000; +stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { + unsigned int k; + if (j->code_bits < n) + stbi__grow_buffer_unsafe(j); + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k; +} + +stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { + unsigned int k; + if (j->code_bits < 1) + stbi__grow_buffer_unsafe(j); + k = j->code_buffer; + j->code_buffer <<= 1; + --j->code_bits; + return k & 0x80000000; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? -static const stbi_uc stbi__jpeg_dezigzag[64+15] = -{ - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - // let corrupt input sample past end - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63 -}; +static const stbi_uc stbi__jpeg_dezigzag[64 + 15] = { + 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, + 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, + 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63}; // decode one 64-entry block-- -static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) -{ - int diff,dc,k; - int t; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - t = stbi__jpeg_huff_decode(j, hdc); - if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - - // 0 all the ac values now so we can do it 32-bits at a time - memset(data,0,64*sizeof(data[0])); - - diff = t ? stbi__extend_receive(j, t) : 0; - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) (dc * dequant[0]); - - // decode AC components, see JPEG spec - k = 1; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - j->code_buffer <<= s; - j->code_bits -= s; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) * dequant[zig]); +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], + stbi__huffman *hdc, stbi__huffman *hac, + stbi__int16 *fac, int b, + stbi__uint16 *dequant) { + int diff, dc, k; + int t; + + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0) + return stbi__err("bad huffman code", "Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data, 0, 64 * sizeof(data[0])); + + diff = t ? stbi__extend_receive(j, t) : 0; + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short)(dc * dequant[0]); + + // decode AC components, see JPEG spec + k = 1; + do { + unsigned int zig; + int c, r, s; + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)((r >> 8) * dequant[zig]); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) + return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) + break; // end block + k += 16; } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (rs != 0xf0) break; // end block - k += 16; - } else { - k += r; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); - } + k += r; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)(stbi__extend_receive(j, s) * dequant[zig]); } - } while (k < 64); - return 1; + } + } while (k < 64); + return 1; } -static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) -{ - int diff,dc; - int t; - if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], + stbi__huffman *hdc, int b) { + int diff, dc; + int t; + if (j->spec_end != 0) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); - if (j->succ_high == 0) { - // first scan for DC coefficient, must be first - memset(data,0,64*sizeof(data[0])); // 0 all the ac values now - t = stbi__jpeg_huff_decode(j, hdc); - diff = t ? stbi__extend_receive(j, t) : 0; + if (j->succ_high == 0) { + // first scan for DC coefficient, must be first + memset(data, 0, 64 * sizeof(data[0])); // 0 all the ac values now + t = stbi__jpeg_huff_decode(j, hdc); + diff = t ? stbi__extend_receive(j, t) : 0; - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) (dc << j->succ_low); - } else { - // refinement scan for DC coefficient - if (stbi__jpeg_get_bit(j)) - data[0] += (short) (1 << j->succ_low); - } - return 1; + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short)(dc << j->succ_low); + } else { + // refinement scan for DC coefficient + if (stbi__jpeg_get_bit(j)) + data[0] += (short)(1 << j->succ_low); + } + return 1; } // @OPTIMIZE: store non-zigzagged during the decode passes, // and only de-zigzag when dequantizing -static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) -{ - int k; - if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - - if (j->succ_high == 0) { - int shift = j->succ_low; +static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], + stbi__huffman *hac, + stbi__int16 *fac) { + int k; + if (j->spec_start == 0) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->succ_high == 0) { + int shift = j->succ_low; + + if (j->eob_run) { + --j->eob_run; + return 1; + } - if (j->eob_run) { - --j->eob_run; - return 1; - } - - k = j->spec_start; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - j->code_buffer <<= s; - j->code_bits -= s; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) << shift); - } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r); - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - --j->eob_run; - break; - } - k += 16; - } else { - k += r; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) << shift); - } - } - } while (k <= j->spec_end); - } else { - // refinement scan for these AC coefficients - - short bit = (short) (1 << j->succ_low); - - if (j->eob_run) { - --j->eob_run; - for (k = j->spec_start; k <= j->spec_end; ++k) { - short *p = &data[stbi__jpeg_dezigzag[k]]; - if (*p != 0) - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } + k = j->spec_start; + do { + unsigned int zig; + int c, r, s; + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)((r >> 8) << shift); } else { - k = j->spec_start; - do { - int r,s; - int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r) - 1; - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - r = 64; // force end of block - } else { - // r=15 s=0 should write 16 0s, so we just do - // a run of 15 0s and then write s (which is 0), - // so we don't have to do anything special here - } - } else { - if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); - // sign bit - if (stbi__jpeg_get_bit(j)) - s = bit; - else - s = -bit; + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) + return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r); + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + --j->eob_run; + break; + } + k += 16; + } else { + k += r; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)(stbi__extend_receive(j, s) << shift); + } + } + } while (k <= j->spec_end); + } else { + // refinement scan for these AC coefficients + + short bit = (short)(1 << j->succ_low); + + if (j->eob_run) { + --j->eob_run; + for (k = j->spec_start; k <= j->spec_end; ++k) { + short *p = &data[stbi__jpeg_dezigzag[k]]; + if (*p != 0) + if (stbi__jpeg_get_bit(j)) + if ((*p & bit) == 0) { + if (*p > 0) + *p += bit; + else + *p -= bit; } + } + } else { + k = j->spec_start; + do { + int r, s; + int rs = stbi__jpeg_huff_decode( + j, hac); // @OPTIMIZE see if we can use the fast path here, + // advance-by-r is so slow, eh + if (rs < 0) + return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r) - 1; + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + r = 64; // force end of block + } else { + // r=15 s=0 should write 16 0s, so we just do + // a run of 15 0s and then write s (which is 0), + // so we don't have to do anything special here + } + } else { + if (s != 1) + return stbi__err("bad huffman code", "Corrupt JPEG"); + // sign bit + if (stbi__jpeg_get_bit(j)) + s = bit; + else + s = -bit; + } - // advance by r - while (k <= j->spec_end) { - short *p = &data[stbi__jpeg_dezigzag[k++]]; - if (*p != 0) { - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } else { - if (r == 0) { - *p = (short) s; - break; - } - --r; - } + // advance by r + while (k <= j->spec_end) { + short *p = &data[stbi__jpeg_dezigzag[k++]]; + if (*p != 0) { + if (stbi__jpeg_get_bit(j)) + if ((*p & bit) == 0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } else { + if (r == 0) { + *p = (short)s; + break; } - } while (k <= j->spec_end); - } - } - return 1; + --r; + } + } + } while (k <= j->spec_end); + } + } + return 1; } // take a -128..127 value and stbi__clamp it and convert to 0..255 -stbi_inline static stbi_uc stbi__clamp(int x) -{ - // trick to use a single test to catch both cases - if ((unsigned int) x > 255) { - if (x < 0) return 0; - if (x > 255) return 255; - } - return (stbi_uc) x; +stbi_inline static stbi_uc stbi__clamp(int x) { + // trick to use a single test to catch both cases + if ((unsigned int)x > 255) { + if (x < 0) + return 0; + if (x > 255) + return 255; + } + return (stbi_uc)x; } -#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) -#define stbi__fsh(x) ((x) * 4096) +#define stbi__f2f(x) ((int)(((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) * 4096) // derived from jidctint -- DCT_ISLOW -#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ - int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ - p2 = s2; \ - p3 = s6; \ - p1 = (p2+p3) * stbi__f2f(0.5411961f); \ - t2 = p1 + p3*stbi__f2f(-1.847759065f); \ - t3 = p1 + p2*stbi__f2f( 0.765366865f); \ - p2 = s0; \ - p3 = s4; \ - t0 = stbi__fsh(p2+p3); \ - t1 = stbi__fsh(p2-p3); \ - x0 = t0+t3; \ - x3 = t0-t3; \ - x1 = t1+t2; \ - x2 = t1-t2; \ - t0 = s7; \ - t1 = s5; \ - t2 = s3; \ - t3 = s1; \ - p3 = t0+t2; \ - p4 = t1+t3; \ - p1 = t0+t3; \ - p2 = t1+t2; \ - p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ - t0 = t0*stbi__f2f( 0.298631336f); \ - t1 = t1*stbi__f2f( 2.053119869f); \ - t2 = t2*stbi__f2f( 3.072711026f); \ - t3 = t3*stbi__f2f( 1.501321110f); \ - p1 = p5 + p1*stbi__f2f(-0.899976223f); \ - p2 = p5 + p2*stbi__f2f(-2.562915447f); \ - p3 = p3*stbi__f2f(-1.961570560f); \ - p4 = p4*stbi__f2f(-0.390180644f); \ - t3 += p1+p4; \ - t2 += p2+p3; \ - t1 += p2+p4; \ - t0 += p1+p3; - -static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) -{ - int i,val[64],*v=val; - stbi_uc *o; - short *d = data; - - // columns - for (i=0; i < 8; ++i,++d, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing - if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 - && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds - int dcterm = d[0]*4; - v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; - } else { - STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision - x0 += 512; x1 += 512; x2 += 512; x3 += 512; - v[ 0] = (x0+t3) >> 10; - v[56] = (x0-t3) >> 10; - v[ 8] = (x1+t2) >> 10; - v[48] = (x1-t2) >> 10; - v[16] = (x2+t1) >> 10; - v[40] = (x2-t1) >> 10; - v[24] = (x3+t0) >> 10; - v[32] = (x3-t0) >> 10; - } - } - - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out - STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - // so we want to round that, which means adding 0.5 * 1<<17, - // aka 65536. Also, we'll end up with -128 to 127 that we want - // to encode as 0..255 by adding 128, so we'll add that before the shift - x0 += 65536 + (128<<17); - x1 += 65536 + (128<<17); - x2 += 65536 + (128<<17); - x3 += 65536 + (128<<17); - // tried computing the shifts into temps, or'ing the temps to see - // if any were out of range, but that was slower - o[0] = stbi__clamp((x0+t3) >> 17); - o[7] = stbi__clamp((x0-t3) >> 17); - o[1] = stbi__clamp((x1+t2) >> 17); - o[6] = stbi__clamp((x1-t2) >> 17); - o[2] = stbi__clamp((x2+t1) >> 17); - o[5] = stbi__clamp((x2-t1) >> 17); - o[3] = stbi__clamp((x3+t0) >> 17); - o[4] = stbi__clamp((x3-t0) >> 17); - } +#define STBI__IDCT_1D(s0, s1, s2, s3, s4, s5, s6, s7) \ + int t0, t1, t2, t3, p1, p2, p3, p4, p5, x0, x1, x2, x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2 + p3) * stbi__f2f(0.5411961f); \ + t2 = p1 + p3 * stbi__f2f(-1.847759065f); \ + t3 = p1 + p2 * stbi__f2f(0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = stbi__fsh(p2 + p3); \ + t1 = stbi__fsh(p2 - p3); \ + x0 = t0 + t3; \ + x3 = t0 - t3; \ + x1 = t1 + t2; \ + x2 = t1 - t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0 + t2; \ + p4 = t1 + t3; \ + p1 = t0 + t3; \ + p2 = t1 + t2; \ + p5 = (p3 + p4) * stbi__f2f(1.175875602f); \ + t0 = t0 * stbi__f2f(0.298631336f); \ + t1 = t1 * stbi__f2f(2.053119869f); \ + t2 = t2 * stbi__f2f(3.072711026f); \ + t3 = t3 * stbi__f2f(1.501321110f); \ + p1 = p5 + p1 * stbi__f2f(-0.899976223f); \ + p2 = p5 + p2 * stbi__f2f(-2.562915447f); \ + p3 = p3 * stbi__f2f(-1.961570560f); \ + p4 = p4 * stbi__f2f(-0.390180644f); \ + t3 += p1 + p4; \ + t2 += p2 + p3; \ + t1 += p2 + p4; \ + t0 += p1 + p3; + +static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { + int i, val[64], *v = val; + stbi_uc *o; + short *d = data; + + // columns + for (i = 0; i < 8; ++i, ++d, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[8] == 0 && d[16] == 0 && d[24] == 0 && d[32] == 0 && d[40] == 0 && + d[48] == 0 && d[56] == 0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0] * 4; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } else { + STBI__IDCT_1D(d[0], d[8], d[16], d[24], d[32], d[40], d[48], d[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; + x1 += 512; + x2 += 512; + x3 += 512; + v[0] = (x0 + t3) >> 10; + v[56] = (x0 - t3) >> 10; + v[8] = (x1 + t2) >> 10; + v[48] = (x1 - t2) >> 10; + v[16] = (x2 + t1) >> 10; + v[40] = (x2 - t1) >> 10; + v[24] = (x3 + t0) >> 10; + v[32] = (x3 - t0) >> 10; + } + } + + for (i = 0, v = val, o = out; i < 8; ++i, v += 8, o += out_stride) { + // no fast case since the first 1D IDCT spread components out + STBI__IDCT_1D(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + // so we want to round that, which means adding 0.5 * 1<<17, + // aka 65536. Also, we'll end up with -128 to 127 that we want + // to encode as 0..255 by adding 128, so we'll add that before the shift + x0 += 65536 + (128 << 17); + x1 += 65536 + (128 << 17); + x2 += 65536 + (128 << 17); + x3 += 65536 + (128 << 17); + // tried computing the shifts into temps, or'ing the temps to see + // if any were out of range, but that was slower + o[0] = stbi__clamp((x0 + t3) >> 17); + o[7] = stbi__clamp((x0 - t3) >> 17); + o[1] = stbi__clamp((x1 + t2) >> 17); + o[6] = stbi__clamp((x1 - t2) >> 17); + o[2] = stbi__clamp((x2 + t1) >> 17); + o[5] = stbi__clamp((x2 - t1) >> 17); + o[3] = stbi__clamp((x3 + t0) >> 17); + o[4] = stbi__clamp((x3 - t0) >> 17); + } } #ifdef STBI_SSE2 // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - // This is constructed to match our regular (generic) integer IDCT exactly. - __m128i row0, row1, row2, row3, row4, row5, row6, row7; - __m128i tmp; - - // dot product constant: even elems=x, odd elems=y - #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) - - // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) - // out(1) = c1[even]*x + c1[odd]*y - #define dct_rot(out0,out1, x,y,c0,c1) \ - __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ - __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ - __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ - __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ - __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ - __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) - - // out = in << 12 (in 16-bit, out 32-bit) - #define dct_widen(out, in) \ - __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ - __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) - - // wide add - #define dct_wadd(out, a, b) \ - __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_add_epi32(a##_h, b##_h) - - // wide sub - #define dct_wsub(out, a, b) \ - __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) - - // butterfly a/b, add bias, then shift by "s" and pack - #define dct_bfly32o(out0, out1, a,b,bias,s) \ - { \ - __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ - __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ - dct_wadd(sum, abiased, b); \ - dct_wsub(dif, abiased, b); \ - out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ - out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ - } +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { + // This is constructed to match our regular (generic) integer IDCT exactly. + __m128i row0, row1, row2, row3, row4, row5, row6, row7; + __m128i tmp; + +// dot product constant: even elems=x, odd elems=y +#define dct_const(x, y) _mm_setr_epi16((x), (y), (x), (y), (x), (y), (x), (y)) + +// out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) +// out(1) = c1[even]*x + c1[odd]*y +#define dct_rot(out0, out1, x, y, c0, c1) \ + __m128i c0##lo = _mm_unpacklo_epi16((x), (y)); \ + __m128i c0##hi = _mm_unpackhi_epi16((x), (y)); \ + __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ + __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ + __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ + __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) + +// out = in << 12 (in 16-bit, out 32-bit) +#define dct_widen(out, in) \ + __m128i out##_l = \ + _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ + __m128i out##_h = \ + _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) - // 8-bit interleave step (for transposes) - #define dct_interleave8(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi8(a, b); \ - b = _mm_unpackhi_epi8(tmp, b) - - // 16-bit interleave step (for transposes) - #define dct_interleave16(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi16(a, b); \ - b = _mm_unpackhi_epi16(tmp, b) - - #define dct_pass(bias,shift) \ - { \ - /* even part */ \ - dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ - __m128i sum04 = _mm_add_epi16(row0, row4); \ - __m128i dif04 = _mm_sub_epi16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ - dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ - __m128i sum17 = _mm_add_epi16(row1, row7); \ - __m128i sum35 = _mm_add_epi16(row3, row5); \ - dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ - dct_wadd(x4, y0o, y4o); \ - dct_wadd(x5, y1o, y5o); \ - dct_wadd(x6, y2o, y5o); \ - dct_wadd(x7, y3o, y4o); \ - dct_bfly32o(row0,row7, x0,x7,bias,shift); \ - dct_bfly32o(row1,row6, x1,x6,bias,shift); \ - dct_bfly32o(row2,row5, x2,x5,bias,shift); \ - dct_bfly32o(row3,row4, x3,x4,bias,shift); \ - } - - __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); - __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); - __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); - __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); - __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); - __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); - __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); - __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); - - // rounding biases in column/row passes, see stbi__idct_block for explanation. - __m128i bias_0 = _mm_set1_epi32(512); - __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); - - // load - row0 = _mm_load_si128((const __m128i *) (data + 0*8)); - row1 = _mm_load_si128((const __m128i *) (data + 1*8)); - row2 = _mm_load_si128((const __m128i *) (data + 2*8)); - row3 = _mm_load_si128((const __m128i *) (data + 3*8)); - row4 = _mm_load_si128((const __m128i *) (data + 4*8)); - row5 = _mm_load_si128((const __m128i *) (data + 5*8)); - row6 = _mm_load_si128((const __m128i *) (data + 6*8)); - row7 = _mm_load_si128((const __m128i *) (data + 7*8)); - - // column pass - dct_pass(bias_0, 10); - - { - // 16bit 8x8 transpose pass 1 - dct_interleave16(row0, row4); - dct_interleave16(row1, row5); - dct_interleave16(row2, row6); - dct_interleave16(row3, row7); - - // transpose pass 2 - dct_interleave16(row0, row2); - dct_interleave16(row1, row3); - dct_interleave16(row4, row6); - dct_interleave16(row5, row7); - - // transpose pass 3 - dct_interleave16(row0, row1); - dct_interleave16(row2, row3); - dct_interleave16(row4, row5); - dct_interleave16(row6, row7); - } - - // row pass - dct_pass(bias_1, 17); - - { - // pack - __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 - __m128i p1 = _mm_packus_epi16(row2, row3); - __m128i p2 = _mm_packus_epi16(row4, row5); - __m128i p3 = _mm_packus_epi16(row6, row7); - - // 8bit 8x8 transpose pass 1 - dct_interleave8(p0, p2); // a0e0a1e1... - dct_interleave8(p1, p3); // c0g0c1g1... - - // transpose pass 2 - dct_interleave8(p0, p1); // a0c0e0g0... - dct_interleave8(p2, p3); // b0d0f0h0... - - // transpose pass 3 - dct_interleave8(p0, p2); // a0b0c0d0... - dct_interleave8(p1, p3); // a4b4c4d4... +// wide add +#define dct_wadd(out, a, b) \ + __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_add_epi32(a##_h, b##_h) - // store - _mm_storel_epi64((__m128i *) out, p0); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p2); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p1); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p3); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); - } +// wide sub +#define dct_wsub(out, a, b) \ + __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) + +// butterfly a/b, add bias, then shift by "s" and pack +#define dct_bfly32o(out0, out1, a, b, bias, s) \ + { \ + __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ + __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ + dct_wadd(sum, abiased, b); \ + dct_wsub(dif, abiased, b); \ + out0 = \ + _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ + out1 = \ + _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ + } + +// 8-bit interleave step (for transposes) +#define dct_interleave8(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi8(a, b); \ + b = _mm_unpackhi_epi8(tmp, b) + +// 16-bit interleave step (for transposes) +#define dct_interleave16(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi16(a, b); \ + b = _mm_unpackhi_epi16(tmp, b) + +#define dct_pass(bias, shift) \ + { \ + /* even part */ \ + dct_rot(t2e, t3e, row2, row6, rot0_0, rot0_1); \ + __m128i sum04 = _mm_add_epi16(row0, row4); \ + __m128i dif04 = _mm_sub_epi16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + dct_rot(y0o, y2o, row7, row3, rot2_0, rot2_1); \ + dct_rot(y1o, y3o, row5, row1, rot3_0, rot3_1); \ + __m128i sum17 = _mm_add_epi16(row1, row7); \ + __m128i sum35 = _mm_add_epi16(row3, row5); \ + dct_rot(y4o, y5o, sum17, sum35, rot1_0, rot1_1); \ + dct_wadd(x4, y0o, y4o); \ + dct_wadd(x5, y1o, y5o); \ + dct_wadd(x6, y2o, y5o); \ + dct_wadd(x7, y3o, y4o); \ + dct_bfly32o(row0, row7, x0, x7, bias, shift); \ + dct_bfly32o(row1, row6, x1, x6, bias, shift); \ + dct_bfly32o(row2, row5, x2, x5, bias, shift); \ + dct_bfly32o(row3, row4, x3, x4, bias, shift); \ + } + + __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), + stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); + __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f(0.765366865f), + stbi__f2f(0.5411961f)); + __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), + stbi__f2f(1.175875602f)); + __m128i rot1_1 = + dct_const(stbi__f2f(1.175875602f), + stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); + __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f(0.298631336f), + stbi__f2f(-1.961570560f)); + __m128i rot2_1 = + dct_const(stbi__f2f(-1.961570560f), + stbi__f2f(-1.961570560f) + stbi__f2f(3.072711026f)); + __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f(2.053119869f), + stbi__f2f(-0.390180644f)); + __m128i rot3_1 = + dct_const(stbi__f2f(-0.390180644f), + stbi__f2f(-0.390180644f) + stbi__f2f(1.501321110f)); + + // rounding biases in column/row passes, see stbi__idct_block for explanation. + __m128i bias_0 = _mm_set1_epi32(512); + __m128i bias_1 = _mm_set1_epi32(65536 + (128 << 17)); + + // load + row0 = _mm_load_si128((const __m128i *)(data + 0 * 8)); + row1 = _mm_load_si128((const __m128i *)(data + 1 * 8)); + row2 = _mm_load_si128((const __m128i *)(data + 2 * 8)); + row3 = _mm_load_si128((const __m128i *)(data + 3 * 8)); + row4 = _mm_load_si128((const __m128i *)(data + 4 * 8)); + row5 = _mm_load_si128((const __m128i *)(data + 5 * 8)); + row6 = _mm_load_si128((const __m128i *)(data + 6 * 8)); + row7 = _mm_load_si128((const __m128i *)(data + 7 * 8)); + + // column pass + dct_pass(bias_0, 10); + + { + // 16bit 8x8 transpose pass 1 + dct_interleave16(row0, row4); + dct_interleave16(row1, row5); + dct_interleave16(row2, row6); + dct_interleave16(row3, row7); + + // transpose pass 2 + dct_interleave16(row0, row2); + dct_interleave16(row1, row3); + dct_interleave16(row4, row6); + dct_interleave16(row5, row7); + + // transpose pass 3 + dct_interleave16(row0, row1); + dct_interleave16(row2, row3); + dct_interleave16(row4, row5); + dct_interleave16(row6, row7); + } + + // row pass + dct_pass(bias_1, 17); + + { + // pack + __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 + __m128i p1 = _mm_packus_epi16(row2, row3); + __m128i p2 = _mm_packus_epi16(row4, row5); + __m128i p3 = _mm_packus_epi16(row6, row7); + + // 8bit 8x8 transpose pass 1 + dct_interleave8(p0, p2); // a0e0a1e1... + dct_interleave8(p1, p3); // c0g0c1g1... + + // transpose pass 2 + dct_interleave8(p0, p1); // a0c0e0g0... + dct_interleave8(p2, p3); // b0d0f0h0... + + // transpose pass 3 + dct_interleave8(p0, p2); // a0b0c0d0... + dct_interleave8(p1, p3); // a4b4c4d4... + + // store + _mm_storel_epi64((__m128i *)out, p0); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p0, 0x4e)); + out += out_stride; + _mm_storel_epi64((__m128i *)out, p2); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p2, 0x4e)); + out += out_stride; + _mm_storel_epi64((__m128i *)out, p1); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p1, 0x4e)); + out += out_stride; + _mm_storel_epi64((__m128i *)out, p3); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p3, 0x4e)); + } #undef dct_const #undef dct_rot @@ -2512,198 +2714,236 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) // NEON integer IDCT. should produce bit-identical // results to the generic C version. -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; - - int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); - int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); - int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); - int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); - int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); - int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); - int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); - int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); - int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); - int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); - int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); - int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); - -#define dct_long_mul(out, inq, coeff) \ - int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) - -#define dct_long_mac(out, acc, inq, coeff) \ - int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) - -#define dct_widen(out, inq) \ - int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ - int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { + int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; + + int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(stbi__f2f(0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(stbi__f2f(1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(stbi__f2f(0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(stbi__f2f(2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(stbi__f2f(3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(stbi__f2f(1.501321110f)); + +#define dct_long_mul(out, inq, coeff) \ + int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) + +#define dct_long_mac(out, acc, inq, coeff) \ + int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) + +#define dct_widen(out, inq) \ + int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ + int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) // wide add -#define dct_wadd(out, a, b) \ - int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vaddq_s32(a##_h, b##_h) +#define dct_wadd(out, a, b) \ + int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vaddq_s32(a##_h, b##_h) // wide sub -#define dct_wsub(out, a, b) \ - int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vsubq_s32(a##_h, b##_h) +#define dct_wsub(out, a, b) \ + int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vsubq_s32(a##_h, b##_h) // butterfly a/b, then shift using "shiftop" by "s" and pack -#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ - { \ - dct_wadd(sum, a, b); \ - dct_wsub(dif, a, b); \ - out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ - out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ - } - -#define dct_pass(shiftop, shift) \ - { \ - /* even part */ \ - int16x8_t sum26 = vaddq_s16(row2, row6); \ - dct_long_mul(p1e, sum26, rot0_0); \ - dct_long_mac(t2e, p1e, row6, rot0_1); \ - dct_long_mac(t3e, p1e, row2, rot0_2); \ - int16x8_t sum04 = vaddq_s16(row0, row4); \ - int16x8_t dif04 = vsubq_s16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - int16x8_t sum15 = vaddq_s16(row1, row5); \ - int16x8_t sum17 = vaddq_s16(row1, row7); \ - int16x8_t sum35 = vaddq_s16(row3, row5); \ - int16x8_t sum37 = vaddq_s16(row3, row7); \ - int16x8_t sumodd = vaddq_s16(sum17, sum35); \ - dct_long_mul(p5o, sumodd, rot1_0); \ - dct_long_mac(p1o, p5o, sum17, rot1_1); \ - dct_long_mac(p2o, p5o, sum35, rot1_2); \ - dct_long_mul(p3o, sum37, rot2_0); \ - dct_long_mul(p4o, sum15, rot2_1); \ - dct_wadd(sump13o, p1o, p3o); \ - dct_wadd(sump24o, p2o, p4o); \ - dct_wadd(sump23o, p2o, p3o); \ - dct_wadd(sump14o, p1o, p4o); \ - dct_long_mac(x4, sump13o, row7, rot3_0); \ - dct_long_mac(x5, sump24o, row5, rot3_1); \ - dct_long_mac(x6, sump23o, row3, rot3_2); \ - dct_long_mac(x7, sump14o, row1, rot3_3); \ - dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ - dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ - dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ - dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ - } - - // load - row0 = vld1q_s16(data + 0*8); - row1 = vld1q_s16(data + 1*8); - row2 = vld1q_s16(data + 2*8); - row3 = vld1q_s16(data + 3*8); - row4 = vld1q_s16(data + 4*8); - row5 = vld1q_s16(data + 5*8); - row6 = vld1q_s16(data + 6*8); - row7 = vld1q_s16(data + 7*8); - - // add DC bias - row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); - - // column pass - dct_pass(vrshrn_n_s32, 10); - - // 16bit 8x8 transpose - { +#define dct_bfly32o(out0, out1, a, b, shiftop, s) \ + { \ + dct_wadd(sum, a, b); \ + dct_wsub(dif, a, b); \ + out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ + out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ + } + +#define dct_pass(shiftop, shift) \ + { \ + /* even part */ \ + int16x8_t sum26 = vaddq_s16(row2, row6); \ + dct_long_mul(p1e, sum26, rot0_0); \ + dct_long_mac(t2e, p1e, row6, rot0_1); \ + dct_long_mac(t3e, p1e, row2, rot0_2); \ + int16x8_t sum04 = vaddq_s16(row0, row4); \ + int16x8_t dif04 = vsubq_s16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + int16x8_t sum15 = vaddq_s16(row1, row5); \ + int16x8_t sum17 = vaddq_s16(row1, row7); \ + int16x8_t sum35 = vaddq_s16(row3, row5); \ + int16x8_t sum37 = vaddq_s16(row3, row7); \ + int16x8_t sumodd = vaddq_s16(sum17, sum35); \ + dct_long_mul(p5o, sumodd, rot1_0); \ + dct_long_mac(p1o, p5o, sum17, rot1_1); \ + dct_long_mac(p2o, p5o, sum35, rot1_2); \ + dct_long_mul(p3o, sum37, rot2_0); \ + dct_long_mul(p4o, sum15, rot2_1); \ + dct_wadd(sump13o, p1o, p3o); \ + dct_wadd(sump24o, p2o, p4o); \ + dct_wadd(sump23o, p2o, p3o); \ + dct_wadd(sump14o, p1o, p4o); \ + dct_long_mac(x4, sump13o, row7, rot3_0); \ + dct_long_mac(x5, sump24o, row5, rot3_1); \ + dct_long_mac(x6, sump23o, row3, rot3_2); \ + dct_long_mac(x7, sump14o, row1, rot3_3); \ + dct_bfly32o(row0, row7, x0, x7, shiftop, shift); \ + dct_bfly32o(row1, row6, x1, x6, shiftop, shift); \ + dct_bfly32o(row2, row5, x2, x5, shiftop, shift); \ + dct_bfly32o(row3, row4, x3, x4, shiftop, shift); \ + } + + // load + row0 = vld1q_s16(data + 0 * 8); + row1 = vld1q_s16(data + 1 * 8); + row2 = vld1q_s16(data + 2 * 8); + row3 = vld1q_s16(data + 3 * 8); + row4 = vld1q_s16(data + 4 * 8); + row5 = vld1q_s16(data + 5 * 8); + row6 = vld1q_s16(data + 6 * 8); + row7 = vld1q_s16(data + 7 * 8); + + // add DC bias + row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); + + // column pass + dct_pass(vrshrn_n_s32, 10); + + // 16bit 8x8 transpose + { // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. // whether compilers actually get this is another story, sadly. -#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } -#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } - - // pass 1 - dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 - dct_trn16(row2, row3); - dct_trn16(row4, row5); - dct_trn16(row6, row7); - - // pass 2 - dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 - dct_trn32(row1, row3); - dct_trn32(row4, row6); - dct_trn32(row5, row7); - - // pass 3 - dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 - dct_trn64(row1, row5); - dct_trn64(row2, row6); - dct_trn64(row3, row7); +#define dct_trn16(x, y) \ + { \ + int16x8x2_t t = vtrnq_s16(x, y); \ + x = t.val[0]; \ + y = t.val[1]; \ + } +#define dct_trn32(x, y) \ + { \ + int32x4x2_t t = \ + vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); \ + x = vreinterpretq_s16_s32(t.val[0]); \ + y = vreinterpretq_s16_s32(t.val[1]); \ + } +#define dct_trn64(x, y) \ + { \ + int16x8_t x0 = x; \ + int16x8_t y0 = y; \ + x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); \ + y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); \ + } + + // pass 1 + dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 + dct_trn16(row2, row3); + dct_trn16(row4, row5); + dct_trn16(row6, row7); + + // pass 2 + dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 + dct_trn32(row1, row3); + dct_trn32(row4, row6); + dct_trn32(row5, row7); + + // pass 3 + dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 + dct_trn64(row1, row5); + dct_trn64(row2, row6); + dct_trn64(row3, row7); #undef dct_trn16 #undef dct_trn32 #undef dct_trn64 - } - - // row pass - // vrshrn_n_s32 only supports shifts up to 16, we need - // 17. so do a non-rounding shift of 16 first then follow - // up with a rounding shift by 1. - dct_pass(vshrn_n_s32, 16); - - { - // pack and round - uint8x8_t p0 = vqrshrun_n_s16(row0, 1); - uint8x8_t p1 = vqrshrun_n_s16(row1, 1); - uint8x8_t p2 = vqrshrun_n_s16(row2, 1); - uint8x8_t p3 = vqrshrun_n_s16(row3, 1); - uint8x8_t p4 = vqrshrun_n_s16(row4, 1); - uint8x8_t p5 = vqrshrun_n_s16(row5, 1); - uint8x8_t p6 = vqrshrun_n_s16(row6, 1); - uint8x8_t p7 = vqrshrun_n_s16(row7, 1); - - // again, these can translate into one instruction, but often don't. -#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } -#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } - - // sadly can't use interleaved stores here since we only write - // 8 bytes to each scan line! - - // 8x8 8-bit transpose pass 1 - dct_trn8_8(p0, p1); - dct_trn8_8(p2, p3); - dct_trn8_8(p4, p5); - dct_trn8_8(p6, p7); - - // pass 2 - dct_trn8_16(p0, p2); - dct_trn8_16(p1, p3); - dct_trn8_16(p4, p6); - dct_trn8_16(p5, p7); - - // pass 3 - dct_trn8_32(p0, p4); - dct_trn8_32(p1, p5); - dct_trn8_32(p2, p6); - dct_trn8_32(p3, p7); - - // store - vst1_u8(out, p0); out += out_stride; - vst1_u8(out, p1); out += out_stride; - vst1_u8(out, p2); out += out_stride; - vst1_u8(out, p3); out += out_stride; - vst1_u8(out, p4); out += out_stride; - vst1_u8(out, p5); out += out_stride; - vst1_u8(out, p6); out += out_stride; - vst1_u8(out, p7); + } + + // row pass + // vrshrn_n_s32 only supports shifts up to 16, we need + // 17. so do a non-rounding shift of 16 first then follow + // up with a rounding shift by 1. + dct_pass(vshrn_n_s32, 16); + + { + // pack and round + uint8x8_t p0 = vqrshrun_n_s16(row0, 1); + uint8x8_t p1 = vqrshrun_n_s16(row1, 1); + uint8x8_t p2 = vqrshrun_n_s16(row2, 1); + uint8x8_t p3 = vqrshrun_n_s16(row3, 1); + uint8x8_t p4 = vqrshrun_n_s16(row4, 1); + uint8x8_t p5 = vqrshrun_n_s16(row5, 1); + uint8x8_t p6 = vqrshrun_n_s16(row6, 1); + uint8x8_t p7 = vqrshrun_n_s16(row7, 1); + + // again, these can translate into one instruction, but often don't. +#define dct_trn8_8(x, y) \ + { \ + uint8x8x2_t t = vtrn_u8(x, y); \ + x = t.val[0]; \ + y = t.val[1]; \ + } +#define dct_trn8_16(x, y) \ + { \ + uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); \ + x = vreinterpret_u8_u16(t.val[0]); \ + y = vreinterpret_u8_u16(t.val[1]); \ + } +#define dct_trn8_32(x, y) \ + { \ + uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); \ + x = vreinterpret_u8_u32(t.val[0]); \ + y = vreinterpret_u8_u32(t.val[1]); \ + } + + // sadly can't use interleaved stores here since we only write + // 8 bytes to each scan line! + + // 8x8 8-bit transpose pass 1 + dct_trn8_8(p0, p1); + dct_trn8_8(p2, p3); + dct_trn8_8(p4, p5); + dct_trn8_8(p6, p7); + + // pass 2 + dct_trn8_16(p0, p2); + dct_trn8_16(p1, p3); + dct_trn8_16(p4, p6); + dct_trn8_16(p5, p7); + + // pass 3 + dct_trn8_32(p0, p4); + dct_trn8_32(p1, p5); + dct_trn8_32(p2, p6); + dct_trn8_32(p3, p7); + + // store + vst1_u8(out, p0); + out += out_stride; + vst1_u8(out, p1); + out += out_stride; + vst1_u8(out, p2); + out += out_stride; + vst1_u8(out, p3); + out += out_stride; + vst1_u8(out, p4); + out += out_stride; + vst1_u8(out, p5); + out += out_stride; + vst1_u8(out, p6); + out += out_stride; + vst1_u8(out, p7); #undef dct_trn8_8 #undef dct_trn8_16 #undef dct_trn8_32 - } + } #undef dct_long_mul #undef dct_long_mac @@ -2716,1130 +2956,1270 @@ static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) #endif // STBI_NEON -#define STBI__MARKER_none 0xff +#define STBI__MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value -static stbi_uc stbi__get_marker(stbi__jpeg *j) -{ - stbi_uc x; - if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } - x = stbi__get8(j->s); - if (x != 0xff) return STBI__MARKER_none; - while (x == 0xff) - x = stbi__get8(j->s); // consume repeated 0xff fill bytes - return x; +static stbi_uc stbi__get_marker(stbi__jpeg *j) { + stbi_uc x; + if (j->marker != STBI__MARKER_none) { + x = j->marker; + j->marker = STBI__MARKER_none; + return x; + } + x = stbi__get8(j->s); + if (x != 0xff) + return STBI__MARKER_none; + while (x == 0xff) + x = stbi__get8(j->s); // consume repeated 0xff fill bytes + return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] -#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) +#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, stbi__jpeg_reset the entropy decoder and // the dc prediction -static void stbi__jpeg_reset(stbi__jpeg *j) -{ - j->code_bits = 0; - j->code_buffer = 0; - j->nomore = 0; - j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; - j->marker = STBI__MARKER_none; - j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; - j->eob_run = 0; - // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, - // since we don't even allow 1<<30 pixels -} - -static int stbi__parse_entropy_coded_data(stbi__jpeg *z) -{ - stbi__jpeg_reset(z); - if (!z->progressive) { - if (z->scan_n == 1) { - int i,j; - STBI_SIMD_ALIGN(short, data[64]); - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - STBI_SIMD_ALIGN(short, data[64]); - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x)*8; - int y2 = (j*z->img_comp[n].v + y)*8; - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; +static void stbi__jpeg_reset(stbi__jpeg *j) { + j->code_bits = 0; + j->code_buffer = 0; + j->nomore = 0; + j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = + j->img_comp[3].dc_pred = 0; + j->marker = STBI__MARKER_none; + j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; + j->eob_run = 0; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { + stbi__jpeg_reset(z); + if (!z->progressive) { + if (z->scan_n == 1) { + int i, j; + STBI_SIMD_ALIGN(short, data[64]); + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc + z->img_comp[n].hd, + z->huff_ac + ha, z->fast_ac[ha], n, + z->dequant[z->img_comp[n].tq])) + return 0; + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2 * j * 8 + + i * 8, + z->img_comp[n].w2, data); + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } } - } else { - if (z->scan_n == 1) { - int i,j; - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - if (z->spec_start == 0) { - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } else { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) - return 0; - } - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x); - int y2 = (j*z->img_comp[n].v + y); - short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } + return 1; + } else { // interleaved + int i, j, k, x, y; + STBI_SIMD_ALIGN(short, data[64]); + for (j = 0; j < z->img_mcu_y; ++j) { + for (i = 0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k = 0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y = 0; y < z->img_comp[n].v; ++y) { + for (x = 0; x < z->img_comp[n].h; ++x) { + int x2 = (i * z->img_comp[n].h + x) * 8; + int y2 = (j * z->img_comp[n].v + y) * 8; + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, + z->huff_dc + z->img_comp[n].hd, + z->huff_ac + ha, z->fast_ac[ha], n, + z->dequant[z->img_comp[n].tq])) + return 0; + z->idct_block_kernel(z->img_comp[n].data + + z->img_comp[n].w2 * y2 + x2, + z->img_comp[n].w2, data); + } } - } - return 1; + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } } - } -} - -static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) -{ - int i; - for (i=0; i < 64; ++i) - data[i] *= dequant[i]; -} - -static void stbi__jpeg_finish(stbi__jpeg *z) -{ - if (z->progressive) { - // dequantize and idct the data - int i,j,n; - for (n=0; n < z->s->img_n; ++n) { - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - } - } + return 1; + } + } else { + if (z->scan_n == 1) { + int i, j; + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + short *data = + z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + if (z->spec_start == 0) { + if (!stbi__jpeg_decode_block_prog_dc( + z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } else { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], + z->fast_ac[ha])) + return 0; + } + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } } - } -} - -static int stbi__process_marker(stbi__jpeg *z, int m) -{ - int L; - switch (m) { - case STBI__MARKER_none: // no marker found - return stbi__err("expected marker","Corrupt JPEG"); - - case 0xDD: // DRI - specify restart interval - if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); - z->restart_interval = stbi__get16be(z->s); - return 1; - - case 0xDB: // DQT - define quantization table - L = stbi__get16be(z->s)-2; - while (L > 0) { - int q = stbi__get8(z->s); - int p = q >> 4, sixteen = (p != 0); - int t = q & 15,i; - if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); - if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); - - for (i=0; i < 64; ++i) - z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); - L -= (sixteen ? 129 : 65); - } - return L==0; - - case 0xC4: // DHT - define huffman table - L = stbi__get16be(z->s)-2; - while (L > 0) { - stbi_uc *v; - int sizes[16],i,n=0; - int q = stbi__get8(z->s); - int tc = q >> 4; - int th = q & 15; - if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); - for (i=0; i < 16; ++i) { - sizes[i] = stbi__get8(z->s); - n += sizes[i]; - } - L -= 17; - if (tc == 0) { - if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; - v = z->huff_dc[th].values; - } else { - if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; - v = z->huff_ac[th].values; + return 1; + } else { // interleaved + int i, j, k, x, y; + for (j = 0; j < z->img_mcu_y; ++j) { + for (i = 0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k = 0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y = 0; y < z->img_comp[n].v; ++y) { + for (x = 0; x < z->img_comp[n].h; ++x) { + int x2 = (i * z->img_comp[n].h + x); + int y2 = (j * z->img_comp[n].v + y); + short *data = z->img_comp[n].coeff + + 64 * (x2 + y2 * z->img_comp[n].coeff_w); + if (!stbi__jpeg_decode_block_prog_dc( + z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } } - for (i=0; i < n; ++i) - v[i] = stbi__get8(z->s); - if (tc != 0) - stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); - L -= n; - } - return L==0; - } - - // check for comment block or APP blocks - if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { - L = stbi__get16be(z->s); - if (L < 2) { - if (m == 0xFE) - return stbi__err("bad COM len","Corrupt JPEG"); - else - return stbi__err("bad APP len","Corrupt JPEG"); + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } } - L -= 2; - - if (m == 0xE0 && L >= 5) { // JFIF APP0 segment - static const unsigned char tag[5] = {'J','F','I','F','\0'}; - int ok = 1; - int i; - for (i=0; i < 5; ++i) - if (stbi__get8(z->s) != tag[i]) - ok = 0; - L -= 5; - if (ok) - z->jfif = 1; - } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment - static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; - int ok = 1; - int i; - for (i=0; i < 6; ++i) - if (stbi__get8(z->s) != tag[i]) - ok = 0; - L -= 6; - if (ok) { - stbi__get8(z->s); // version - stbi__get16be(z->s); // flags0 - stbi__get16be(z->s); // flags1 - z->app14_color_transform = stbi__get8(z->s); // color transform - L -= 6; - } + return 1; + } + } +} + +static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) { + int i; + for (i = 0; i < 64; ++i) + data[i] *= dequant[i]; +} + +static void stbi__jpeg_finish(stbi__jpeg *z) { + if (z->progressive) { + // dequantize and idct the data + int i, j, n; + for (n = 0; n < z->s->img_n; ++n) { + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + short *data = + z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2 * j * 8 + + i * 8, + z->img_comp[n].w2, data); + } } + } + } +} - stbi__skip(z->s, L); - return 1; - } +static int stbi__process_marker(stbi__jpeg *z, int m) { + int L; + switch (m) { + case STBI__MARKER_none: // no marker found + return stbi__err("expected marker", "Corrupt JPEG"); - return stbi__err("unknown marker","Corrupt JPEG"); -} + case 0xDD: // DRI - specify restart interval + if (stbi__get16be(z->s) != 4) + return stbi__err("bad DRI len", "Corrupt JPEG"); + z->restart_interval = stbi__get16be(z->s); + return 1; -// after we see SOS -static int stbi__process_scan_header(stbi__jpeg *z) -{ - int i; - int Ls = stbi__get16be(z->s); - z->scan_n = stbi__get8(z->s); - if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); - if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); - for (i=0; i < z->scan_n; ++i) { - int id = stbi__get8(z->s), which; + case 0xDB: // DQT - define quantization table + L = stbi__get16be(z->s) - 2; + while (L > 0) { int q = stbi__get8(z->s); - for (which = 0; which < z->s->img_n; ++which) - if (z->img_comp[which].id == id) - break; - if (which == z->s->img_n) return 0; // no match - z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); - z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); - z->order[i] = which; - } - - { - int aa; - z->spec_start = stbi__get8(z->s); - z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 - aa = stbi__get8(z->s); - z->succ_high = (aa >> 4); - z->succ_low = (aa & 15); - if (z->progressive) { - if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) - return stbi__err("bad SOS", "Corrupt JPEG"); + int p = q >> 4, sixteen = (p != 0); + int t = q & 15, i; + if (p != 0 && p != 1) + return stbi__err("bad DQT type", "Corrupt JPEG"); + if (t > 3) + return stbi__err("bad DQT table", "Corrupt JPEG"); + + for (i = 0; i < 64; ++i) + z->dequant[t][stbi__jpeg_dezigzag[i]] = + (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); + L -= (sixteen ? 129 : 65); + } + return L == 0; + + case 0xC4: // DHT - define huffman table + L = stbi__get16be(z->s) - 2; + while (L > 0) { + stbi_uc *v; + int sizes[16], i, n = 0; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) + return stbi__err("bad DHT header", "Corrupt JPEG"); + for (i = 0; i < 16; ++i) { + sizes[i] = stbi__get8(z->s); + n += sizes[i]; + } + L -= 17; + if (tc == 0) { + if (!stbi__build_huffman(z->huff_dc + th, sizes)) + return 0; + v = z->huff_dc[th].values; } else { - if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); - if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); - z->spec_end = 63; + if (!stbi__build_huffman(z->huff_ac + th, sizes)) + return 0; + v = z->huff_ac[th].values; + } + for (i = 0; i < n; ++i) + v[i] = stbi__get8(z->s); + if (tc != 0) + stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + L -= n; + } + return L == 0; + } + + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + L = stbi__get16be(z->s); + if (L < 2) { + if (m == 0xFE) + return stbi__err("bad COM len", "Corrupt JPEG"); + else + return stbi__err("bad APP len", "Corrupt JPEG"); + } + L -= 2; + + if (m == 0xE0 && L >= 5) { // JFIF APP0 segment + static const unsigned char tag[5] = {'J', 'F', 'I', 'F', '\0'}; + int ok = 1; + int i; + for (i = 0; i < 5; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 5; + if (ok) + z->jfif = 1; + } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment + static const unsigned char tag[6] = {'A', 'd', 'o', 'b', 'e', '\0'}; + int ok = 1; + int i; + for (i = 0; i < 6; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 6; + if (ok) { + stbi__get8(z->s); // version + stbi__get16be(z->s); // flags0 + stbi__get16be(z->s); // flags1 + z->app14_color_transform = stbi__get8(z->s); // color transform + L -= 6; } - } + } + + stbi__skip(z->s, L); + return 1; + } - return 1; + return stbi__err("unknown marker", "Corrupt JPEG"); } -static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) -{ - int i; - for (i=0; i < ncomp; ++i) { - if (z->img_comp[i].raw_data) { - STBI_FREE(z->img_comp[i].raw_data); - z->img_comp[i].raw_data = NULL; - z->img_comp[i].data = NULL; - } - if (z->img_comp[i].raw_coeff) { - STBI_FREE(z->img_comp[i].raw_coeff); - z->img_comp[i].raw_coeff = 0; - z->img_comp[i].coeff = 0; - } - if (z->img_comp[i].linebuf) { - STBI_FREE(z->img_comp[i].linebuf); - z->img_comp[i].linebuf = NULL; - } - } - return why; +// after we see SOS +static int stbi__process_scan_header(stbi__jpeg *z) { + int i; + int Ls = stbi__get16be(z->s); + z->scan_n = stbi__get8(z->s); + if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int)z->s->img_n) + return stbi__err("bad SOS component count", "Corrupt JPEG"); + if (Ls != 6 + 2 * z->scan_n) + return stbi__err("bad SOS len", "Corrupt JPEG"); + for (i = 0; i < z->scan_n; ++i) { + int id = stbi__get8(z->s), which; + int q = stbi__get8(z->s); + for (which = 0; which < z->s->img_n; ++which) + if (z->img_comp[which].id == id) + break; + if (which == z->s->img_n) + return 0; // no match + z->img_comp[which].hd = q >> 4; + if (z->img_comp[which].hd > 3) + return stbi__err("bad DC huff", "Corrupt JPEG"); + z->img_comp[which].ha = q & 15; + if (z->img_comp[which].ha > 3) + return stbi__err("bad AC huff", "Corrupt JPEG"); + z->order[i] = which; + } + + { + int aa; + z->spec_start = stbi__get8(z->s); + z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 + aa = stbi__get8(z->s); + z->succ_high = (aa >> 4); + z->succ_low = (aa & 15); + if (z->progressive) { + if (z->spec_start > 63 || z->spec_end > 63 || + z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) + return stbi__err("bad SOS", "Corrupt JPEG"); + } else { + if (z->spec_start != 0) + return stbi__err("bad SOS", "Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) + return stbi__err("bad SOS", "Corrupt JPEG"); + z->spec_end = 63; + } + } + + return 1; } -static int stbi__process_frame_header(stbi__jpeg *z, int scan) -{ - stbi__context *s = z->s; - int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG - p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline - s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG - s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires - c = stbi__get8(s); - if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); - s->img_n = c; - for (i=0; i < c; ++i) { +static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) { + int i; + for (i = 0; i < ncomp; ++i) { + if (z->img_comp[i].raw_data) { + STBI_FREE(z->img_comp[i].raw_data); + z->img_comp[i].raw_data = NULL; z->img_comp[i].data = NULL; - z->img_comp[i].linebuf = NULL; - } - - if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); - - z->rgb = 0; - for (i=0; i < s->img_n; ++i) { - static const unsigned char rgb[3] = { 'R', 'G', 'B' }; - z->img_comp[i].id = stbi__get8(s); - if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) - ++z->rgb; - q = stbi__get8(s); - z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); - z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); - z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); - } - - if (scan != STBI__SCAN_load) return 1; - - if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); - - for (i=0; i < s->img_n; ++i) { - if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; - if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; - } - - // compute interleaved mcu info - z->img_h_max = h_max; - z->img_v_max = v_max; - z->img_mcu_w = h_max * 8; - z->img_mcu_h = v_max * 8; - // these sizes can't be more than 17 bits - z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; - z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; - - for (i=0; i < s->img_n; ++i) { - // number of effective pixels (e.g. for non-interleaved MCU) - z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; - z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; - // to simplify generation, we'll allocate enough memory to decode - // the bogus oversized data from using interleaved MCUs and their - // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't - // discard the extra data until colorspace conversion - // - // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) - // so these muls can't overflow with 32-bit ints (which we require) - z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; - z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; - z->img_comp[i].coeff = 0; + } + if (z->img_comp[i].raw_coeff) { + STBI_FREE(z->img_comp[i].raw_coeff); z->img_comp[i].raw_coeff = 0; + z->img_comp[i].coeff = 0; + } + if (z->img_comp[i].linebuf) { + STBI_FREE(z->img_comp[i].linebuf); z->img_comp[i].linebuf = NULL; - z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); - if (z->img_comp[i].raw_data == NULL) - return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); - // align blocks for idct using mmx/sse - z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); - if (z->progressive) { - // w2, h2 are multiples of 8 (see above) - z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; - z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; - z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); - if (z->img_comp[i].raw_coeff == NULL) - return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); - z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); - } - } + } + } + return why; +} + +static int stbi__process_frame_header(stbi__jpeg *z, int scan) { + stbi__context *s = z->s; + int Lf, p, i, q, h_max = 1, v_max = 1, c; + Lf = stbi__get16be(s); + if (Lf < 11) + return stbi__err("bad SOF len", "Corrupt JPEG"); // JPEG + p = stbi__get8(s); + if (p != 8) + return stbi__err("only 8-bit", + "JPEG format not supported: 8-bit only"); // JPEG baseline + s->img_y = stbi__get16be(s); + if (s->img_y == 0) + return stbi__err( + "no header height", + "JPEG format not supported: delayed height"); // Legal, but we don't + // handle it--but neither + // does IJG + s->img_x = stbi__get16be(s); + if (s->img_x == 0) + return stbi__err("0 width", "Corrupt JPEG"); // JPEG requires + c = stbi__get8(s); + if (c != 3 && c != 1 && c != 4) + return stbi__err("bad component count", "Corrupt JPEG"); + s->img_n = c; + for (i = 0; i < c; ++i) { + z->img_comp[i].data = NULL; + z->img_comp[i].linebuf = NULL; + } + + if (Lf != 8 + 3 * s->img_n) + return stbi__err("bad SOF len", "Corrupt JPEG"); + + z->rgb = 0; + for (i = 0; i < s->img_n; ++i) { + static const unsigned char rgb[3] = {'R', 'G', 'B'}; + z->img_comp[i].id = stbi__get8(s); + if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) + ++z->rgb; + q = stbi__get8(s); + z->img_comp[i].h = (q >> 4); + if (!z->img_comp[i].h || z->img_comp[i].h > 4) + return stbi__err("bad H", "Corrupt JPEG"); + z->img_comp[i].v = q & 15; + if (!z->img_comp[i].v || z->img_comp[i].v > 4) + return stbi__err("bad V", "Corrupt JPEG"); + z->img_comp[i].tq = stbi__get8(s); + if (z->img_comp[i].tq > 3) + return stbi__err("bad TQ", "Corrupt JPEG"); + } + + if (scan != STBI__SCAN_load) + return 1; + + if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) + return stbi__err("too large", "Image too large to decode"); + + for (i = 0; i < s->img_n; ++i) { + if (z->img_comp[i].h > h_max) + h_max = z->img_comp[i].h; + if (z->img_comp[i].v > v_max) + v_max = z->img_comp[i].v; + } + + // compute interleaved mcu info + z->img_h_max = h_max; + z->img_v_max = v_max; + z->img_mcu_w = h_max * 8; + z->img_mcu_h = v_max * 8; + // these sizes can't be more than 17 bits + z->img_mcu_x = (s->img_x + z->img_mcu_w - 1) / z->img_mcu_w; + z->img_mcu_y = (s->img_y + z->img_mcu_h - 1) / z->img_mcu_h; + + for (i = 0; i < s->img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max - 1) / h_max; + z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max - 1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + // + // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked + // earlier) so these muls can't overflow with 32-bit ints (which we require) + z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; + z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; + z->img_comp[i].coeff = 0; + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].linebuf = NULL; + z->img_comp[i].raw_data = + stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); + if (z->img_comp[i].raw_data == NULL) + return stbi__free_jpeg_components(z, i + 1, + stbi__err("outofmem", "Out of memory")); + // align blocks for idct using mmx/sse + z->img_comp[i].data = + (stbi_uc *)(((size_t)z->img_comp[i].raw_data + 15) & ~15); + if (z->progressive) { + // w2, h2 are multiples of 8 (see above) + z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; + z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; + z->img_comp[i].raw_coeff = stbi__malloc_mad3( + z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); + if (z->img_comp[i].raw_coeff == NULL) + return stbi__free_jpeg_components( + z, i + 1, stbi__err("outofmem", "Out of memory")); + z->img_comp[i].coeff = + (short *)(((size_t)z->img_comp[i].raw_coeff + 15) & ~15); + } + } - return 1; + return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) -#define stbi__DNL(x) ((x) == 0xdc) -#define stbi__SOI(x) ((x) == 0xd8) -#define stbi__EOI(x) ((x) == 0xd9) -#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) -#define stbi__SOS(x) ((x) == 0xda) - -#define stbi__SOF_progressive(x) ((x) == 0xc2) - -static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) -{ - int m; - z->jfif = 0; - z->app14_color_transform = -1; // valid values are 0,1,2 - z->marker = STBI__MARKER_none; // initialize cached marker to empty - m = stbi__get_marker(z); - if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); - if (scan == STBI__SCAN_type) return 1; - m = stbi__get_marker(z); - while (!stbi__SOF(m)) { - if (!stbi__process_marker(z,m)) return 0; +#define stbi__DNL(x) ((x) == 0xdc) +#define stbi__SOI(x) ((x) == 0xd8) +#define stbi__EOI(x) ((x) == 0xd9) +#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define stbi__SOS(x) ((x) == 0xda) + +#define stbi__SOF_progressive(x) ((x) == 0xc2) + +static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { + int m; + z->jfif = 0; + z->app14_color_transform = -1; // valid values are 0,1,2 + z->marker = STBI__MARKER_none; // initialize cached marker to empty + m = stbi__get_marker(z); + if (!stbi__SOI(m)) + return stbi__err("no SOI", "Corrupt JPEG"); + if (scan == STBI__SCAN_type) + return 1; + m = stbi__get_marker(z); + while (!stbi__SOF(m)) { + if (!stbi__process_marker(z, m)) + return 0; + m = stbi__get_marker(z); + while (m == STBI__MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (stbi__at_eof(z->s)) + return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); - while (m == STBI__MARKER_none) { - // some files have extra padding after their blocks, so ok, we'll scan - if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); - m = stbi__get_marker(z); - } - } - z->progressive = stbi__SOF_progressive(m); - if (!stbi__process_frame_header(z, scan)) return 0; - return 1; + } + } + z->progressive = stbi__SOF_progressive(m); + if (!stbi__process_frame_header(z, scan)) + return 0; + return 1; } // decode image to YCbCr format -static int stbi__decode_jpeg_image(stbi__jpeg *j) -{ - int m; - for (m = 0; m < 4; m++) { - j->img_comp[m].raw_data = NULL; - j->img_comp[m].raw_coeff = NULL; - } - j->restart_interval = 0; - if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; - m = stbi__get_marker(j); - while (!stbi__EOI(m)) { - if (stbi__SOS(m)) { - if (!stbi__process_scan_header(j)) return 0; - if (!stbi__parse_entropy_coded_data(j)) return 0; - if (j->marker == STBI__MARKER_none ) { - // handle 0s at the end of image data from IP Kamera 9060 - while (!stbi__at_eof(j->s)) { - int x = stbi__get8(j->s); - if (x == 255) { - j->marker = stbi__get8(j->s); - break; - } - } - // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 - } - } else if (stbi__DNL(m)) { - int Ld = stbi__get16be(j->s); - stbi__uint32 NL = stbi__get16be(j->s); - if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); - if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); - } else { - if (!stbi__process_marker(j, m)) return 0; +static int stbi__decode_jpeg_image(stbi__jpeg *j) { + int m; + for (m = 0; m < 4; m++) { + j->img_comp[m].raw_data = NULL; + j->img_comp[m].raw_coeff = NULL; + } + j->restart_interval = 0; + if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) + return 0; + m = stbi__get_marker(j); + while (!stbi__EOI(m)) { + if (stbi__SOS(m)) { + if (!stbi__process_scan_header(j)) + return 0; + if (!stbi__parse_entropy_coded_data(j)) + return 0; + if (j->marker == STBI__MARKER_none) { + // handle 0s at the end of image data from IP Kamera 9060 + while (!stbi__at_eof(j->s)) { + int x = stbi__get8(j->s); + if (x == 255) { + j->marker = stbi__get8(j->s); + break; + } + } + // if we reach eof without hitting a marker, stbi__get_marker() below + // will fail and we'll eventually return 0 } - m = stbi__get_marker(j); - } - if (j->progressive) - stbi__jpeg_finish(j); - return 1; + } else if (stbi__DNL(m)) { + int Ld = stbi__get16be(j->s); + stbi__uint32 NL = stbi__get16be(j->s); + if (Ld != 4) + return stbi__err("bad DNL len", "Corrupt JPEG"); + if (NL != j->s->img_y) + return stbi__err("bad DNL height", "Corrupt JPEG"); + } else { + if (!stbi__process_marker(j, m)) + return 0; + } + m = stbi__get_marker(j); + } + if (j->progressive) + stbi__jpeg_finish(j); + return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, - int w, int hs); - -#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) - -static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - STBI_NOTUSED(out); - STBI_NOTUSED(in_far); - STBI_NOTUSED(w); - STBI_NOTUSED(hs); - return in_near; -} - -static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples vertically for every one in input - int i; - STBI_NOTUSED(hs); - for (i=0; i < w; ++i) - out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); - return out; -} - -static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples horizontally for every one in input - int i; - stbi_uc *input = in_near; - - if (w == 1) { - // if only one sample, can't do any interpolation - out[0] = out[1] = input[0]; - return out; - } - - out[0] = input[0]; - out[1] = stbi__div4(input[0]*3 + input[1] + 2); - for (i=1; i < w-1; ++i) { - int n = 3*input[i]+2; - out[i*2+0] = stbi__div4(n+input[i-1]); - out[i*2+1] = stbi__div4(n+input[i+1]); - } - out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); - out[i*2+1] = input[w-1]; - - STBI_NOTUSED(in_far); - STBI_NOTUSED(hs); - - return out; -} - -#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) - -static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i,t0,t1; - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - out[0] = stbi__div4(t1+2); - for (i=1; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); - - STBI_NOTUSED(hs); - - return out; + int w, int hs); + +#define stbi__div4(x) ((stbi_uc)((x) >> 2)) + +static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, + int w, int hs) { + STBI_NOTUSED(out); + STBI_NOTUSED(in_far); + STBI_NOTUSED(w); + STBI_NOTUSED(hs); + return in_near; +} + +static stbi_uc *stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, + stbi_uc *in_far, int w, int hs) { + // need to generate two samples vertically for every one in input + int i; + STBI_NOTUSED(hs); + for (i = 0; i < w; ++i) + out[i] = stbi__div4(3 * in_near[i] + in_far[i] + 2); + return out; +} + +static stbi_uc *stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, + stbi_uc *in_far, int w, int hs) { + // need to generate two samples horizontally for every one in input + int i; + stbi_uc *input = in_near; + + if (w == 1) { + // if only one sample, can't do any interpolation + out[0] = out[1] = input[0]; + return out; + } + + out[0] = input[0]; + out[1] = stbi__div4(input[0] * 3 + input[1] + 2); + for (i = 1; i < w - 1; ++i) { + int n = 3 * input[i] + 2; + out[i * 2 + 0] = stbi__div4(n + input[i - 1]); + out[i * 2 + 1] = stbi__div4(n + input[i + 1]); + } + out[i * 2 + 0] = stbi__div4(input[w - 2] * 3 + input[w - 1] + 2); + out[i * 2 + 1] = input[w - 1]; + + STBI_NOTUSED(in_far); + STBI_NOTUSED(hs); + + return out; +} + +#define stbi__div16(x) ((stbi_uc)((x) >> 4)) + +static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, + stbi_uc *in_far, int w, int hs) { + // need to generate 2x2 samples for every one in input + int i, t0, t1; + if (w == 1) { + out[0] = out[1] = stbi__div4(3 * in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3 * in_near[0] + in_far[0]; + out[0] = stbi__div4(t1 + 2); + for (i = 1; i < w; ++i) { + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2 - 1] = stbi__div16(3 * t0 + t1 + 8); + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + } + out[w * 2 - 1] = stbi__div4(t1 + 2); + + STBI_NOTUSED(hs); + + return out; } #if defined(STBI_SSE2) || defined(STBI_NEON) -static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i=0,t0,t1; - - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - // process groups of 8 pixels for as long as we can. - // note we can't handle the last pixel in a row in this loop - // because we need to handle the filter boundary conditions. - for (; i < ((w-1) & ~7); i += 8) { +static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, + stbi_uc *in_far, int w, int hs) { + // need to generate 2x2 samples for every one in input + int i = 0, t0, t1; + + if (w == 1) { + out[0] = out[1] = stbi__div4(3 * in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3 * in_near[0] + in_far[0]; + // process groups of 8 pixels for as long as we can. + // note we can't handle the last pixel in a row in this loop + // because we need to handle the filter boundary conditions. + for (; i < ((w - 1) & ~7); i += 8) { #if defined(STBI_SSE2) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - __m128i zero = _mm_setzero_si128(); - __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); - __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); - __m128i farw = _mm_unpacklo_epi8(farb, zero); - __m128i nearw = _mm_unpacklo_epi8(nearb, zero); - __m128i diff = _mm_sub_epi16(farw, nearw); - __m128i nears = _mm_slli_epi16(nearw, 2); - __m128i curr = _mm_add_epi16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - __m128i prv0 = _mm_slli_si128(curr, 2); - __m128i nxt0 = _mm_srli_si128(curr, 2); - __m128i prev = _mm_insert_epi16(prv0, t1, 0); - __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - __m128i bias = _mm_set1_epi16(8); - __m128i curs = _mm_slli_epi16(curr, 2); - __m128i prvd = _mm_sub_epi16(prev, curr); - __m128i nxtd = _mm_sub_epi16(next, curr); - __m128i curb = _mm_add_epi16(curs, bias); - __m128i even = _mm_add_epi16(prvd, curb); - __m128i odd = _mm_add_epi16(nxtd, curb); - - // interleave even and odd pixels, then undo scaling. - __m128i int0 = _mm_unpacklo_epi16(even, odd); - __m128i int1 = _mm_unpackhi_epi16(even, odd); - __m128i de0 = _mm_srli_epi16(int0, 4); - __m128i de1 = _mm_srli_epi16(int1, 4); - - // pack and write output - __m128i outv = _mm_packus_epi16(de0, de1); - _mm_storeu_si128((__m128i *) (out + i*2), outv); + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + __m128i zero = _mm_setzero_si128(); + __m128i farb = _mm_loadl_epi64((__m128i *)(in_far + i)); + __m128i nearb = _mm_loadl_epi64((__m128i *)(in_near + i)); + __m128i farw = _mm_unpacklo_epi8(farb, zero); + __m128i nearw = _mm_unpacklo_epi8(nearb, zero); + __m128i diff = _mm_sub_epi16(farw, nearw); + __m128i nears = _mm_slli_epi16(nearw, 2); + __m128i curr = _mm_add_epi16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + __m128i prv0 = _mm_slli_si128(curr, 2); + __m128i nxt0 = _mm_srli_si128(curr, 2); + __m128i prev = _mm_insert_epi16(prv0, t1, 0); + __m128i next = + _mm_insert_epi16(nxt0, 3 * in_near[i + 8] + in_far[i + 8], 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + __m128i bias = _mm_set1_epi16(8); + __m128i curs = _mm_slli_epi16(curr, 2); + __m128i prvd = _mm_sub_epi16(prev, curr); + __m128i nxtd = _mm_sub_epi16(next, curr); + __m128i curb = _mm_add_epi16(curs, bias); + __m128i even = _mm_add_epi16(prvd, curb); + __m128i odd = _mm_add_epi16(nxtd, curb); + + // interleave even and odd pixels, then undo scaling. + __m128i int0 = _mm_unpacklo_epi16(even, odd); + __m128i int1 = _mm_unpackhi_epi16(even, odd); + __m128i de0 = _mm_srli_epi16(int0, 4); + __m128i de1 = _mm_srli_epi16(int1, 4); + + // pack and write output + __m128i outv = _mm_packus_epi16(de0, de1); + _mm_storeu_si128((__m128i *)(out + i * 2), outv); #elif defined(STBI_NEON) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - uint8x8_t farb = vld1_u8(in_far + i); - uint8x8_t nearb = vld1_u8(in_near + i); - int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); - int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); - int16x8_t curr = vaddq_s16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - int16x8_t prv0 = vextq_s16(curr, curr, 7); - int16x8_t nxt0 = vextq_s16(curr, curr, 1); - int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); - int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - int16x8_t curs = vshlq_n_s16(curr, 2); - int16x8_t prvd = vsubq_s16(prev, curr); - int16x8_t nxtd = vsubq_s16(next, curr); - int16x8_t even = vaddq_s16(curs, prvd); - int16x8_t odd = vaddq_s16(curs, nxtd); - - // undo scaling and round, then store with even/odd phases interleaved - uint8x8x2_t o; - o.val[0] = vqrshrun_n_s16(even, 4); - o.val[1] = vqrshrun_n_s16(odd, 4); - vst2_u8(out + i*2, o); + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + uint8x8_t farb = vld1_u8(in_far + i); + uint8x8_t nearb = vld1_u8(in_near + i); + int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); + int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); + int16x8_t curr = vaddq_s16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + int16x8_t prv0 = vextq_s16(curr, curr, 7); + int16x8_t nxt0 = vextq_s16(curr, curr, 1); + int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); + int16x8_t next = + vsetq_lane_s16(3 * in_near[i + 8] + in_far[i + 8], nxt0, 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + int16x8_t curs = vshlq_n_s16(curr, 2); + int16x8_t prvd = vsubq_s16(prev, curr); + int16x8_t nxtd = vsubq_s16(next, curr); + int16x8_t even = vaddq_s16(curs, prvd); + int16x8_t odd = vaddq_s16(curs, nxtd); + + // undo scaling and round, then store with even/odd phases interleaved + uint8x8x2_t o; + o.val[0] = vqrshrun_n_s16(even, 4); + o.val[1] = vqrshrun_n_s16(odd, 4); + vst2_u8(out + i * 2, o); #endif - // "previous" value for next iter - t1 = 3*in_near[i+7] + in_far[i+7]; - } + // "previous" value for next iter + t1 = 3 * in_near[i + 7] + in_far[i + 7]; + } - t0 = t1; - t1 = 3*in_near[i] + in_far[i]; - out[i*2] = stbi__div16(3*t1 + t0 + 8); + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); - for (++i; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); + for (++i; i < w; ++i) { + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2 - 1] = stbi__div16(3 * t0 + t1 + 8); + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + } + out[w * 2 - 1] = stbi__div4(t1 + 2); - STBI_NOTUSED(hs); + STBI_NOTUSED(hs); - return out; + return out; } #endif -static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // resample with nearest-neighbor - int i,j; - STBI_NOTUSED(in_far); - for (i=0; i < w; ++i) - for (j=0; j < hs; ++j) - out[i*hs+j] = in_near[i]; - return out; +static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, + stbi_uc *in_far, int w, int hs) { + // resample with nearest-neighbor + int i, j; + STBI_NOTUSED(in_far); + for (i = 0; i < w; ++i) + for (j = 0; j < hs; ++j) + out[i * hs + j] = in_near[i]; + return out; } // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar -#define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) -static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* stbi__float2fixed(1.40200f); - g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* stbi__float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } +#define stbi__float2fixed(x) (((int)((x) * 4096.0f + 0.5f)) << 8) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, + const stbi_uc *pcb, const stbi_uc *pcr, + int count, int step) { + int i; + for (i = 0; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1 << 19); // rounding + int r, g, b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr * stbi__float2fixed(1.40200f); + g = y_fixed + (cr * -stbi__float2fixed(0.71414f)) + + ((cb * -stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb * stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned)r > 255) { + if (r < 0) + r = 0; + else + r = 255; + } + if ((unsigned)g > 255) { + if (g < 0) + g = 0; + else + g = 255; + } + if ((unsigned)b > 255) { + if (b < 0) + b = 0; + else + b = 255; + } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } } #if defined(STBI_SSE2) || defined(STBI_NEON) -static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) -{ - int i = 0; +static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, + stbi_uc const *pcb, stbi_uc const *pcr, + int count, int step) { + int i = 0; #ifdef STBI_SSE2 - // step == 3 is pretty ugly on the final interleave, and i'm not convinced - // it's useful in practice (you wouldn't use it for textures, for example). - // so just accelerate step == 4 case. - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - __m128i signflip = _mm_set1_epi8(-0x80); - __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); - __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); - __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); - __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); - __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); - __m128i xw = _mm_set1_epi16(255); // alpha channel - - for (; i+7 < count; i += 8) { - // load - __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); - __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); - __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); - __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 - __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 - - // unpack to short (and left-shift cr, cb by 8) - __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); - __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); - __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); - - // color transform - __m128i yws = _mm_srli_epi16(yw, 4); - __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); - __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); - __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); - __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); - __m128i rws = _mm_add_epi16(cr0, yws); - __m128i gwt = _mm_add_epi16(cb0, yws); - __m128i bws = _mm_add_epi16(yws, cb1); - __m128i gws = _mm_add_epi16(gwt, cr1); - - // descale - __m128i rw = _mm_srai_epi16(rws, 4); - __m128i bw = _mm_srai_epi16(bws, 4); - __m128i gw = _mm_srai_epi16(gws, 4); - - // back to byte, set up for transpose - __m128i brb = _mm_packus_epi16(rw, bw); - __m128i gxb = _mm_packus_epi16(gw, xw); - - // transpose to interleave channels - __m128i t0 = _mm_unpacklo_epi8(brb, gxb); - __m128i t1 = _mm_unpackhi_epi8(brb, gxb); - __m128i o0 = _mm_unpacklo_epi16(t0, t1); - __m128i o1 = _mm_unpackhi_epi16(t0, t1); - - // store - _mm_storeu_si128((__m128i *) (out + 0), o0); - _mm_storeu_si128((__m128i *) (out + 16), o1); - out += 32; - } - } + // step == 3 is pretty ugly on the final interleave, and i'm not convinced + // it's useful in practice (you wouldn't use it for textures, for example). + // so just accelerate step == 4 case. + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + __m128i signflip = _mm_set1_epi8(-0x80); + __m128i cr_const0 = _mm_set1_epi16((short)(1.40200f * 4096.0f + 0.5f)); + __m128i cr_const1 = _mm_set1_epi16(-(short)(0.71414f * 4096.0f + 0.5f)); + __m128i cb_const0 = _mm_set1_epi16(-(short)(0.34414f * 4096.0f + 0.5f)); + __m128i cb_const1 = _mm_set1_epi16((short)(1.77200f * 4096.0f + 0.5f)); + __m128i y_bias = _mm_set1_epi8((char)(unsigned char)128); + __m128i xw = _mm_set1_epi16(255); // alpha channel + + for (; i + 7 < count; i += 8) { + // load + __m128i y_bytes = _mm_loadl_epi64((__m128i *)(y + i)); + __m128i cr_bytes = _mm_loadl_epi64((__m128i *)(pcr + i)); + __m128i cb_bytes = _mm_loadl_epi64((__m128i *)(pcb + i)); + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + + // unpack to short (and left-shift cr, cb by 8) + __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); + __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); + __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); + + // color transform + __m128i yws = _mm_srli_epi16(yw, 4); + __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); + __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); + __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); + __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); + __m128i rws = _mm_add_epi16(cr0, yws); + __m128i gwt = _mm_add_epi16(cb0, yws); + __m128i bws = _mm_add_epi16(yws, cb1); + __m128i gws = _mm_add_epi16(gwt, cr1); + + // descale + __m128i rw = _mm_srai_epi16(rws, 4); + __m128i bw = _mm_srai_epi16(bws, 4); + __m128i gw = _mm_srai_epi16(gws, 4); + + // back to byte, set up for transpose + __m128i brb = _mm_packus_epi16(rw, bw); + __m128i gxb = _mm_packus_epi16(gw, xw); + + // transpose to interleave channels + __m128i t0 = _mm_unpacklo_epi8(brb, gxb); + __m128i t1 = _mm_unpackhi_epi8(brb, gxb); + __m128i o0 = _mm_unpacklo_epi16(t0, t1); + __m128i o1 = _mm_unpackhi_epi16(t0, t1); + + // store + _mm_storeu_si128((__m128i *)(out + 0), o0); + _mm_storeu_si128((__m128i *)(out + 16), o1); + out += 32; + } + } #endif #ifdef STBI_NEON - // in this version, step=3 support would be easy to add. but is there demand? - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - uint8x8_t signflip = vdup_n_u8(0x80); - int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); - int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); - int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); - int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); - - for (; i+7 < count; i += 8) { - // load - uint8x8_t y_bytes = vld1_u8(y + i); - uint8x8_t cr_bytes = vld1_u8(pcr + i); - uint8x8_t cb_bytes = vld1_u8(pcb + i); - int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); - int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); - - // expand to s16 - int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); - int16x8_t crw = vshll_n_s8(cr_biased, 7); - int16x8_t cbw = vshll_n_s8(cb_biased, 7); - - // color transform - int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); - int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); - int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); - int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); - int16x8_t rws = vaddq_s16(yws, cr0); - int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); - int16x8_t bws = vaddq_s16(yws, cb1); - - // undo scaling, round, convert to byte - uint8x8x4_t o; - o.val[0] = vqrshrun_n_s16(rws, 4); - o.val[1] = vqrshrun_n_s16(gws, 4); - o.val[2] = vqrshrun_n_s16(bws, 4); - o.val[3] = vdup_n_u8(255); - - // store, interleaving r/g/b/a - vst4_u8(out, o); - out += 8*4; - } - } + // in this version, step=3 support would be easy to add. but is there demand? + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + uint8x8_t signflip = vdup_n_u8(0x80); + int16x8_t cr_const0 = vdupq_n_s16((short)(1.40200f * 4096.0f + 0.5f)); + int16x8_t cr_const1 = vdupq_n_s16(-(short)(0.71414f * 4096.0f + 0.5f)); + int16x8_t cb_const0 = vdupq_n_s16(-(short)(0.34414f * 4096.0f + 0.5f)); + int16x8_t cb_const1 = vdupq_n_s16((short)(1.77200f * 4096.0f + 0.5f)); + + for (; i + 7 < count; i += 8) { + // load + uint8x8_t y_bytes = vld1_u8(y + i); + uint8x8_t cr_bytes = vld1_u8(pcr + i); + uint8x8_t cb_bytes = vld1_u8(pcb + i); + int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); + int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); + + // expand to s16 + int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); + int16x8_t crw = vshll_n_s8(cr_biased, 7); + int16x8_t cbw = vshll_n_s8(cb_biased, 7); + + // color transform + int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); + int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); + int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); + int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); + int16x8_t rws = vaddq_s16(yws, cr0); + int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); + int16x8_t bws = vaddq_s16(yws, cb1); + + // undo scaling, round, convert to byte + uint8x8x4_t o; + o.val[0] = vqrshrun_n_s16(rws, 4); + o.val[1] = vqrshrun_n_s16(gws, 4); + o.val[2] = vqrshrun_n_s16(bws, 4); + o.val[3] = vdup_n_u8(255); + + // store, interleaving r/g/b/a + vst4_u8(out, o); + out += 8 * 4; + } + } #endif - for (; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* stbi__float2fixed(1.40200f); - g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* stbi__float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } + for (; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1 << 19); // rounding + int r, g, b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr * stbi__float2fixed(1.40200f); + g = y_fixed + cr * -stbi__float2fixed(0.71414f) + + ((cb * -stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb * stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned)r > 255) { + if (r < 0) + r = 0; + else + r = 255; + } + if ((unsigned)g > 255) { + if (g < 0) + g = 0; + else + g = 255; + } + if ((unsigned)b > 255) { + if (b < 0) + b = 0; + else + b = 255; + } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } } #endif // set up the kernels -static void stbi__setup_jpeg(stbi__jpeg *j) -{ - j->idct_block_kernel = stbi__idct_block; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; +static void stbi__setup_jpeg(stbi__jpeg *j) { + j->idct_block_kernel = stbi__idct_block; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; #ifdef STBI_SSE2 - if (stbi__sse2_available()) { - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; - } + if (stbi__sse2_available()) { + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } #endif #ifdef STBI_NEON - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } // clean up the temporary component buffers -static void stbi__cleanup_jpeg(stbi__jpeg *j) -{ - stbi__free_jpeg_components(j, j->s->img_n, 0); +static void stbi__cleanup_jpeg(stbi__jpeg *j) { + stbi__free_jpeg_components(j, j->s->img_n, 0); } -typedef struct -{ - resample_row_func resample; - stbi_uc *line0,*line1; - int hs,vs; // expansion factor in each axis - int w_lores; // horizontal pixels pre-expansion - int ystep; // how far through vertical expansion we are - int ypos; // which pre-expansion row we're on +typedef struct { + resample_row_func resample; + stbi_uc *line0, *line1; + int hs, vs; // expansion factor in each axis + int w_lores; // horizontal pixels pre-expansion + int ystep; // how far through vertical expansion we are + int ypos; // which pre-expansion row we're on } stbi__resample; // fast 0..255 * 0..255 => 0..255 rounded multiplication -static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) -{ - unsigned int t = x*y + 128; - return (stbi_uc) ((t + (t >>8)) >> 8); -} - -static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) -{ - int n, decode_n, is_rgb; - z->s->img_n = 0; // make stbi__cleanup_jpeg safe - - // validate req_comp - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - - // load a jpeg image from whichever source, but leave in YCbCr format - if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } - - // determine actual number of components to generate - n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; - - is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); - - if (z->s->img_n == 3 && n < 3 && !is_rgb) - decode_n = 1; - else - decode_n = z->s->img_n; - - // resample and color-convert - { - int k; - unsigned int i,j; - stbi_uc *output; - stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; - - stbi__resample res_comp[4]; - - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - - // allocate line buffer big enough for upsampling off the edges - // with upsample factor of 4 - z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); - if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - r->hs = z->img_h_max / z->img_comp[k].h; - r->vs = z->img_v_max / z->img_comp[k].v; - r->ystep = r->vs >> 1; - r->w_lores = (z->s->img_x + r->hs-1) / r->hs; - r->ypos = 0; - r->line0 = r->line1 = z->img_comp[k].data; - - if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; - else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; - else r->resample = stbi__resample_row_generic; +static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) { + unsigned int t = x * y + 128; + return (stbi_uc)((t + (t >> 8)) >> 8); +} + +static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, + int *comp, int req_comp) { + int n, decode_n, is_rgb; + z->s->img_n = 0; // make stbi__cleanup_jpeg safe + + // validate req_comp + if (req_comp < 0 || req_comp > 4) + return stbi__errpuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source, but leave in YCbCr format + if (!stbi__decode_jpeg_image(z)) { + stbi__cleanup_jpeg(z); + return NULL; + } + + // determine actual number of components to generate + n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; + + is_rgb = z->s->img_n == 3 && + (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); + + if (z->s->img_n == 3 && n < 3 && !is_rgb) + decode_n = 1; + else + decode_n = z->s->img_n; + + // resample and color-convert + { + int k; + unsigned int i, j; + stbi_uc *output; + stbi_uc *coutput[4] = {NULL, NULL, NULL, NULL}; + + stbi__resample res_comp[4]; + + for (k = 0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + + // allocate line buffer big enough for upsampling off the edges + // with upsample factor of 4 + z->img_comp[k].linebuf = (stbi_uc *)stbi__malloc(z->s->img_x + 3); + if (!z->img_comp[k].linebuf) { + stbi__cleanup_jpeg(z); + return stbi__errpuc("outofmem", "Out of memory"); } - // can't error after this so, this is safe - output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); - if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - // now go ahead and resample - for (j=0; j < z->s->img_y; ++j) { - stbi_uc *out = output + n * z->s->img_x * j; - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - int y_bot = r->ystep >= (r->vs >> 1); - coutput[k] = r->resample(z->img_comp[k].linebuf, - y_bot ? r->line1 : r->line0, - y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); - if (++r->ystep >= r->vs) { - r->ystep = 0; - r->line0 = r->line1; - if (++r->ypos < z->img_comp[k].y) - r->line1 += z->img_comp[k].w2; + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs - 1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + + if (r->hs == 1 && r->vs == 1) + r->resample = resample_row_1; + else if (r->hs == 1 && r->vs == 2) + r->resample = stbi__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) + r->resample = stbi__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) + r->resample = z->resample_row_hv_2_kernel; + else + r->resample = stbi__resample_row_generic; + } + + // can't error after this so, this is safe + output = (stbi_uc *)stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); + if (!output) { + stbi__cleanup_jpeg(z); + return stbi__errpuc("outofmem", "Out of memory"); + } + + // now go ahead and resample + for (j = 0; j < z->s->img_y; ++j) { + stbi_uc *out = output + n * z->s->img_x * j; + for (k = 0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + int y_bot = r->ystep >= (r->vs >> 1); + coutput[k] = + r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, r->w_lores, r->hs); + if (++r->ystep >= r->vs) { + r->ystep = 0; + r->line0 = r->line1; + if (++r->ypos < z->img_comp[k].y) + r->line1 += z->img_comp[k].w2; + } + } + if (n >= 3) { + stbi_uc *y = coutput[0]; + if (z->s->img_n == 3) { + if (is_rgb) { + for (i = 0; i < z->s->img_x; ++i) { + out[0] = y[i]; + out[1] = coutput[1][i]; + out[2] = coutput[2][i]; + out[3] = 255; + out += n; + } + } else { + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, + n); + } + } else if (z->s->img_n == 4) { + if (z->app14_color_transform == 0) { // CMYK + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(coutput[0][i], m); + out[1] = stbi__blinn_8x8(coutput[1][i], m); + out[2] = stbi__blinn_8x8(coutput[2][i], m); + out[3] = 255; + out += n; + } + } else if (z->app14_color_transform == 2) { // YCCK + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, + n); + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(255 - out[0], m); + out[1] = stbi__blinn_8x8(255 - out[1], m); + out[2] = stbi__blinn_8x8(255 - out[2], m); + out += n; + } + } else { // YCbCr + alpha? Ignore the fourth channel for now + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, + n); + } + } else + for (i = 0; i < z->s->img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n==3 + out += n; + } + } else { + if (is_rgb) { + if (n == 1) + for (i = 0; i < z->s->img_x; ++i) + *out++ = + stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + else { + for (i = 0; i < z->s->img_x; ++i, out += 2) { + out[0] = + stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + out[1] = 255; } - } - if (n >= 3) { - stbi_uc *y = coutput[0]; - if (z->s->img_n == 3) { - if (is_rgb) { - for (i=0; i < z->s->img_x; ++i) { - out[0] = y[i]; - out[1] = coutput[1][i]; - out[2] = coutput[2][i]; - out[3] = 255; - out += n; - } - } else { - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } - } else if (z->s->img_n == 4) { - if (z->app14_color_transform == 0) { // CMYK - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - out[0] = stbi__blinn_8x8(coutput[0][i], m); - out[1] = stbi__blinn_8x8(coutput[1][i], m); - out[2] = stbi__blinn_8x8(coutput[2][i], m); - out[3] = 255; - out += n; - } - } else if (z->app14_color_transform == 2) { // YCCK - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - out[0] = stbi__blinn_8x8(255 - out[0], m); - out[1] = stbi__blinn_8x8(255 - out[1], m); - out[2] = stbi__blinn_8x8(255 - out[2], m); - out += n; - } - } else { // YCbCr + alpha? Ignore the fourth channel for now - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } - } else - for (i=0; i < z->s->img_x; ++i) { - out[0] = out[1] = out[2] = y[i]; - out[3] = 255; // not used if n==3 - out += n; - } - } else { - if (is_rgb) { - if (n == 1) - for (i=0; i < z->s->img_x; ++i) - *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); - else { - for (i=0; i < z->s->img_x; ++i, out += 2) { - out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); - out[1] = 255; - } - } - } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); - stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); - stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); - out[0] = stbi__compute_y(r, g, b); - out[1] = 255; - out += n; - } - } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { - for (i=0; i < z->s->img_x; ++i) { - out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); - out[1] = 255; - out += n; - } - } else { - stbi_uc *y = coutput[0]; - if (n == 1) - for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; - else - for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); + stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); + stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); + out[0] = stbi__compute_y(r, g, b); + out[1] = 255; + out += n; + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { + for (i = 0; i < z->s->img_x; ++i) { + out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); + out[1] = 255; + out += n; + } + } else { + stbi_uc *y = coutput[0]; + if (n == 1) + for (i = 0; i < z->s->img_x; ++i) + out[i] = y[i]; + else + for (i = 0; i < z->s->img_x; ++i) { + *out++ = y[i]; + *out++ = 255; } - } + } } - stbi__cleanup_jpeg(z); - *out_x = z->s->img_x; - *out_y = z->s->img_y; - if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output - return output; - } -} - -static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - unsigned char* result; - stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); - STBI_NOTUSED(ri); - j->s = s; - stbi__setup_jpeg(j); - result = load_jpeg_image(j, x,y,comp,req_comp); - STBI_FREE(j); - return result; -} - -static int stbi__jpeg_test(stbi__context *s) -{ - int r; - stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); - j->s = s; - stbi__setup_jpeg(j); - r = stbi__decode_jpeg_header(j, STBI__SCAN_type); - stbi__rewind(s); - STBI_FREE(j); - return r; -} - -static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) -{ - if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { - stbi__rewind( j->s ); - return 0; - } - if (x) *x = j->s->img_x; - if (y) *y = j->s->img_y; - if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; - return 1; -} - -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) -{ - int result; - stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); - j->s = s; - result = stbi__jpeg_info_raw(j, x, y, comp); - STBI_FREE(j); - return result; + } + stbi__cleanup_jpeg(z); + *out_x = z->s->img_x; + *out_y = z->s->img_y; + if (comp) + *comp = + z->s->img_n >= 3 ? 3 : 1; // report original components, not output + return output; + } +} + +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri) { + unsigned char *result; + stbi__jpeg *j = (stbi__jpeg *)stbi__malloc(sizeof(stbi__jpeg)); + STBI_NOTUSED(ri); + j->s = s; + stbi__setup_jpeg(j); + result = load_jpeg_image(j, x, y, comp, req_comp); + STBI_FREE(j); + return result; +} + +static int stbi__jpeg_test(stbi__context *s) { + int r; + stbi__jpeg *j = (stbi__jpeg *)stbi__malloc(sizeof(stbi__jpeg)); + j->s = s; + stbi__setup_jpeg(j); + r = stbi__decode_jpeg_header(j, STBI__SCAN_type); + stbi__rewind(s); + STBI_FREE(j); + return r; +} + +static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { + if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { + stbi__rewind(j->s); + return 0; + } + if (x) + *x = j->s->img_x; + if (y) + *y = j->s->img_y; + if (comp) + *comp = j->s->img_n >= 3 ? 3 : 1; + return 1; +} + +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { + int result; + stbi__jpeg *j = (stbi__jpeg *)(stbi__malloc(sizeof(stbi__jpeg))); + j->s = s; + result = stbi__jpeg_info_raw(j, x, y, comp); + STBI_FREE(j); + return result; } #endif @@ -3853,83 +4233,81 @@ static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) #ifndef STBI_NO_ZLIB // fast-way is faster to check than jpeg huffman, but slow way is slower -#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables -#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) +#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables +#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) -typedef struct -{ - stbi__uint16 fast[1 << STBI__ZFAST_BITS]; - stbi__uint16 firstcode[16]; - int maxcode[17]; - stbi__uint16 firstsymbol[16]; - stbi_uc size[288]; - stbi__uint16 value[288]; +typedef struct { + stbi__uint16 fast[1 << STBI__ZFAST_BITS]; + stbi__uint16 firstcode[16]; + int maxcode[17]; + stbi__uint16 firstsymbol[16]; + stbi_uc size[288]; + stbi__uint16 value[288]; } stbi__zhuffman; -stbi_inline static int stbi__bitreverse16(int n) -{ - n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); - n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); - n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); - n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); +stbi_inline static int stbi__bitreverse16(int n) { + n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); + n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); + n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); + n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } -stbi_inline static int stbi__bit_reverse(int v, int bits) -{ - STBI_ASSERT(bits <= 16); - // to bit reverse n bits, reverse 16 and shift - // e.g. 11 bits, bit reverse and shift away 5 - return stbi__bitreverse16(v) >> (16-bits); -} - -static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) -{ - int i,k=0; - int code, next_code[16], sizes[17]; - - // DEFLATE spec for generating codes - memset(sizes, 0, sizeof(sizes)); - memset(z->fast, 0, sizeof(z->fast)); - for (i=0; i < num; ++i) - ++sizes[sizelist[i]]; - sizes[0] = 0; - for (i=1; i < 16; ++i) - if (sizes[i] > (1 << i)) - return stbi__err("bad sizes", "Corrupt PNG"); - code = 0; - for (i=1; i < 16; ++i) { - next_code[i] = code; - z->firstcode[i] = (stbi__uint16) code; - z->firstsymbol[i] = (stbi__uint16) k; - code = (code + sizes[i]); - if (sizes[i]) - if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); - z->maxcode[i] = code << (16-i); // preshift for inner loop - code <<= 1; - k += sizes[i]; - } - z->maxcode[16] = 0x10000; // sentinel - for (i=0; i < num; ++i) { - int s = sizelist[i]; - if (s) { - int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; - stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); - z->size [c] = (stbi_uc ) s; - z->value[c] = (stbi__uint16) i; - if (s <= STBI__ZFAST_BITS) { - int j = stbi__bit_reverse(next_code[s],s); - while (j < (1 << STBI__ZFAST_BITS)) { - z->fast[j] = fastv; - j += (1 << s); - } - } - ++next_code[s]; +stbi_inline static int stbi__bit_reverse(int v, int bits) { + STBI_ASSERT(bits <= 16); + // to bit reverse n bits, reverse 16 and shift + // e.g. 11 bits, bit reverse and shift away 5 + return stbi__bitreverse16(v) >> (16 - bits); +} + +static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, + int num) { + int i, k = 0; + int code, next_code[16], sizes[17]; + + // DEFLATE spec for generating codes + memset(sizes, 0, sizeof(sizes)); + memset(z->fast, 0, sizeof(z->fast)); + for (i = 0; i < num; ++i) + ++sizes[sizelist[i]]; + sizes[0] = 0; + for (i = 1; i < 16; ++i) + if (sizes[i] > (1 << i)) + return stbi__err("bad sizes", "Corrupt PNG"); + code = 0; + for (i = 1; i < 16; ++i) { + next_code[i] = code; + z->firstcode[i] = (stbi__uint16)code; + z->firstsymbol[i] = (stbi__uint16)k; + code = (code + sizes[i]); + if (sizes[i]) + if (code - 1 >= (1 << i)) + return stbi__err("bad codelengths", "Corrupt PNG"); + z->maxcode[i] = code << (16 - i); // preshift for inner loop + code <<= 1; + k += sizes[i]; + } + z->maxcode[16] = 0x10000; // sentinel + for (i = 0; i < num; ++i) { + int s = sizelist[i]; + if (s) { + int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; + stbi__uint16 fastv = (stbi__uint16)((s << 9) | i); + z->size[c] = (stbi_uc)s; + z->value[c] = (stbi__uint16)i; + if (s <= STBI__ZFAST_BITS) { + int j = stbi__bit_reverse(next_code[s], s); + while (j < (1 << STBI__ZFAST_BITS)) { + z->fast[j] = fastv; + j += (1 << s); + } } - } - return 1; + ++next_code[s]; + } + } + return 1; } // zlib-from-memory implementation for PNG reading @@ -3938,259 +4316,292 @@ static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int // we require PNG read all the IDATs and combine them into a single // memory buffer -typedef struct -{ - stbi_uc *zbuffer, *zbuffer_end; - int num_bits; - stbi__uint32 code_buffer; +typedef struct { + stbi_uc *zbuffer, *zbuffer_end; + int num_bits; + stbi__uint32 code_buffer; - char *zout; - char *zout_start; - char *zout_end; - int z_expandable; + char *zout; + char *zout_start; + char *zout_end; + int z_expandable; - stbi__zhuffman z_length, z_distance; + stbi__zhuffman z_length, z_distance; } stbi__zbuf; -stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) -{ - if (z->zbuffer >= z->zbuffer_end) return 0; - return *z->zbuffer++; -} - -static void stbi__fill_bits(stbi__zbuf *z) -{ - do { - STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); - z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; - z->num_bits += 8; - } while (z->num_bits <= 24); -} - -stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) -{ - unsigned int k; - if (z->num_bits < n) stbi__fill_bits(z); - k = z->code_buffer & ((1 << n) - 1); - z->code_buffer >>= n; - z->num_bits -= n; - return k; -} - -static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s,k; - // not resolved by fast table, so compute it the slow way - // use jpeg approach, which requires MSbits at top - k = stbi__bit_reverse(a->code_buffer, 16); - for (s=STBI__ZFAST_BITS+1; ; ++s) - if (k < z->maxcode[s]) - break; - if (s == 16) return -1; // invalid code! - // code size is s, so: - b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; - STBI_ASSERT(z->size[b] == s); - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; -} - -stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s; - if (a->num_bits < 16) stbi__fill_bits(a); - b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; - if (b) { - s = b >> 9; - a->code_buffer >>= s; - a->num_bits -= s; - return b & 511; - } - return stbi__zhuffman_decode_slowpath(a, z); -} - -static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes -{ - char *q; - int cur, limit, old_limit; - z->zout = zout; - if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); - cur = (int) (z->zout - z->zout_start); - limit = old_limit = (int) (z->zout_end - z->zout_start); - while (cur + n > limit) - limit *= 2; - q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); - STBI_NOTUSED(old_limit); - if (q == NULL) return stbi__err("outofmem", "Out of memory"); - z->zout_start = q; - z->zout = q + cur; - z->zout_end = q + limit; - return 1; +stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { + if (z->zbuffer >= z->zbuffer_end) + return 0; + return *z->zbuffer++; +} + +static void stbi__fill_bits(stbi__zbuf *z) { + do { + STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); + z->code_buffer |= (unsigned int)stbi__zget8(z) << z->num_bits; + z->num_bits += 8; + } while (z->num_bits <= 24); +} + +stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { + unsigned int k; + if (z->num_bits < n) + stbi__fill_bits(z); + k = z->code_buffer & ((1 << n) - 1); + z->code_buffer >>= n; + z->num_bits -= n; + return k; +} + +static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { + int b, s, k; + // not resolved by fast table, so compute it the slow way + // use jpeg approach, which requires MSbits at top + k = stbi__bit_reverse(a->code_buffer, 16); + for (s = STBI__ZFAST_BITS + 1;; ++s) + if (k < z->maxcode[s]) + break; + if (s == 16) + return -1; // invalid code! + // code size is s, so: + b = (k >> (16 - s)) - z->firstcode[s] + z->firstsymbol[s]; + STBI_ASSERT(z->size[b] == s); + a->code_buffer >>= s; + a->num_bits -= s; + return z->value[b]; +} + +stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { + int b, s; + if (a->num_bits < 16) + stbi__fill_bits(a); + b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; + if (b) { + s = b >> 9; + a->code_buffer >>= s; + a->num_bits -= s; + return b & 511; + } + return stbi__zhuffman_decode_slowpath(a, z); +} + +static int stbi__zexpand(stbi__zbuf *z, char *zout, + int n) // need to make room for n bytes +{ + char *q; + int cur, limit, old_limit; + z->zout = zout; + if (!z->z_expandable) + return stbi__err("output buffer limit", "Corrupt PNG"); + cur = (int)(z->zout - z->zout_start); + limit = old_limit = (int)(z->zout_end - z->zout_start); + while (cur + n > limit) + limit *= 2; + q = (char *)STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); + STBI_NOTUSED(old_limit); + if (q == NULL) + return stbi__err("outofmem", "Out of memory"); + z->zout_start = q; + z->zout = q + cur; + z->zout_end = q + limit; + return 1; } static const int stbi__zlength_base[31] = { - 3,4,5,6,7,8,9,10,11,13, - 15,17,19,23,27,31,35,43,51,59, - 67,83,99,115,131,163,195,227,258,0,0 }; - -static const int stbi__zlength_extra[31]= -{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; - -static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, -257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; - -static const int stbi__zdist_extra[32] = -{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -static int stbi__parse_huffman_block(stbi__zbuf *a) -{ - char *zout = a->zout; - for(;;) { - int z = stbi__zhuffman_decode(a, &a->z_length); - if (z < 256) { - if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes - if (zout >= a->zout_end) { - if (!stbi__zexpand(a, zout, 1)) return 0; - zout = a->zout; - } - *zout++ = (char) z; + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + +static const int stbi__zlength_extra[31] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, + 4, 4, 5, 5, 5, 5, 0, 0, 0}; + +static const int stbi__zdist_base[32] = { + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, + 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, + 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; + +static const int stbi__zdist_extra[32] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, + 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; + +static int stbi__parse_huffman_block(stbi__zbuf *a) { + char *zout = a->zout; + for (;;) { + int z = stbi__zhuffman_decode(a, &a->z_length); + if (z < 256) { + if (z < 0) + return stbi__err("bad huffman code", + "Corrupt PNG"); // error in huffman codes + if (zout >= a->zout_end) { + if (!stbi__zexpand(a, zout, 1)) + return 0; + zout = a->zout; + } + *zout++ = (char)z; + } else { + stbi_uc *p; + int len, dist; + if (z == 256) { + a->zout = zout; + return 1; + } + z -= 257; + len = stbi__zlength_base[z]; + if (stbi__zlength_extra[z]) + len += stbi__zreceive(a, stbi__zlength_extra[z]); + z = stbi__zhuffman_decode(a, &a->z_distance); + if (z < 0) + return stbi__err("bad huffman code", "Corrupt PNG"); + dist = stbi__zdist_base[z]; + if (stbi__zdist_extra[z]) + dist += stbi__zreceive(a, stbi__zdist_extra[z]); + if (zout - a->zout_start < dist) + return stbi__err("bad dist", "Corrupt PNG"); + if (zout + len > a->zout_end) { + if (!stbi__zexpand(a, zout, len)) + return 0; + zout = a->zout; + } + p = (stbi_uc *)(zout - dist); + if (dist == 1) { // run of one byte; common in images. + stbi_uc v = *p; + if (len) { + do + *zout++ = v; + while (--len); + } } else { - stbi_uc *p; - int len,dist; - if (z == 256) { - a->zout = zout; - return 1; - } - z -= 257; - len = stbi__zlength_base[z]; - if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); - z = stbi__zhuffman_decode(a, &a->z_distance); - if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); - dist = stbi__zdist_base[z]; - if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); - if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); - if (zout + len > a->zout_end) { - if (!stbi__zexpand(a, zout, len)) return 0; - zout = a->zout; - } - p = (stbi_uc *) (zout - dist); - if (dist == 1) { // run of one byte; common in images. - stbi_uc v = *p; - if (len) { do *zout++ = v; while (--len); } - } else { - if (len) { do *zout++ = *p++; while (--len); } - } + if (len) { + do + *zout++ = *p++; + while (--len); + } } - } -} - -static int stbi__compute_huffman_codes(stbi__zbuf *a) -{ - static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; - stbi__zhuffman z_codelength; - stbi_uc lencodes[286+32+137];//padding for maximum single op - stbi_uc codelength_sizes[19]; - int i,n; - - int hlit = stbi__zreceive(a,5) + 257; - int hdist = stbi__zreceive(a,5) + 1; - int hclen = stbi__zreceive(a,4) + 4; - int ntot = hlit + hdist; - - memset(codelength_sizes, 0, sizeof(codelength_sizes)); - for (i=0; i < hclen; ++i) { - int s = stbi__zreceive(a,3); - codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; - } - if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; - - n = 0; - while (n < ntot) { - int c = stbi__zhuffman_decode(a, &z_codelength); - if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); - if (c < 16) - lencodes[n++] = (stbi_uc) c; + } + } +} + +static int stbi__compute_huffman_codes(stbi__zbuf *a) { + static const stbi_uc length_dezigzag[19] = { + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + stbi__zhuffman z_codelength; + stbi_uc lencodes[286 + 32 + 137]; // padding for maximum single op + stbi_uc codelength_sizes[19]; + int i, n; + + int hlit = stbi__zreceive(a, 5) + 257; + int hdist = stbi__zreceive(a, 5) + 1; + int hclen = stbi__zreceive(a, 4) + 4; + int ntot = hlit + hdist; + + memset(codelength_sizes, 0, sizeof(codelength_sizes)); + for (i = 0; i < hclen; ++i) { + int s = stbi__zreceive(a, 3); + codelength_sizes[length_dezigzag[i]] = (stbi_uc)s; + } + if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) + return 0; + + n = 0; + while (n < ntot) { + int c = stbi__zhuffman_decode(a, &z_codelength); + if (c < 0 || c >= 19) + return stbi__err("bad codelengths", "Corrupt PNG"); + if (c < 16) + lencodes[n++] = (stbi_uc)c; + else { + stbi_uc fill = 0; + if (c == 16) { + c = stbi__zreceive(a, 2) + 3; + if (n == 0) + return stbi__err("bad codelengths", "Corrupt PNG"); + fill = lencodes[n - 1]; + } else if (c == 17) + c = stbi__zreceive(a, 3) + 3; else { - stbi_uc fill = 0; - if (c == 16) { - c = stbi__zreceive(a,2)+3; - if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); - fill = lencodes[n-1]; - } else if (c == 17) - c = stbi__zreceive(a,3)+3; - else { - STBI_ASSERT(c == 18); - c = stbi__zreceive(a,7)+11; - } - if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); - memset(lencodes+n, fill, c); - n += c; + STBI_ASSERT(c == 18); + c = stbi__zreceive(a, 7) + 11; } - } - if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); - if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; - return 1; -} - -static int stbi__parse_uncompressed_block(stbi__zbuf *a) -{ - stbi_uc header[4]; - int len,nlen,k; - if (a->num_bits & 7) - stbi__zreceive(a, a->num_bits & 7); // discard - // drain the bit-packed data into header - k = 0; - while (a->num_bits > 0) { - header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check - a->code_buffer >>= 8; - a->num_bits -= 8; - } - STBI_ASSERT(a->num_bits == 0); - // now fill header the normal way - while (k < 4) - header[k++] = stbi__zget8(a); - len = header[1] * 256 + header[0]; - nlen = header[3] * 256 + header[2]; - if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); - if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); - if (a->zout + len > a->zout_end) - if (!stbi__zexpand(a, a->zout, len)) return 0; - memcpy(a->zout, a->zbuffer, len); - a->zbuffer += len; - a->zout += len; - return 1; -} - -static int stbi__parse_zlib_header(stbi__zbuf *a) -{ - int cmf = stbi__zget8(a); - int cm = cmf & 15; - /* int cinfo = cmf >> 4; */ - int flg = stbi__zget8(a); - if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec - if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png - if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png - // window = 1 << (8 + cinfo)... but who cares, we fully buffer output - return 1; -} - -static const stbi_uc stbi__zdefault_length[288] = -{ - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 -}; -static const stbi_uc stbi__zdefault_distance[32] = -{ - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 -}; + if (ntot - n < c) + return stbi__err("bad codelengths", "Corrupt PNG"); + memset(lencodes + n, fill, c); + n += c; + } + } + if (n != ntot) + return stbi__err("bad codelengths", "Corrupt PNG"); + if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) + return 0; + if (!stbi__zbuild_huffman(&a->z_distance, lencodes + hlit, hdist)) + return 0; + return 1; +} + +static int stbi__parse_uncompressed_block(stbi__zbuf *a) { + stbi_uc header[4]; + int len, nlen, k; + if (a->num_bits & 7) + stbi__zreceive(a, a->num_bits & 7); // discard + // drain the bit-packed data into header + k = 0; + while (a->num_bits > 0) { + header[k++] = + (stbi_uc)(a->code_buffer & 255); // suppress MSVC run-time check + a->code_buffer >>= 8; + a->num_bits -= 8; + } + STBI_ASSERT(a->num_bits == 0); + // now fill header the normal way + while (k < 4) + header[k++] = stbi__zget8(a); + len = header[1] * 256 + header[0]; + nlen = header[3] * 256 + header[2]; + if (nlen != (len ^ 0xffff)) + return stbi__err("zlib corrupt", "Corrupt PNG"); + if (a->zbuffer + len > a->zbuffer_end) + return stbi__err("read past buffer", "Corrupt PNG"); + if (a->zout + len > a->zout_end) + if (!stbi__zexpand(a, a->zout, len)) + return 0; + memcpy(a->zout, a->zbuffer, len); + a->zbuffer += len; + a->zout += len; + return 1; +} + +static int stbi__parse_zlib_header(stbi__zbuf *a) { + int cmf = stbi__zget8(a); + int cm = cmf & 15; + /* int cinfo = cmf >> 4; */ + int flg = stbi__zget8(a); + if ((cmf * 256 + flg) % 31 != 0) + return stbi__err("bad zlib header", "Corrupt PNG"); // zlib spec + if (flg & 32) + return stbi__err("no preset dict", + "Corrupt PNG"); // preset dictionary not allowed in png + if (cm != 8) + return stbi__err("bad compression", + "Corrupt PNG"); // DEFLATE required for png + // window = 1 << (8 + cinfo)... but who cares, we fully buffer output + return 1; +} + +static const stbi_uc stbi__zdefault_length[288] = { + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8}; +static const stbi_uc stbi__zdefault_distance[32] = { + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; /* Init algorithm: { @@ -4204,117 +4615,131 @@ Init algorithm: } */ -static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) -{ - int final, type; - if (parse_header) - if (!stbi__parse_zlib_header(a)) return 0; - a->num_bits = 0; - a->code_buffer = 0; - do { - final = stbi__zreceive(a,1); - type = stbi__zreceive(a,2); - if (type == 0) { - if (!stbi__parse_uncompressed_block(a)) return 0; - } else if (type == 3) { - return 0; +static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { + int final, type; + if (parse_header) + if (!stbi__parse_zlib_header(a)) + return 0; + a->num_bits = 0; + a->code_buffer = 0; + do { + final = stbi__zreceive(a, 1); + type = stbi__zreceive(a, 2); + if (type == 0) { + if (!stbi__parse_uncompressed_block(a)) + return 0; + } else if (type == 3) { + return 0; + } else { + if (type == 1) { + // use fixed code lengths + if (!stbi__zbuild_huffman(&a->z_length, stbi__zdefault_length, 288)) + return 0; + if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) + return 0; } else { - if (type == 1) { - // use fixed code lengths - if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; - } else { - if (!stbi__compute_huffman_codes(a)) return 0; - } - if (!stbi__parse_huffman_block(a)) return 0; + if (!stbi__compute_huffman_codes(a)) + return 0; } - } while (!final); - return 1; -} - -static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) -{ - a->zout_start = obuf; - a->zout = obuf; - a->zout_end = obuf + olen; - a->z_expandable = exp; - - return stbi__parse_zlib(a, parse_header); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) -{ - return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(16384); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer+len; - if (stbi__do_zlib(&a, p, 16384, 1, 0)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) - return (int) (a.zout - a.zout_start); - else - return -1; + if (!stbi__parse_huffman_block(a)) + return 0; + } + } while (!final); + return 1; +} + +static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, + int parse_header) { + a->zout_start = obuf; + a->zout = obuf; + a->zout_end = obuf + olen; + a->z_expandable = exp; + + return stbi__parse_zlib(a, parse_header); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, + int initial_size, int *outlen) { + stbi__zbuf a; + char *p = (char *)stbi__malloc(initial_size); + if (p == NULL) + return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { + if (outlen) + *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, + int *outlen) { + return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, + int len, + int initial_size, + int *outlen, + int parse_header) { + stbi__zbuf a; + char *p = (char *)stbi__malloc(initial_size); + if (p == NULL) + return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { + if (outlen) + *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, + char const *ibuffer, int ilen) { + stbi__zbuf a; + a.zbuffer = (stbi_uc *)ibuffer; + a.zbuffer_end = (stbi_uc *)ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) + return (int)(a.zout - a.zout_start); + else + return -1; +} + +STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, + int *outlen) { + stbi__zbuf a; + char *p = (char *)stbi__malloc(16384); + if (p == NULL) + return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, 16384, 1, 0)) { + if (outlen) + *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, + const char *ibuffer, int ilen) { + stbi__zbuf a; + a.zbuffer = (stbi_uc *)ibuffer; + a.zbuffer_end = (stbi_uc *)ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) + return (int)(a.zout - a.zout_start); + else + return -1; } #endif @@ -4329,1062 +4754,1276 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char // - uses stb_zlib, a PD zlib implementation with fast huffman decoding #ifndef STBI_NO_PNG -typedef struct -{ - stbi__uint32 length; - stbi__uint32 type; +typedef struct { + stbi__uint32 length; + stbi__uint32 type; } stbi__pngchunk; -static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) -{ - stbi__pngchunk c; - c.length = stbi__get32be(s); - c.type = stbi__get32be(s); - return c; +static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { + stbi__pngchunk c; + c.length = stbi__get32be(s); + c.type = stbi__get32be(s); + return c; } -static int stbi__check_png_header(stbi__context *s) -{ - static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; - int i; - for (i=0; i < 8; ++i) - if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); - return 1; +static int stbi__check_png_header(stbi__context *s) { + static const stbi_uc png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + int i; + for (i = 0; i < 8; ++i) + if (stbi__get8(s) != png_sig[i]) + return stbi__err("bad png sig", "Not a PNG"); + return 1; } -typedef struct -{ - stbi__context *s; - stbi_uc *idata, *expanded, *out; - int depth; +typedef struct { + stbi__context *s; + stbi_uc *idata, *expanded, *out; + int depth; } stbi__png; - enum { - STBI__F_none=0, - STBI__F_sub=1, - STBI__F_up=2, - STBI__F_avg=3, - STBI__F_paeth=4, - // synthetic filters used for first scanline to avoid needing a dummy row of 0s - STBI__F_avg_first, - STBI__F_paeth_first + STBI__F_none = 0, + STBI__F_sub = 1, + STBI__F_up = 2, + STBI__F_avg = 3, + STBI__F_paeth = 4, + // synthetic filters used for first scanline to avoid needing a dummy row of + // 0s + STBI__F_avg_first, + STBI__F_paeth_first }; -static stbi_uc first_row_filter[5] = -{ - STBI__F_none, - STBI__F_sub, - STBI__F_none, - STBI__F_avg_first, - STBI__F_paeth_first -}; +static stbi_uc first_row_filter[5] = {STBI__F_none, STBI__F_sub, STBI__F_none, + STBI__F_avg_first, STBI__F_paeth_first}; -static int stbi__paeth(int a, int b, int c) -{ - int p = a + b - c; - int pa = abs(p-a); - int pb = abs(p-b); - int pc = abs(p-c); - if (pa <= pb && pa <= pc) return a; - if (pb <= pc) return b; - return c; +static int stbi__paeth(int a, int b, int c) { + int p = a + b - c; + int pa = abs(p - a); + int pb = abs(p - b); + int pc = abs(p - c); + if (pa <= pb && pa <= pc) + return a; + if (pb <= pc) + return b; + return c; } -static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; +static const stbi_uc stbi__depth_scale_table[9] = {0, 0xff, 0x55, 0, 0x11, + 0, 0, 0, 0x01}; // create the png data from post-deflated data -static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) -{ - int bytes = (depth == 16? 2 : 1); - stbi__context *s = a->s; - stbi__uint32 i,j,stride = x*out_n*bytes; - stbi__uint32 img_len, img_width_bytes; - int k; - int img_n = s->img_n; // copy it into a local for later - - int output_bytes = out_n*bytes; - int filter_bytes = img_n*bytes; - int width = x; - - STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); - a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into - if (!a->out) return stbi__err("outofmem", "Out of memory"); - - if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); - img_width_bytes = (((img_n * x * depth) + 7) >> 3); - img_len = (img_width_bytes + 1) * y; - - // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, - // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), - // so just check for raw_len < img_len always. - if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); - - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *prior; - int filter = *raw++; - - if (filter > 4) - return stbi__err("invalid filter","Corrupt PNG"); - - if (depth < 8) { - STBI_ASSERT(img_width_bytes <= x); - cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place - filter_bytes = 1; - width = img_width_bytes; - } - prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above - - // if first row, use special filter that doesn't sample previous row - if (j == 0) filter = first_row_filter[filter]; - - // handle first byte explicitly - for (k=0; k < filter_bytes; ++k) { - switch (filter) { - case STBI__F_none : cur[k] = raw[k]; break; - case STBI__F_sub : cur[k] = raw[k]; break; - case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; - case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; - case STBI__F_avg_first : cur[k] = raw[k]; break; - case STBI__F_paeth_first: cur[k] = raw[k]; break; - } +static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, + stbi__uint32 raw_len, int out_n, + stbi__uint32 x, stbi__uint32 y, int depth, + int color) { + int bytes = (depth == 16 ? 2 : 1); + stbi__context *s = a->s; + stbi__uint32 i, j, stride = x * out_n * bytes; + stbi__uint32 img_len, img_width_bytes; + int k; + int img_n = s->img_n; // copy it into a local for later + + int output_bytes = out_n * bytes; + int filter_bytes = img_n * bytes; + int width = x; + + STBI_ASSERT(out_n == s->img_n || out_n == s->img_n + 1); + a->out = (stbi_uc *)stbi__malloc_mad3( + x, y, output_bytes, 0); // extra bytes to write off the end into + if (!a->out) + return stbi__err("outofmem", "Out of memory"); + + if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) + return stbi__err("too large", "Corrupt PNG"); + img_width_bytes = (((img_n * x * depth) + 7) >> 3); + img_len = (img_width_bytes + 1) * y; + + // we used to check for exact match between raw_len and img_len on + // non-interlaced PNGs, but issue #276 reported a PNG in the wild that had + // extra data at the end (all zeros), so just check for raw_len < img_len + // always. + if (raw_len < img_len) + return stbi__err("not enough pixels", "Corrupt PNG"); + + for (j = 0; j < y; ++j) { + stbi_uc *cur = a->out + stride * j; + stbi_uc *prior; + int filter = *raw++; + + if (filter > 4) + return stbi__err("invalid filter", "Corrupt PNG"); + + if (depth < 8) { + STBI_ASSERT(img_width_bytes <= x); + cur += + x * out_n - img_width_bytes; // store output to the rightmost img_len + // bytes, so we can decode in place + filter_bytes = 1; + width = img_width_bytes; + } + prior = + cur - + stride; // bugfix: need to compute this after 'cur +=' computation above + + // if first row, use special filter that doesn't sample previous row + if (j == 0) + filter = first_row_filter[filter]; + + // handle first byte explicitly + for (k = 0; k < filter_bytes; ++k) { + switch (filter) { + case STBI__F_none: + cur[k] = raw[k]; + break; + case STBI__F_sub: + cur[k] = raw[k]; + break; + case STBI__F_up: + cur[k] = STBI__BYTECAST(raw[k] + prior[k]); + break; + case STBI__F_avg: + cur[k] = STBI__BYTECAST(raw[k] + (prior[k] >> 1)); + break; + case STBI__F_paeth: + cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0, prior[k], 0)); + break; + case STBI__F_avg_first: + cur[k] = raw[k]; + break; + case STBI__F_paeth_first: + cur[k] = raw[k]; + break; } + } - if (depth == 8) { - if (img_n != out_n) - cur[img_n] = 255; // first pixel - raw += img_n; - cur += out_n; - prior += out_n; - } else if (depth == 16) { - if (img_n != out_n) { - cur[filter_bytes] = 255; // first pixel top byte - cur[filter_bytes+1] = 255; // first pixel bottom byte - } - raw += filter_bytes; - cur += output_bytes; - prior += output_bytes; - } else { - raw += 1; - cur += 1; - prior += 1; + if (depth == 8) { + if (img_n != out_n) + cur[img_n] = 255; // first pixel + raw += img_n; + cur += out_n; + prior += out_n; + } else if (depth == 16) { + if (img_n != out_n) { + cur[filter_bytes] = 255; // first pixel top byte + cur[filter_bytes + 1] = 255; // first pixel bottom byte } + raw += filter_bytes; + cur += output_bytes; + prior += output_bytes; + } else { + raw += 1; + cur += 1; + prior += 1; + } - // this is a little gross, so that we don't switch per-pixel or per-component - if (depth < 8 || img_n == out_n) { - int nk = (width - 1)*filter_bytes; - #define STBI__CASE(f) \ - case f: \ - for (k=0; k < nk; ++k) - switch (filter) { - // "none" filter turns into a memcpy here; make that explicit. - case STBI__F_none: memcpy(cur, raw, nk); break; - STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; - STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; - STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; - STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; - STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; - STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; - } - #undef STBI__CASE - raw += nk; - } else { - STBI_ASSERT(img_n+1 == out_n); - #define STBI__CASE(f) \ - case f: \ - for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ - for (k=0; k < filter_bytes; ++k) - switch (filter) { - STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; - STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; - STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; - STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; - STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; - STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; - STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; - } - #undef STBI__CASE - - // the loop above sets the high byte of the pixels' alpha, but for - // 16 bit png files we also need the low byte set. we'll do that here. - if (depth == 16) { - cur = a->out + stride*j; // start at the beginning of the row again - for (i=0; i < x; ++i,cur+=output_bytes) { - cur[filter_bytes+1] = 255; - } - } + // this is a little gross, so that we don't switch per-pixel or + // per-component + if (depth < 8 || img_n == out_n) { + int nk = (width - 1) * filter_bytes; +#define STBI__CASE(f) \ + case f: \ + for (k = 0; k < nk; ++k) + switch (filter) { + // "none" filter turns into a memcpy here; make that explicit. + case STBI__F_none: + memcpy(cur, raw, nk); + break; + STBI__CASE(STBI__F_sub) { + cur[k] = STBI__BYTECAST(raw[k] + cur[k - filter_bytes]); + } + break; + STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } + break; + STBI__CASE(STBI__F_avg) { + cur[k] = STBI__BYTECAST(raw[k] + + ((prior[k] + cur[k - filter_bytes]) >> 1)); + } + break; + STBI__CASE(STBI__F_paeth) { + cur[k] = STBI__BYTECAST(raw[k] + + stbi__paeth(cur[k - filter_bytes], prior[k], + prior[k - filter_bytes])); + } + break; + STBI__CASE(STBI__F_avg_first) { + cur[k] = STBI__BYTECAST(raw[k] + (cur[k - filter_bytes] >> 1)); + } + break; + STBI__CASE(STBI__F_paeth_first) { + cur[k] = + STBI__BYTECAST(raw[k] + stbi__paeth(cur[k - filter_bytes], 0, 0)); + } + break; } - } - - // we make a separate pass to expand bits to pixels; for performance, - // this could run two scanlines behind the above code, so it won't - // intefere with filtering but will still be in the cache. - if (depth < 8) { - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; - // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit - // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop - stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range - - // note that the final byte might overshoot and write more data than desired. - // we can allocate enough data that this never writes out of memory, but it - // could also overwrite the next scanline. can it overwrite non-empty data - // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. - // so we need to explicitly clamp the final ones - - if (depth == 4) { - for (k=x*img_n; k >= 2; k-=2, ++in) { - *cur++ = scale * ((*in >> 4) ); - *cur++ = scale * ((*in ) & 0x0f); - } - if (k > 0) *cur++ = scale * ((*in >> 4) ); - } else if (depth == 2) { - for (k=x*img_n; k >= 4; k-=4, ++in) { - *cur++ = scale * ((*in >> 6) ); - *cur++ = scale * ((*in >> 4) & 0x03); - *cur++ = scale * ((*in >> 2) & 0x03); - *cur++ = scale * ((*in ) & 0x03); - } - if (k > 0) *cur++ = scale * ((*in >> 6) ); - if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); - if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); - } else if (depth == 1) { - for (k=x*img_n; k >= 8; k-=8, ++in) { - *cur++ = scale * ((*in >> 7) ); - *cur++ = scale * ((*in >> 6) & 0x01); - *cur++ = scale * ((*in >> 5) & 0x01); - *cur++ = scale * ((*in >> 4) & 0x01); - *cur++ = scale * ((*in >> 3) & 0x01); - *cur++ = scale * ((*in >> 2) & 0x01); - *cur++ = scale * ((*in >> 1) & 0x01); - *cur++ = scale * ((*in ) & 0x01); - } - if (k > 0) *cur++ = scale * ((*in >> 7) ); - if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); - if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); - if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); - if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); - if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); - if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); - } - if (img_n != out_n) { - int q; - // insert alpha = 255 - cur = a->out + stride*j; - if (img_n == 1) { - for (q=x-1; q >= 0; --q) { - cur[q*2+1] = 255; - cur[q*2+0] = cur[q]; - } - } else { - STBI_ASSERT(img_n == 3); - for (q=x-1; q >= 0; --q) { - cur[q*4+3] = 255; - cur[q*4+2] = cur[q*3+2]; - cur[q*4+1] = cur[q*3+1]; - cur[q*4+0] = cur[q*3+0]; - } - } - } +#undef STBI__CASE + raw += nk; + } else { + STBI_ASSERT(img_n + 1 == out_n); +#define STBI__CASE(f) \ + case f: \ + for (i = x - 1; i >= 1; --i, cur[filter_bytes] = 255, raw += filter_bytes, \ + cur += output_bytes, prior += output_bytes) \ + for (k = 0; k < filter_bytes; ++k) + switch (filter) { + STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } + break; + STBI__CASE(STBI__F_sub) { + cur[k] = STBI__BYTECAST(raw[k] + cur[k - output_bytes]); + } + break; + STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } + break; + STBI__CASE(STBI__F_avg) { + cur[k] = STBI__BYTECAST(raw[k] + + ((prior[k] + cur[k - output_bytes]) >> 1)); + } + break; + STBI__CASE(STBI__F_paeth) { + cur[k] = STBI__BYTECAST(raw[k] + + stbi__paeth(cur[k - output_bytes], prior[k], + prior[k - output_bytes])); + } + break; + STBI__CASE(STBI__F_avg_first) { + cur[k] = STBI__BYTECAST(raw[k] + (cur[k - output_bytes] >> 1)); + } + break; + STBI__CASE(STBI__F_paeth_first) { + cur[k] = + STBI__BYTECAST(raw[k] + stbi__paeth(cur[k - output_bytes], 0, 0)); + } + break; } - } else if (depth == 16) { - // force the image data from big-endian to platform-native. - // this is done in a separate pass due to the decoding relying - // on the data being untouched, but could probably be done - // per-line during decode if care is taken. - stbi_uc *cur = a->out; - stbi__uint16 *cur16 = (stbi__uint16*)cur; - - for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { - *cur16 = (cur[0] << 8) | cur[1]; +#undef STBI__CASE + + // the loop above sets the high byte of the pixels' alpha, but for + // 16 bit png files we also need the low byte set. we'll do that here. + if (depth == 16) { + cur = a->out + stride * j; // start at the beginning of the row again + for (i = 0; i < x; ++i, cur += output_bytes) { + cur[filter_bytes + 1] = 255; + } } - } + } + } + + // we make a separate pass to expand bits to pixels; for performance, + // this could run two scanlines behind the above code, so it won't + // intefere with filtering but will still be in the cache. + if (depth < 8) { + for (j = 0; j < y; ++j) { + stbi_uc *cur = a->out + stride * j; + stbi_uc *in = a->out + stride * j + x * out_n - img_width_bytes; + // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common + // 8-bit path optimal at minimal cost for 1/2/4-bit png guarante byte + // alignment, if width is not multiple of 8/4/2 we'll decode dummy + // trailing data that will be skipped in the later loop + stbi_uc scale = (color == 0) + ? stbi__depth_scale_table[depth] + : 1; // scale grayscale values to 0..255 range + + // note that the final byte might overshoot and write more data than + // desired. we can allocate enough data that this never writes out of + // memory, but it could also overwrite the next scanline. can it overwrite + // non-empty data on the next scanline? yes, consider 1-pixel-wide + // scanlines with 1-bit-per-pixel. so we need to explicitly clamp the + // final ones + + if (depth == 4) { + for (k = x * img_n; k >= 2; k -= 2, ++in) { + *cur++ = scale * ((*in >> 4)); + *cur++ = scale * ((*in) & 0x0f); + } + if (k > 0) + *cur++ = scale * ((*in >> 4)); + } else if (depth == 2) { + for (k = x * img_n; k >= 4; k -= 4, ++in) { + *cur++ = scale * ((*in >> 6)); + *cur++ = scale * ((*in >> 4) & 0x03); + *cur++ = scale * ((*in >> 2) & 0x03); + *cur++ = scale * ((*in) & 0x03); + } + if (k > 0) + *cur++ = scale * ((*in >> 6)); + if (k > 1) + *cur++ = scale * ((*in >> 4) & 0x03); + if (k > 2) + *cur++ = scale * ((*in >> 2) & 0x03); + } else if (depth == 1) { + for (k = x * img_n; k >= 8; k -= 8, ++in) { + *cur++ = scale * ((*in >> 7)); + *cur++ = scale * ((*in >> 6) & 0x01); + *cur++ = scale * ((*in >> 5) & 0x01); + *cur++ = scale * ((*in >> 4) & 0x01); + *cur++ = scale * ((*in >> 3) & 0x01); + *cur++ = scale * ((*in >> 2) & 0x01); + *cur++ = scale * ((*in >> 1) & 0x01); + *cur++ = scale * ((*in) & 0x01); + } + if (k > 0) + *cur++ = scale * ((*in >> 7)); + if (k > 1) + *cur++ = scale * ((*in >> 6) & 0x01); + if (k > 2) + *cur++ = scale * ((*in >> 5) & 0x01); + if (k > 3) + *cur++ = scale * ((*in >> 4) & 0x01); + if (k > 4) + *cur++ = scale * ((*in >> 3) & 0x01); + if (k > 5) + *cur++ = scale * ((*in >> 2) & 0x01); + if (k > 6) + *cur++ = scale * ((*in >> 1) & 0x01); + } + if (img_n != out_n) { + int q; + // insert alpha = 255 + cur = a->out + stride * j; + if (img_n == 1) { + for (q = x - 1; q >= 0; --q) { + cur[q * 2 + 1] = 255; + cur[q * 2 + 0] = cur[q]; + } + } else { + STBI_ASSERT(img_n == 3); + for (q = x - 1; q >= 0; --q) { + cur[q * 4 + 3] = 255; + cur[q * 4 + 2] = cur[q * 3 + 2]; + cur[q * 4 + 1] = cur[q * 3 + 1]; + cur[q * 4 + 0] = cur[q * 3 + 0]; + } + } + } + } + } else if (depth == 16) { + // force the image data from big-endian to platform-native. + // this is done in a separate pass due to the decoding relying + // on the data being untouched, but could probably be done + // per-line during decode if care is taken. + stbi_uc *cur = a->out; + stbi__uint16 *cur16 = (stbi__uint16 *)cur; + + for (i = 0; i < x * y * out_n; ++i, cur16++, cur += 2) { + *cur16 = (cur[0] << 8) | cur[1]; + } + } + + return 1; +} + +static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, + stbi__uint32 image_data_len, int out_n, + int depth, int color, int interlaced) { + int bytes = (depth == 16 ? 2 : 1); + int out_bytes = out_n * bytes; + stbi_uc *final; + int p; + if (!interlaced) + return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, + a->s->img_x, a->s->img_y, depth, color); + + // de-interlacing + final = (stbi_uc *)stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); + for (p = 0; p < 7; ++p) { + int xorig[] = {0, 4, 0, 2, 0, 1, 0}; + int yorig[] = {0, 0, 4, 0, 2, 0, 1}; + int xspc[] = {8, 8, 4, 4, 2, 2, 1}; + int yspc[] = {8, 8, 8, 4, 4, 2, 2}; + int i, j, x, y; + // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 + x = (a->s->img_x - xorig[p] + xspc[p] - 1) / xspc[p]; + y = (a->s->img_y - yorig[p] + yspc[p] - 1) / yspc[p]; + if (x && y) { + stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; + if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, + y, depth, color)) { + STBI_FREE(final); + return 0; + } + for (j = 0; j < y; ++j) { + for (i = 0; i < x; ++i) { + int out_y = j * yspc[p] + yorig[p]; + int out_x = i * xspc[p] + xorig[p]; + memcpy(final + out_y * a->s->img_x * out_bytes + out_x * out_bytes, + a->out + (j * x + i) * out_bytes, out_bytes); + } + } + STBI_FREE(a->out); + image_data += img_len; + image_data_len -= img_len; + } + } + a->out = final; - return 1; + return 1; } -static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) -{ - int bytes = (depth == 16 ? 2 : 1); - int out_bytes = out_n * bytes; - stbi_uc *final; - int p; - if (!interlaced) - return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); - - // de-interlacing - final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); - for (p=0; p < 7; ++p) { - int xorig[] = { 0,4,0,2,0,1,0 }; - int yorig[] = { 0,0,4,0,2,0,1 }; - int xspc[] = { 8,8,4,4,2,2,1 }; - int yspc[] = { 8,8,8,4,4,2,2 }; - int i,j,x,y; - // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 - x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; - y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; - if (x && y) { - stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; - if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { - STBI_FREE(final); - return 0; - } - for (j=0; j < y; ++j) { - for (i=0; i < x; ++i) { - int out_y = j*yspc[p]+yorig[p]; - int out_x = i*xspc[p]+xorig[p]; - memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, - a->out + (j*x+i)*out_bytes, out_bytes); - } - } - STBI_FREE(a->out); - image_data += img_len; - image_data_len -= img_len; - } - } - a->out = final; +static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; - return 1; -} + // compute color-based transparency, assuming we've + // already got 255 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); -static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - // compute color-based transparency, assuming we've - // already got 255 as the alpha value in the output - STBI_ASSERT(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i=0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 255); - p += 2; - } - } else { - for (i=0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 255); + p += 2; + } + } else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; } -static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi__uint16 *p = (stbi__uint16*) z->out; +static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], + int out_n) { + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi__uint16 *p = (stbi__uint16 *)z->out; - // compute color-based transparency, assuming we've - // already got 65535 as the alpha value in the output - STBI_ASSERT(out_n == 2 || out_n == 4); + // compute color-based transparency, assuming we've + // already got 65535 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); - if (out_n == 2) { - for (i = 0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 65535); - p += 2; - } - } else { - for (i = 0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 65535); + p += 2; + } + } else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; } -static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) -{ - stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; - stbi_uc *p, *temp_out, *orig = a->out; - - p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); - if (p == NULL) return stbi__err("outofmem", "Out of memory"); - - // between here and free(out) below, exitting would leak - temp_out = p; - - if (pal_img_n == 3) { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p += 3; - } - } else { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p[3] = palette[n+3]; - p += 4; - } - } - STBI_FREE(a->out); - a->out = temp_out; +static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, + int pal_img_n) { + stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; + stbi_uc *p, *temp_out, *orig = a->out; + + p = (stbi_uc *)stbi__malloc_mad2(pixel_count, pal_img_n, 0); + if (p == NULL) + return stbi__err("outofmem", "Out of memory"); - STBI_NOTUSED(len); + // between here and free(out) below, exitting would leak + temp_out = p; + + if (pal_img_n == 3) { + for (i = 0; i < pixel_count; ++i) { + int n = orig[i] * 4; + p[0] = palette[n]; + p[1] = palette[n + 1]; + p[2] = palette[n + 2]; + p += 3; + } + } else { + for (i = 0; i < pixel_count; ++i) { + int n = orig[i] * 4; + p[0] = palette[n]; + p[1] = palette[n + 1]; + p[2] = palette[n + 2]; + p[3] = palette[n + 3]; + p += 4; + } + } + STBI_FREE(a->out); + a->out = temp_out; - return 1; + STBI_NOTUSED(len); + + return 1; } static int stbi__unpremultiply_on_load = 0; static int stbi__de_iphone_flag = 0; -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) -{ - stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; +STBIDEF void +stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { + stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; } -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) -{ - stbi__de_iphone_flag = flag_true_if_should_convert; +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { + stbi__de_iphone_flag = flag_true_if_should_convert; } -static void stbi__de_iphone(stbi__png *z) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - if (s->img_out_n == 3) { // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 3; +static void stbi__de_iphone(stbi__png *z) { + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + if (s->img_out_n == 3) { // convert bgr to rgb + for (i = 0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 3; + } + } else { + STBI_ASSERT(s->img_out_n == 4); + if (stbi__unpremultiply_on_load) { + // convert bgr to rgb and unpremultiply + for (i = 0; i < pixel_count; ++i) { + stbi_uc a = p[3]; + stbi_uc t = p[0]; + if (a) { + stbi_uc half = a / 2; + p[0] = (p[2] * 255 + half) / a; + p[1] = (p[1] * 255 + half) / a; + p[2] = (t * 255 + half) / a; + } else { + p[0] = p[2]; + p[2] = t; + } + p += 4; } - } else { - STBI_ASSERT(s->img_out_n == 4); - if (stbi__unpremultiply_on_load) { - // convert bgr to rgb and unpremultiply - for (i=0; i < pixel_count; ++i) { - stbi_uc a = p[3]; - stbi_uc t = p[0]; - if (a) { - stbi_uc half = a / 2; - p[0] = (p[2] * 255 + half) / a; - p[1] = (p[1] * 255 + half) / a; - p[2] = ( t * 255 + half) / a; - } else { - p[0] = p[2]; - p[2] = t; - } - p += 4; - } + } else { + // convert bgr to rgb + for (i = 0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 4; + } + } + } +} + +#define STBI__PNG_TYPE(a, b, c, d) \ + (((unsigned)(a) << 24) + ((unsigned)(b) << 16) + ((unsigned)(c) << 8) + \ + (unsigned)(d)) + +static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { + stbi_uc palette[1024], pal_img_n = 0; + stbi_uc has_trans = 0, tc[3] = {0}; + stbi__uint16 tc16[3]; + stbi__uint32 ioff = 0, idata_limit = 0, i, pal_len = 0; + int first = 1, k, interlace = 0, color = 0, is_iphone = 0; + stbi__context *s = z->s; + + z->expanded = NULL; + z->idata = NULL; + z->out = NULL; + + if (!stbi__check_png_header(s)) + return 0; + + if (scan == STBI__SCAN_type) + return 1; + + for (;;) { + stbi__pngchunk c = stbi__get_chunk_header(s); + switch (c.type) { + case STBI__PNG_TYPE('C', 'g', 'B', 'I'): + is_iphone = 1; + stbi__skip(s, c.length); + break; + case STBI__PNG_TYPE('I', 'H', 'D', 'R'): { + int comp, filter; + if (!first) + return stbi__err("multiple IHDR", "Corrupt PNG"); + first = 0; + if (c.length != 13) + return stbi__err("bad IHDR len", "Corrupt PNG"); + s->img_x = stbi__get32be(s); + if (s->img_x > (1 << 24)) + return stbi__err("too large", "Very large image (corrupt?)"); + s->img_y = stbi__get32be(s); + if (s->img_y > (1 << 24)) + return stbi__err("too large", "Very large image (corrupt?)"); + z->depth = stbi__get8(s); + if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && + z->depth != 16) + return stbi__err("1/2/4/8/16-bit only", + "PNG not supported: 1/2/4/8/16-bit only"); + color = stbi__get8(s); + if (color > 6) + return stbi__err("bad ctype", "Corrupt PNG"); + if (color == 3 && z->depth == 16) + return stbi__err("bad ctype", "Corrupt PNG"); + if (color == 3) + pal_img_n = 3; + else if (color & 1) + return stbi__err("bad ctype", "Corrupt PNG"); + comp = stbi__get8(s); + if (comp) + return stbi__err("bad comp method", "Corrupt PNG"); + filter = stbi__get8(s); + if (filter) + return stbi__err("bad filter method", "Corrupt PNG"); + interlace = stbi__get8(s); + if (interlace > 1) + return stbi__err("bad interlace method", "Corrupt PNG"); + if (!s->img_x || !s->img_y) + return stbi__err("0-pixel image", "Corrupt PNG"); + if (!pal_img_n) { + s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); + if ((1 << 30) / s->img_x / s->img_n < s->img_y) + return stbi__err("too large", "Image too large to decode"); + if (scan == STBI__SCAN_header) + return 1; } else { - // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 4; - } + // if paletted, then pal_n is our final components, and + // img_n is # components to decompress/filter. + s->img_n = 1; + if ((1 << 30) / s->img_x / 4 < s->img_y) + return stbi__err("too large", "Corrupt PNG"); + // if SCAN_header, have to scan to see if we have a tRNS } - } -} - -#define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) + break; + } -static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) -{ - stbi_uc palette[1024], pal_img_n=0; - stbi_uc has_trans=0, tc[3]={0}; - stbi__uint16 tc16[3]; - stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; - int first=1,k,interlace=0, color=0, is_iphone=0; - stbi__context *s = z->s; - - z->expanded = NULL; - z->idata = NULL; - z->out = NULL; - - if (!stbi__check_png_header(s)) return 0; - - if (scan == STBI__SCAN_type) return 1; - - for (;;) { - stbi__pngchunk c = stbi__get_chunk_header(s); - switch (c.type) { - case STBI__PNG_TYPE('C','g','B','I'): - is_iphone = 1; - stbi__skip(s, c.length); - break; - case STBI__PNG_TYPE('I','H','D','R'): { - int comp,filter; - if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); - first = 0; - if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); - s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); - s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); - z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); - color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); - if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); - if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); - comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); - filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); - interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); - if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); - if (!pal_img_n) { - s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); - if (scan == STBI__SCAN_header) return 1; - } else { - // if paletted, then pal_n is our final components, and - // img_n is # components to decompress/filter. - s->img_n = 1; - if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); - // if SCAN_header, have to scan to see if we have a tRNS - } - break; - } - - case STBI__PNG_TYPE('P','L','T','E'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); - pal_len = c.length / 3; - if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); - for (i=0; i < pal_len; ++i) { - palette[i*4+0] = stbi__get8(s); - palette[i*4+1] = stbi__get8(s); - palette[i*4+2] = stbi__get8(s); - palette[i*4+3] = 255; - } - break; - } - - case STBI__PNG_TYPE('t','R','N','S'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); - if (pal_img_n) { - if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } - if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); - if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); - pal_img_n = 4; - for (i=0; i < c.length; ++i) - palette[i*4+3] = stbi__get8(s); - } else { - if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); - if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); - has_trans = 1; - if (z->depth == 16) { - for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is - } else { - for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger - } - } - break; - } - - case STBI__PNG_TYPE('I','D','A','T'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); - if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } - if ((int)(ioff + c.length) < (int)ioff) return 0; - if (ioff + c.length > idata_limit) { - stbi__uint32 idata_limit_old = idata_limit; - stbi_uc *p; - if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; - while (ioff + c.length > idata_limit) - idata_limit *= 2; - STBI_NOTUSED(idata_limit_old); - p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); - z->idata = p; - } - if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); - ioff += c.length; - break; - } - - case STBI__PNG_TYPE('I','E','N','D'): { - stbi__uint32 raw_len, bpl; - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (scan != STBI__SCAN_load) return 1; - if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); - // initial guess for decoded data size to avoid unnecessary reallocs - bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component - raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; - z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); - if (z->expanded == NULL) return 0; // zlib should set error - STBI_FREE(z->idata); z->idata = NULL; - if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) - s->img_out_n = s->img_n+1; - else - s->img_out_n = s->img_n; - if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; - if (has_trans) { - if (z->depth == 16) { - if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; - } else { - if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; - } - } - if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) - stbi__de_iphone(z); - if (pal_img_n) { - // pal_img_n == 3 or 4 - s->img_n = pal_img_n; // record the actual colors we had - s->img_out_n = pal_img_n; - if (req_comp >= 3) s->img_out_n = req_comp; - if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) - return 0; - } else if (has_trans) { - // non-paletted image with tRNS -> source image has (constant) alpha - ++s->img_n; - } - STBI_FREE(z->expanded); z->expanded = NULL; - return 1; - } - - default: - // if critical, fail - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if ((c.type & (1 << 29)) == 0) { - #ifndef STBI_NO_FAILURE_STRINGS - // not threadsafe - static char invalid_chunk[] = "XXXX PNG chunk not known"; - invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); - invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); - invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); - invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); - #endif - return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); - } - stbi__skip(s, c.length); - break; + case STBI__PNG_TYPE('P', 'L', 'T', 'E'): { + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (c.length > 256 * 3) + return stbi__err("invalid PLTE", "Corrupt PNG"); + pal_len = c.length / 3; + if (pal_len * 3 != c.length) + return stbi__err("invalid PLTE", "Corrupt PNG"); + for (i = 0; i < pal_len; ++i) { + palette[i * 4 + 0] = stbi__get8(s); + palette[i * 4 + 1] = stbi__get8(s); + palette[i * 4 + 2] = stbi__get8(s); + palette[i * 4 + 3] = 255; } - // end of PNG chunk, read and skip CRC - stbi__get32be(s); - } -} + break; + } -static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) -{ - void *result=NULL; - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { - if (p->depth < 8) - ri->bits_per_channel = 8; - else - ri->bits_per_channel = p->depth; - result = p->out; - p->out = NULL; - if (req_comp && req_comp != p->s->img_out_n) { - if (ri->bits_per_channel == 8) - result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); - else - result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); - p->s->img_out_n = req_comp; - if (result == NULL) return result; + case STBI__PNG_TYPE('t', 'R', 'N', 'S'): { + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (z->idata) + return stbi__err("tRNS after IDAT", "Corrupt PNG"); + if (pal_img_n) { + if (scan == STBI__SCAN_header) { + s->img_n = 4; + return 1; + } + if (pal_len == 0) + return stbi__err("tRNS before PLTE", "Corrupt PNG"); + if (c.length > pal_len) + return stbi__err("bad tRNS len", "Corrupt PNG"); + pal_img_n = 4; + for (i = 0; i < c.length; ++i) + palette[i * 4 + 3] = stbi__get8(s); + } else { + if (!(s->img_n & 1)) + return stbi__err("tRNS with alpha", "Corrupt PNG"); + if (c.length != (stbi__uint32)s->img_n * 2) + return stbi__err("bad tRNS len", "Corrupt PNG"); + has_trans = 1; + if (z->depth == 16) { + for (k = 0; k < s->img_n; ++k) + tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is + } else { + for (k = 0; k < s->img_n; ++k) + tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * + stbi__depth_scale_table[z->depth]; // non 8-bit images will + // be larger + } } - *x = p->s->img_x; - *y = p->s->img_y; - if (n) *n = p->s->img_n; - } - STBI_FREE(p->out); p->out = NULL; - STBI_FREE(p->expanded); p->expanded = NULL; - STBI_FREE(p->idata); p->idata = NULL; - - return result; -} - -static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi__png p; - p.s = s; - return stbi__do_png(&p, x,y,comp,req_comp, ri); -} - -static int stbi__png_test(stbi__context *s) -{ - int r; - r = stbi__check_png_header(s); - stbi__rewind(s); - return r; -} + break; + } -static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) -{ - if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { - stbi__rewind( p->s ); - return 0; - } - if (x) *x = p->s->img_x; - if (y) *y = p->s->img_y; - if (comp) *comp = p->s->img_n; - return 1; -} + case STBI__PNG_TYPE('I', 'D', 'A', 'T'): { + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (pal_img_n && !pal_len) + return stbi__err("no PLTE", "Corrupt PNG"); + if (scan == STBI__SCAN_header) { + s->img_n = pal_img_n; + return 1; + } + if ((int)(ioff + c.length) < (int)ioff) + return 0; + if (ioff + c.length > idata_limit) { + stbi__uint32 idata_limit_old = idata_limit; + stbi_uc *p; + if (idata_limit == 0) + idata_limit = c.length > 4096 ? c.length : 4096; + while (ioff + c.length > idata_limit) + idata_limit *= 2; + STBI_NOTUSED(idata_limit_old); + p = (stbi_uc *)STBI_REALLOC_SIZED(z->idata, idata_limit_old, + idata_limit); + if (p == NULL) + return stbi__err("outofmem", "Out of memory"); + z->idata = p; + } + if (!stbi__getn(s, z->idata + ioff, c.length)) + return stbi__err("outofdata", "Corrupt PNG"); + ioff += c.length; + break; + } -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__png p; - p.s = s; - return stbi__png_info_raw(&p, x, y, comp); -} + case STBI__PNG_TYPE('I', 'E', 'N', 'D'): { + stbi__uint32 raw_len, bpl; + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (scan != STBI__SCAN_load) + return 1; + if (z->idata == NULL) + return stbi__err("no IDAT", "Corrupt PNG"); + // initial guess for decoded data size to avoid unnecessary reallocs + bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component + raw_len = bpl * s->img_y * s->img_n /* pixels */ + + s->img_y /* filter mode per row */; + z->expanded = (stbi_uc *)stbi_zlib_decode_malloc_guesssize_headerflag( + (char *)z->idata, ioff, raw_len, (int *)&raw_len, !is_iphone); + if (z->expanded == NULL) + return 0; // zlib should set error + STBI_FREE(z->idata); + z->idata = NULL; + if ((req_comp == s->img_n + 1 && req_comp != 3 && !pal_img_n) || + has_trans) + s->img_out_n = s->img_n + 1; + else + s->img_out_n = s->img_n; + if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, + z->depth, color, interlace)) + return 0; + if (has_trans) { + if (z->depth == 16) { + if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) + return 0; + } else { + if (!stbi__compute_transparency(z, tc, s->img_out_n)) + return 0; + } + } + if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) + stbi__de_iphone(z); + if (pal_img_n) { + // pal_img_n == 3 or 4 + s->img_n = pal_img_n; // record the actual colors we had + s->img_out_n = pal_img_n; + if (req_comp >= 3) + s->img_out_n = req_comp; + if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) + return 0; + } else if (has_trans) { + // non-paletted image with tRNS -> source image has (constant) alpha + ++s->img_n; + } + STBI_FREE(z->expanded); + z->expanded = NULL; + return 1; + } -static int stbi__png_is16(stbi__context *s) -{ - stbi__png p; - p.s = s; - if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) - return 0; - if (p.depth != 16) { - stbi__rewind(p.s); - return 0; - } - return 1; + default: + // if critical, fail + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if ((c.type & (1 << 29)) == 0) { +#ifndef STBI_NO_FAILURE_STRINGS + // not threadsafe + static char invalid_chunk[] = "XXXX PNG chunk not known"; + invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); + invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); + invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); + invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); +#endif + return stbi__err(invalid_chunk, + "PNG not supported: unknown PNG chunk type"); + } + stbi__skip(s, c.length); + break; + } + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + } +} + +static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, + stbi__result_info *ri) { + void *result = NULL; + if (req_comp < 0 || req_comp > 4) + return stbi__errpuc("bad req_comp", "Internal error"); + if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { + if (p->depth < 8) + ri->bits_per_channel = 8; + else + ri->bits_per_channel = p->depth; + result = p->out; + p->out = NULL; + if (req_comp && req_comp != p->s->img_out_n) { + if (ri->bits_per_channel == 8) + result = stbi__convert_format((unsigned char *)result, p->s->img_out_n, + req_comp, p->s->img_x, p->s->img_y); + else + result = stbi__convert_format16((stbi__uint16 *)result, p->s->img_out_n, + req_comp, p->s->img_x, p->s->img_y); + p->s->img_out_n = req_comp; + if (result == NULL) + return result; + } + *x = p->s->img_x; + *y = p->s->img_y; + if (n) + *n = p->s->img_n; + } + STBI_FREE(p->out); + p->out = NULL; + STBI_FREE(p->expanded); + p->expanded = NULL; + STBI_FREE(p->idata); + p->idata = NULL; + + return result; +} + +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri) { + stbi__png p; + p.s = s; + return stbi__do_png(&p, x, y, comp, req_comp, ri); +} + +static int stbi__png_test(stbi__context *s) { + int r; + r = stbi__check_png_header(s); + stbi__rewind(s); + return r; +} + +static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { + if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { + stbi__rewind(p->s); + return 0; + } + if (x) + *x = p->s->img_x; + if (y) + *y = p->s->img_y; + if (comp) + *comp = p->s->img_n; + return 1; +} + +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { + stbi__png p; + p.s = s; + return stbi__png_info_raw(&p, x, y, comp); +} + +static int stbi__png_is16(stbi__context *s) { + stbi__png p; + p.s = s; + if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) + return 0; + if (p.depth != 16) { + stbi__rewind(p.s); + return 0; + } + return 1; } #endif // Microsoft/Windows BMP image #ifndef STBI_NO_BMP -static int stbi__bmp_test_raw(stbi__context *s) -{ - int r; - int sz; - if (stbi__get8(s) != 'B') return 0; - if (stbi__get8(s) != 'M') return 0; - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - stbi__get32le(s); // discard data offset - sz = stbi__get32le(s); - r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); - return r; -} - -static int stbi__bmp_test(stbi__context *s) -{ - int r = stbi__bmp_test_raw(s); - stbi__rewind(s); - return r; +static int stbi__bmp_test_raw(stbi__context *s) { + int r; + int sz; + if (stbi__get8(s) != 'B') + return 0; + if (stbi__get8(s) != 'M') + return 0; + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + stbi__get32le(s); // discard data offset + sz = stbi__get32le(s); + r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); + return r; +} + +static int stbi__bmp_test(stbi__context *s) { + int r = stbi__bmp_test_raw(s); + stbi__rewind(s); + return r; } - // returns 0..31 for the highest set bit -static int stbi__high_bit(unsigned int z) -{ - int n=0; - if (z == 0) return -1; - if (z >= 0x10000) { n += 16; z >>= 16; } - if (z >= 0x00100) { n += 8; z >>= 8; } - if (z >= 0x00010) { n += 4; z >>= 4; } - if (z >= 0x00004) { n += 2; z >>= 2; } - if (z >= 0x00002) { n += 1;/* >>= 1;*/ } - return n; +static int stbi__high_bit(unsigned int z) { + int n = 0; + if (z == 0) + return -1; + if (z >= 0x10000) { + n += 16; + z >>= 16; + } + if (z >= 0x00100) { + n += 8; + z >>= 8; + } + if (z >= 0x00010) { + n += 4; + z >>= 4; + } + if (z >= 0x00004) { + n += 2; + z >>= 2; + } + if (z >= 0x00002) { + n += 1; /* >>= 1;*/ + } + return n; } -static int stbi__bitcount(unsigned int a) -{ - a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 - a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 - a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits - a = (a + (a >> 8)); // max 16 per 8 bits - a = (a + (a >> 16)); // max 32 per 8 bits - return a & 0xff; +static int stbi__bitcount(unsigned int a) { + a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 + a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 + a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits + a = (a + (a >> 8)); // max 16 per 8 bits + a = (a + (a >> 16)); // max 32 per 8 bits + return a & 0xff; } // extract an arbitrarily-aligned N-bit value (N=bits) // from v, and then make it 8-bits long and fractionally // extend it to full full range. -static int stbi__shiftsigned(unsigned int v, int shift, int bits) -{ - static unsigned int mul_table[9] = { +static int stbi__shiftsigned(unsigned int v, int shift, int bits) { + static unsigned int mul_table[9] = { 0, - 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, - 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, - }; - static unsigned int shift_table[9] = { - 0, 0,0,1,0,2,4,6,0, - }; - if (shift < 0) - v <<= -shift; - else - v >>= shift; - STBI_ASSERT(v >= 0 && v < 256); - v >>= (8-bits); - STBI_ASSERT(bits >= 0 && bits <= 8); - return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; -} - -typedef struct -{ - int bpp, offset, hsz; - unsigned int mr,mg,mb,ma, all_a; + 0xff /*0b11111111*/, + 0x55 /*0b01010101*/, + 0x49 /*0b01001001*/, + 0x11 /*0b00010001*/, + 0x21 /*0b00100001*/, + 0x41 /*0b01000001*/, + 0x81 /*0b10000001*/, + 0x01 /*0b00000001*/, + }; + static unsigned int shift_table[9] = { + 0, 0, 0, 1, 0, 2, 4, 6, 0, + }; + if (shift < 0) + v <<= -shift; + else + v >>= shift; + STBI_ASSERT(v >= 0 && v < 256); + v >>= (8 - bits); + STBI_ASSERT(bits >= 0 && bits <= 8); + return (int)((unsigned)v * mul_table[bits]) >> shift_table[bits]; +} + +typedef struct { + int bpp, offset, hsz; + unsigned int mr, mg, mb, ma, all_a; } stbi__bmp_data; -static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) -{ - int hsz; - if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - info->offset = stbi__get32le(s); - info->hsz = hsz = stbi__get32le(s); - info->mr = info->mg = info->mb = info->ma = 0; - - if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); - if (hsz == 12) { - s->img_x = stbi__get16le(s); - s->img_y = stbi__get16le(s); - } else { - s->img_x = stbi__get32le(s); - s->img_y = stbi__get32le(s); - } - if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); - info->bpp = stbi__get16le(s); - if (hsz != 12) { - int compress = stbi__get32le(s); - if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); - stbi__get32le(s); // discard sizeof - stbi__get32le(s); // discard hres - stbi__get32le(s); // discard vres - stbi__get32le(s); // discard colorsused - stbi__get32le(s); // discard max important - if (hsz == 40 || hsz == 56) { - if (hsz == 56) { - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - } - if (info->bpp == 16 || info->bpp == 32) { - if (compress == 0) { - if (info->bpp == 32) { - info->mr = 0xffu << 16; - info->mg = 0xffu << 8; - info->mb = 0xffu << 0; - info->ma = 0xffu << 24; - info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 - } else { - info->mr = 31u << 10; - info->mg = 31u << 5; - info->mb = 31u << 0; - } - } else if (compress == 3) { - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - // not documented, but generated by photoshop and handled by mspaint - if (info->mr == info->mg && info->mg == info->mb) { - // ?!?!? - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else { - int i; - if (hsz != 108 && hsz != 124) +static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { + int hsz; + if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') + return stbi__errpuc("not BMP", "Corrupt BMP"); + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + info->offset = stbi__get32le(s); + info->hsz = hsz = stbi__get32le(s); + info->mr = info->mg = info->mb = info->ma = 0; + + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) + return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); + if (hsz == 12) { + s->img_x = stbi__get16le(s); + s->img_y = stbi__get16le(s); + } else { + s->img_x = stbi__get32le(s); + s->img_y = stbi__get32le(s); + } + if (stbi__get16le(s) != 1) + return stbi__errpuc("bad BMP", "bad BMP"); + info->bpp = stbi__get16le(s); + if (hsz != 12) { + int compress = stbi__get32le(s); + if (compress == 1 || compress == 2) + return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); + stbi__get32le(s); // discard sizeof + stbi__get32le(s); // discard hres + stbi__get32le(s); // discard vres + stbi__get32le(s); // discard colorsused + stbi__get32le(s); // discard max important + if (hsz == 40 || hsz == 56) { + if (hsz == 56) { + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + } + if (info->bpp == 16 || info->bpp == 32) { + if (compress == 0) { + if (info->bpp == 32) { + info->mr = 0xffu << 16; + info->mg = 0xffu << 8; + info->mb = 0xffu << 0; + info->ma = 0xffu << 24; + info->all_a = 0; // if all_a is 0 at end, then we loaded alpha + // channel but it was all 0 + } else { + info->mr = 31u << 10; + info->mg = 31u << 5; + info->mb = 31u << 0; + } + } else if (compress == 3) { + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + // not documented, but generated by photoshop and handled by mspaint + if (info->mr == info->mg && info->mg == info->mb) { + // ?!?!? return stbi__errpuc("bad BMP", "bad BMP"); - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - info->ma = stbi__get32le(s); - stbi__get32le(s); // discard color space - for (i=0; i < 12; ++i) - stbi__get32le(s); // discard color space parameters - if (hsz == 124) { - stbi__get32le(s); // discard rendering intent - stbi__get32le(s); // discard offset of profile data - stbi__get32le(s); // discard size of profile data - stbi__get32le(s); // discard reserved - } + } + } else + return stbi__errpuc("bad BMP", "bad BMP"); } - } - return (void *) 1; -} - - -static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *out; - unsigned int mr=0,mg=0,mb=0,ma=0, all_a; - stbi_uc pal[256][4]; - int psize=0,i,j,width; - int flip_vertically, pad, target; - stbi__bmp_data info; - STBI_NOTUSED(ri); - - info.all_a = 255; - if (stbi__bmp_parse_header(s, &info) == NULL) - return NULL; // error code already set - - flip_vertically = ((int) s->img_y) > 0; - s->img_y = abs((int) s->img_y); - - mr = info.mr; - mg = info.mg; - mb = info.mb; - ma = info.ma; - all_a = info.all_a; - - if (info.hsz == 12) { - if (info.bpp < 24) - psize = (info.offset - 14 - 24) / 3; - } else { - if (info.bpp < 16) - psize = (info.offset - 14 - info.hsz) >> 2; - } - - if (info.bpp == 24 && ma == 0xff000000) - s->img_n = 3; - else - s->img_n = ma ? 4 : 3; - if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 - target = req_comp; - else - target = s->img_n; // if they want monochrome, we'll post-convert - - // sanity-check size - if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) - return stbi__errpuc("too large", "Corrupt BMP"); - - out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - if (info.bpp < 16) { - int z=0; - if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } - for (i=0; i < psize; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - if (info.hsz != 12) stbi__get8(s); - pal[i][3] = 255; + } else { + int i; + if (hsz != 108 && hsz != 124) + return stbi__errpuc("bad BMP", "bad BMP"); + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->ma = stbi__get32le(s); + stbi__get32le(s); // discard color space + for (i = 0; i < 12; ++i) + stbi__get32le(s); // discard color space parameters + if (hsz == 124) { + stbi__get32le(s); // discard rendering intent + stbi__get32le(s); // discard offset of profile data + stbi__get32le(s); // discard size of profile data + stbi__get32le(s); // discard reserved } - stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); - if (info.bpp == 1) width = (s->img_x + 7) >> 3; - else if (info.bpp == 4) width = (s->img_x + 1) >> 1; - else if (info.bpp == 8) width = s->img_x; - else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } - pad = (-width)&3; - if (info.bpp == 1) { - for (j=0; j < (int) s->img_y; ++j) { - int bit_offset = 7, v = stbi__get8(s); - for (i=0; i < (int) s->img_x; ++i) { - int color = (v>>bit_offset)&0x1; - out[z++] = pal[color][0]; - out[z++] = pal[color][1]; - out[z++] = pal[color][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - if((--bit_offset) < 0) { - bit_offset = 7; - v = stbi__get8(s); - } - } - stbi__skip(s, pad); - } - } else { - for (j=0; j < (int) s->img_y; ++j) { - for (i=0; i < (int) s->img_x; i += 2) { - int v=stbi__get8(s),v2=0; - if (info.bpp == 4) { - v2 = v & 15; - v >>= 4; - } - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - v = (info.bpp == 8) ? stbi__get8(s) : v2; - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - } - stbi__skip(s, pad); - } + } + } + return (void *)1; +} + +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri) { + stbi_uc *out; + unsigned int mr = 0, mg = 0, mb = 0, ma = 0, all_a; + stbi_uc pal[256][4]; + int psize = 0, i, j, width; + int flip_vertically, pad, target; + stbi__bmp_data info; + STBI_NOTUSED(ri); + + info.all_a = 255; + if (stbi__bmp_parse_header(s, &info) == NULL) + return NULL; // error code already set + + flip_vertically = ((int)s->img_y) > 0; + s->img_y = abs((int)s->img_y); + + mr = info.mr; + mg = info.mg; + mb = info.mb; + ma = info.ma; + all_a = info.all_a; + + if (info.hsz == 12) { + if (info.bpp < 24) + psize = (info.offset - 14 - 24) / 3; + } else { + if (info.bpp < 16) + psize = (info.offset - 14 - info.hsz) >> 2; + } + + if (info.bpp == 24 && ma == 0xff000000) + s->img_n = 3; + else + s->img_n = ma ? 4 : 3; + if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 + target = req_comp; + else + target = s->img_n; // if they want monochrome, we'll post-convert + + // sanity-check size + if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "Corrupt BMP"); + + out = (stbi_uc *)stbi__malloc_mad3(target, s->img_x, s->img_y, 0); + if (!out) + return stbi__errpuc("outofmem", "Out of memory"); + if (info.bpp < 16) { + int z = 0; + if (psize == 0 || psize > 256) { + STBI_FREE(out); + return stbi__errpuc("invalid", "Corrupt BMP"); + } + for (i = 0; i < psize; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + if (info.hsz != 12) + stbi__get8(s); + pal[i][3] = 255; + } + stbi__skip(s, + info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); + if (info.bpp == 1) + width = (s->img_x + 7) >> 3; + else if (info.bpp == 4) + width = (s->img_x + 1) >> 1; + else if (info.bpp == 8) + width = s->img_x; + else { + STBI_FREE(out); + return stbi__errpuc("bad bpp", "Corrupt BMP"); + } + pad = (-width) & 3; + if (info.bpp == 1) { + for (j = 0; j < (int)s->img_y; ++j) { + int bit_offset = 7, v = stbi__get8(s); + for (i = 0; i < (int)s->img_x; ++i) { + int color = (v >> bit_offset) & 0x1; + out[z++] = pal[color][0]; + out[z++] = pal[color][1]; + out[z++] = pal[color][2]; + if (target == 4) + out[z++] = 255; + if (i + 1 == (int)s->img_x) + break; + if ((--bit_offset) < 0) { + bit_offset = 7; + v = stbi__get8(s); + } + } + stbi__skip(s, pad); } - } else { - int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; - int z = 0; - int easy=0; - stbi__skip(s, info.offset - 14 - info.hsz); - if (info.bpp == 24) width = 3 * s->img_x; - else if (info.bpp == 16) width = 2*s->img_x; - else /* bpp = 32 and pad = 0 */ width=0; - pad = (-width) & 3; - if (info.bpp == 24) { - easy = 1; - } else if (info.bpp == 32) { - if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) - easy = 2; + } else { + for (j = 0; j < (int)s->img_y; ++j) { + for (i = 0; i < (int)s->img_x; i += 2) { + int v = stbi__get8(s), v2 = 0; + if (info.bpp == 4) { + v2 = v & 15; + v >>= 4; + } + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) + out[z++] = 255; + if (i + 1 == (int)s->img_x) + break; + v = (info.bpp == 8) ? stbi__get8(s) : v2; + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) + out[z++] = 255; + } + stbi__skip(s, pad); } - if (!easy) { - if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } - // right shift amt to put high bit in position #7 - rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); - gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); - bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); - ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); + } + } else { + int rshift = 0, gshift = 0, bshift = 0, ashift = 0, rcount = 0, gcount = 0, + bcount = 0, acount = 0; + int z = 0; + int easy = 0; + stbi__skip(s, info.offset - 14 - info.hsz); + if (info.bpp == 24) + width = 3 * s->img_x; + else if (info.bpp == 16) + width = 2 * s->img_x; + else /* bpp = 32 and pad = 0 */ + width = 0; + pad = (-width) & 3; + if (info.bpp == 24) { + easy = 1; + } else if (info.bpp == 32) { + if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) + easy = 2; + } + if (!easy) { + if (!mr || !mg || !mb) { + STBI_FREE(out); + return stbi__errpuc("bad masks", "Corrupt BMP"); } - for (j=0; j < (int) s->img_y; ++j) { - if (easy) { - for (i=0; i < (int) s->img_x; ++i) { - unsigned char a; - out[z+2] = stbi__get8(s); - out[z+1] = stbi__get8(s); - out[z+0] = stbi__get8(s); - z += 3; - a = (easy == 2 ? stbi__get8(s) : 255); - all_a |= a; - if (target == 4) out[z++] = a; - } - } else { - int bpp = info.bpp; - for (i=0; i < (int) s->img_x; ++i) { - stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); - unsigned int a; - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); - a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); - all_a |= a; - if (target == 4) out[z++] = STBI__BYTECAST(a); - } - } - stbi__skip(s, pad); + // right shift amt to put high bit in position #7 + rshift = stbi__high_bit(mr) - 7; + rcount = stbi__bitcount(mr); + gshift = stbi__high_bit(mg) - 7; + gcount = stbi__bitcount(mg); + bshift = stbi__high_bit(mb) - 7; + bcount = stbi__bitcount(mb); + ashift = stbi__high_bit(ma) - 7; + acount = stbi__bitcount(ma); + } + for (j = 0; j < (int)s->img_y; ++j) { + if (easy) { + for (i = 0; i < (int)s->img_x; ++i) { + unsigned char a; + out[z + 2] = stbi__get8(s); + out[z + 1] = stbi__get8(s); + out[z + 0] = stbi__get8(s); + z += 3; + a = (easy == 2 ? stbi__get8(s) : 255); + all_a |= a; + if (target == 4) + out[z++] = a; + } + } else { + int bpp = info.bpp; + for (i = 0; i < (int)s->img_x; ++i) { + stbi__uint32 v = + (bpp == 16 ? (stbi__uint32)stbi__get16le(s) : stbi__get32le(s)); + unsigned int a; + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); + a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); + all_a |= a; + if (target == 4) + out[z++] = STBI__BYTECAST(a); + } } - } - - // if alpha channel is all 0s, replace with all 255s - if (target == 4 && all_a == 0) - for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) - out[i] = 255; - - if (flip_vertically) { - stbi_uc t; - for (j=0; j < (int) s->img_y>>1; ++j) { - stbi_uc *p1 = out + j *s->img_x*target; - stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; - for (i=0; i < (int) s->img_x*target; ++i) { - t = p1[i]; p1[i] = p2[i]; p2[i] = t; - } + stbi__skip(s, pad); + } + } + + // if alpha channel is all 0s, replace with all 255s + if (target == 4 && all_a == 0) + for (i = 4 * s->img_x * s->img_y - 1; i >= 0; i -= 4) + out[i] = 255; + + if (flip_vertically) { + stbi_uc t; + for (j = 0; j < (int)s->img_y >> 1; ++j) { + stbi_uc *p1 = out + j * s->img_x * target; + stbi_uc *p2 = out + (s->img_y - 1 - j) * s->img_x * target; + for (i = 0; i < (int)s->img_x * target; ++i) { + t = p1[i]; + p1[i] = p2[i]; + p2[i] = t; } - } + } + } - if (req_comp && req_comp != target) { - out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } + if (req_comp && req_comp != target) { + out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); + if (out == NULL) + return out; // stbi__convert_format frees input on failure + } - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = s->img_n; - return out; + *x = s->img_x; + *y = s->img_y; + if (comp) + *comp = s->img_n; + return out; } #endif @@ -5392,581 +6031,610 @@ static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error -static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) -{ - // only RGB or RGBA (incl. 16bit) or grey allowed - if (is_rgb16) *is_rgb16 = 0; - switch(bits_per_pixel) { - case 8: return STBI_grey; - case 16: if(is_grey) return STBI_grey_alpha; - // fallthrough - case 15: if(is_rgb16) *is_rgb16 = 1; - return STBI_rgb; - case 24: // fallthrough - case 32: return bits_per_pixel/8; - default: return 0; - } -} - -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) -{ - int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; - int sz, tga_colormap_type; - stbi__get8(s); // discard Offset - tga_colormap_type = stbi__get8(s); // colormap type - if( tga_colormap_type > 1 ) { - stbi__rewind(s); - return 0; // only RGB or indexed allowed - } - tga_image_type = stbi__get8(s); // image type - if ( tga_colormap_type == 1 ) { // colormapped (paletted) image - if (tga_image_type != 1 && tga_image_type != 9) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip image x and y origin - tga_colormap_bpp = sz; - } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE - if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { - stbi__rewind(s); - return 0; // only RGB or grey allowed, +/- RLE - } - stbi__skip(s,9); // skip colormap specification and image x/y origin - tga_colormap_bpp = 0; - } - tga_w = stbi__get16le(s); - if( tga_w < 1 ) { - stbi__rewind(s); - return 0; // test width +static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int *is_rgb16) { + // only RGB or RGBA (incl. 16bit) or grey allowed + if (is_rgb16) + *is_rgb16 = 0; + switch (bits_per_pixel) { + case 8: + return STBI_grey; + case 16: + if (is_grey) + return STBI_grey_alpha; + // fallthrough + case 15: + if (is_rgb16) + *is_rgb16 = 1; + return STBI_rgb; + case 24: // fallthrough + case 32: + return bits_per_pixel / 8; + default: + return 0; + } +} + +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { + int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, + tga_colormap_bpp; + int sz, tga_colormap_type; + stbi__get8(s); // discard Offset + tga_colormap_type = stbi__get8(s); // colormap type + if (tga_colormap_type > 1) { + stbi__rewind(s); + return 0; // only RGB or indexed allowed + } + tga_image_type = stbi__get8(s); // image type + if (tga_colormap_type == 1) { // colormapped (paletted) image + if (tga_image_type != 1 && tga_image_type != 9) { + stbi__rewind(s); + return 0; } - tga_h = stbi__get16le(s); - if( tga_h < 1 ) { - stbi__rewind(s); - return 0; // test height + stbi__skip(s, + 4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) { + stbi__rewind(s); + return 0; } - tga_bits_per_pixel = stbi__get8(s); // bits per pixel - stbi__get8(s); // ignore alpha bits - if (tga_colormap_bpp != 0) { - if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { - // when using a colormap, tga_bits_per_pixel is the size of the indexes - // I don't think anything but 8 or 16bit indexes makes sense - stbi__rewind(s); - return 0; - } - tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); - } else { - tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); + stbi__skip(s, 4); // skip image x and y origin + tga_colormap_bpp = sz; + } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE + if ((tga_image_type != 2) && (tga_image_type != 3) && + (tga_image_type != 10) && (tga_image_type != 11)) { + stbi__rewind(s); + return 0; // only RGB or grey allowed, +/- RLE } - if(!tga_comp) { + stbi__skip(s, 9); // skip colormap specification and image x/y origin + tga_colormap_bpp = 0; + } + tga_w = stbi__get16le(s); + if (tga_w < 1) { + stbi__rewind(s); + return 0; // test width + } + tga_h = stbi__get16le(s); + if (tga_h < 1) { + stbi__rewind(s); + return 0; // test height + } + tga_bits_per_pixel = stbi__get8(s); // bits per pixel + stbi__get8(s); // ignore alpha bits + if (tga_colormap_bpp != 0) { + if ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { + // when using a colormap, tga_bits_per_pixel is the size of the indexes + // I don't think anything but 8 or 16bit indexes makes sense stbi__rewind(s); return 0; } - if (x) *x = tga_w; - if (y) *y = tga_h; - if (comp) *comp = tga_comp; - return 1; // seems to have passed everything -} - -static int stbi__tga_test(stbi__context *s) -{ - int res = 0; - int sz, tga_color_type; - stbi__get8(s); // discard Offset - tga_color_type = stbi__get8(s); // color type - if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed - sz = stbi__get8(s); // image type - if ( tga_color_type == 1 ) { // colormapped (paletted) image - if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - stbi__skip(s,4); // skip image x and y origin - } else { // "normal" image w/o colormap - if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE - stbi__skip(s,9); // skip colormap specification and image x/y origin - } - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height - sz = stbi__get8(s); // bits per pixel - if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - - res = 1; // if we got this far, everything's good and we can return 1 instead of 0 + tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); + } else { + tga_comp = stbi__tga_get_comp( + tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), + NULL); + } + if (!tga_comp) { + stbi__rewind(s); + return 0; + } + if (x) + *x = tga_w; + if (y) + *y = tga_h; + if (comp) + *comp = tga_comp; + return 1; // seems to have passed everything +} + +static int stbi__tga_test(stbi__context *s) { + int res = 0; + int sz, tga_color_type; + stbi__get8(s); // discard Offset + tga_color_type = stbi__get8(s); // color type + if (tga_color_type > 1) + goto errorEnd; // only RGB or indexed allowed + sz = stbi__get8(s); // image type + if (tga_color_type == 1) { // colormapped (paletted) image + if (sz != 1 && sz != 9) + goto errorEnd; // colortype 1 demands image type 1 or 9 + stbi__skip(s, + 4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) + goto errorEnd; + stbi__skip(s, 4); // skip image x and y origin + } else { // "normal" image w/o colormap + if ((sz != 2) && (sz != 3) && (sz != 10) && (sz != 11)) + goto errorEnd; // only RGB or grey allowed, +/- RLE + stbi__skip(s, 9); // skip colormap specification and image x/y origin + } + if (stbi__get16le(s) < 1) + goto errorEnd; // test width + if (stbi__get16le(s) < 1) + goto errorEnd; // test height + sz = stbi__get8(s); // bits per pixel + if ((tga_color_type == 1) && (sz != 8) && (sz != 16)) + goto errorEnd; // for colormapped images, bpp is size of an index + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) + goto errorEnd; + + res = 1; // if we got this far, everything's good and we can return 1 instead + // of 0 errorEnd: - stbi__rewind(s); - return res; + stbi__rewind(s); + return res; } // read 16bit value and convert to 24bit RGB -static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) -{ - stbi__uint16 px = (stbi__uint16)stbi__get16le(s); - stbi__uint16 fiveBitMask = 31; - // we have 3 channels with 5bits each - int r = (px >> 10) & fiveBitMask; - int g = (px >> 5) & fiveBitMask; - int b = px & fiveBitMask; - // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later - out[0] = (stbi_uc)((r * 255)/31); - out[1] = (stbi_uc)((g * 255)/31); - out[2] = (stbi_uc)((b * 255)/31); - - // some people claim that the most significant bit might be used for alpha - // (possibly if an alpha-bit is set in the "image descriptor byte") - // but that only made 16bit test images completely translucent.. - // so let's treat all 15 and 16bit TGAs as RGB with no alpha. -} - -static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - // read in the TGA header stuff - int tga_offset = stbi__get8(s); - int tga_indexed = stbi__get8(s); - int tga_image_type = stbi__get8(s); - int tga_is_RLE = 0; - int tga_palette_start = stbi__get16le(s); - int tga_palette_len = stbi__get16le(s); - int tga_palette_bits = stbi__get8(s); - int tga_x_origin = stbi__get16le(s); - int tga_y_origin = stbi__get16le(s); - int tga_width = stbi__get16le(s); - int tga_height = stbi__get16le(s); - int tga_bits_per_pixel = stbi__get8(s); - int tga_comp, tga_rgb16=0; - int tga_inverted = stbi__get8(s); - // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) - // image data - unsigned char *tga_data; - unsigned char *tga_palette = NULL; - int i, j; - unsigned char raw_data[4] = {0}; - int RLE_count = 0; - int RLE_repeating = 0; - int read_next_pixel = 1; - STBI_NOTUSED(ri); - STBI_NOTUSED(tga_x_origin); // @TODO - STBI_NOTUSED(tga_y_origin); // @TODO - - // do a tiny bit of precessing - if ( tga_image_type >= 8 ) - { - tga_image_type -= 8; - tga_is_RLE = 1; - } - tga_inverted = 1 - ((tga_inverted >> 5) & 1); - - // If I'm paletted, then I'll use the number of bits from the palette - if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); - else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); - - if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency - return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); - - // tga info - *x = tga_width; - *y = tga_height; - if (comp) *comp = tga_comp; - - if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) - return stbi__errpuc("too large", "Corrupt TGA"); - - tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); - if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); - - // skip to the data's starting position (offset usually = 0) - stbi__skip(s, tga_offset ); - - if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { - for (i=0; i < tga_height; ++i) { - int row = tga_inverted ? tga_height -i - 1 : i; - stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; - stbi__getn(s, tga_row, tga_width * tga_comp); - } - } else { - // do I need to load a palette? - if ( tga_indexed) - { - // any data to skip? (offset usually = 0) - stbi__skip(s, tga_palette_start ); - // load the palette - tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); - if (!tga_palette) { - STBI_FREE(tga_data); - return stbi__errpuc("outofmem", "Out of memory"); - } - if (tga_rgb16) { - stbi_uc *pal_entry = tga_palette; - STBI_ASSERT(tga_comp == STBI_rgb); - for (i=0; i < tga_palette_len; ++i) { - stbi__tga_read_rgb16(s, pal_entry); - pal_entry += tga_comp; - } - } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { - STBI_FREE(tga_data); - STBI_FREE(tga_palette); - return stbi__errpuc("bad palette", "Corrupt TGA"); - } - } - // load the data - for (i=0; i < tga_width * tga_height; ++i) - { - // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? - if ( tga_is_RLE ) - { - if ( RLE_count == 0 ) - { - // yep, get the next byte as a RLE command - int RLE_cmd = stbi__get8(s); - RLE_count = 1 + (RLE_cmd & 127); - RLE_repeating = RLE_cmd >> 7; - read_next_pixel = 1; - } else if ( !RLE_repeating ) - { - read_next_pixel = 1; - } - } else - { - read_next_pixel = 1; - } - // OK, if I need to read a pixel, do it now - if ( read_next_pixel ) - { - // load however much data we did have - if ( tga_indexed ) - { - // read in index, then perform the lookup - int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); - if ( pal_idx >= tga_palette_len ) { - // invalid index - pal_idx = 0; - } - pal_idx *= tga_comp; - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = tga_palette[pal_idx+j]; - } - } else if(tga_rgb16) { - STBI_ASSERT(tga_comp == STBI_rgb); - stbi__tga_read_rgb16(s, raw_data); - } else { - // read in the data raw - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = stbi__get8(s); - } - } - // clear the reading flag for the next pixel - read_next_pixel = 0; - } // end of reading a pixel - - // copy data - for (j = 0; j < tga_comp; ++j) - tga_data[i*tga_comp+j] = raw_data[j]; - - // in case we're in RLE mode, keep counting down - --RLE_count; +static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc *out) { + stbi__uint16 px = (stbi__uint16)stbi__get16le(s); + stbi__uint16 fiveBitMask = 31; + // we have 3 channels with 5bits each + int r = (px >> 10) & fiveBitMask; + int g = (px >> 5) & fiveBitMask; + int b = px & fiveBitMask; + // Note that this saves the data in RGB(A) order, so it doesn't need to be + // swapped later + out[0] = (stbi_uc)((r * 255) / 31); + out[1] = (stbi_uc)((g * 255) / 31); + out[2] = (stbi_uc)((b * 255) / 31); + + // some people claim that the most significant bit might be used for alpha + // (possibly if an alpha-bit is set in the "image descriptor byte") + // but that only made 16bit test images completely translucent.. + // so let's treat all 15 and 16bit TGAs as RGB with no alpha. +} + +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri) { + // read in the TGA header stuff + int tga_offset = stbi__get8(s); + int tga_indexed = stbi__get8(s); + int tga_image_type = stbi__get8(s); + int tga_is_RLE = 0; + int tga_palette_start = stbi__get16le(s); + int tga_palette_len = stbi__get16le(s); + int tga_palette_bits = stbi__get8(s); + int tga_x_origin = stbi__get16le(s); + int tga_y_origin = stbi__get16le(s); + int tga_width = stbi__get16le(s); + int tga_height = stbi__get16le(s); + int tga_bits_per_pixel = stbi__get8(s); + int tga_comp, tga_rgb16 = 0; + int tga_inverted = stbi__get8(s); + // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused + // (useless?) + // image data + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; + unsigned char raw_data[4] = {0}; + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + STBI_NOTUSED(ri); + STBI_NOTUSED(tga_x_origin); // @TODO + STBI_NOTUSED(tga_y_origin); // @TODO + + // do a tiny bit of precessing + if (tga_image_type >= 8) { + tga_image_type -= 8; + tga_is_RLE = 1; + } + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + // If I'm paletted, then I'll use the number of bits from the palette + if (tga_indexed) + tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); + else + tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), + &tga_rgb16); + + if (!tga_comp) // shouldn't really happen, stbi__tga_test() should have + // ensured basic consistency + return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); + + // tga info + *x = tga_width; + *y = tga_height; + if (comp) + *comp = tga_comp; + + if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) + return stbi__errpuc("too large", "Corrupt TGA"); + + tga_data = + (unsigned char *)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); + if (!tga_data) + return stbi__errpuc("outofmem", "Out of memory"); + + // skip to the data's starting position (offset usually = 0) + stbi__skip(s, tga_offset); + + if (!tga_indexed && !tga_is_RLE && !tga_rgb16) { + for (i = 0; i < tga_height; ++i) { + int row = tga_inverted ? tga_height - i - 1 : i; + stbi_uc *tga_row = tga_data + row * tga_width * tga_comp; + stbi__getn(s, tga_row, tga_width * tga_comp); + } + } else { + // do I need to load a palette? + if (tga_indexed) { + // any data to skip? (offset usually = 0) + stbi__skip(s, tga_palette_start); + // load the palette + tga_palette = + (unsigned char *)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); + if (!tga_palette) { + STBI_FREE(tga_data); + return stbi__errpuc("outofmem", "Out of memory"); } - // do I need to invert the image? - if ( tga_inverted ) - { - for (j = 0; j*2 < tga_height; ++j) - { - int index1 = j * tga_width * tga_comp; - int index2 = (tga_height - 1 - j) * tga_width * tga_comp; - for (i = tga_width * tga_comp; i > 0; --i) - { - unsigned char temp = tga_data[index1]; - tga_data[index1] = tga_data[index2]; - tga_data[index2] = temp; - ++index1; - ++index2; - } - } + if (tga_rgb16) { + stbi_uc *pal_entry = tga_palette; + STBI_ASSERT(tga_comp == STBI_rgb); + for (i = 0; i < tga_palette_len; ++i) { + stbi__tga_read_rgb16(s, pal_entry); + pal_entry += tga_comp; + } + } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { + STBI_FREE(tga_data); + STBI_FREE(tga_palette); + return stbi__errpuc("bad palette", "Corrupt TGA"); } - // clear my palette, if I had one - if ( tga_palette != NULL ) - { - STBI_FREE( tga_palette ); + } + // load the data + for (i = 0; i < tga_width * tga_height; ++i) { + // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? + if (tga_is_RLE) { + if (RLE_count == 0) { + // yep, get the next byte as a RLE command + int RLE_cmd = stbi__get8(s); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } else if (!RLE_repeating) { + read_next_pixel = 1; + } + } else { + read_next_pixel = 1; } - } + // OK, if I need to read a pixel, do it now + if (read_next_pixel) { + // load however much data we did have + if (tga_indexed) { + // read in index, then perform the lookup + int pal_idx = + (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); + if (pal_idx >= tga_palette_len) { + // invalid index + pal_idx = 0; + } + pal_idx *= tga_comp; + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = tga_palette[pal_idx + j]; + } + } else if (tga_rgb16) { + STBI_ASSERT(tga_comp == STBI_rgb); + stbi__tga_read_rgb16(s, raw_data); + } else { + // read in the data raw + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = stbi__get8(s); + } + } + // clear the reading flag for the next pixel + read_next_pixel = 0; + } // end of reading a pixel - // swap RGB - if the source data was RGB16, it already is in the right order - if (tga_comp >= 3 && !tga_rgb16) - { - unsigned char* tga_pixel = tga_data; - for (i=0; i < tga_width * tga_height; ++i) - { - unsigned char temp = tga_pixel[0]; - tga_pixel[0] = tga_pixel[2]; - tga_pixel[2] = temp; - tga_pixel += tga_comp; + // copy data + for (j = 0; j < tga_comp; ++j) + tga_data[i * tga_comp + j] = raw_data[j]; + + // in case we're in RLE mode, keep counting down + --RLE_count; + } + // do I need to invert the image? + if (tga_inverted) { + for (j = 0; j * 2 < tga_height; ++j) { + int index1 = j * tga_width * tga_comp; + int index2 = (tga_height - 1 - j) * tga_width * tga_comp; + for (i = tga_width * tga_comp; i > 0; --i) { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } } - } + } + // clear my palette, if I had one + if (tga_palette != NULL) { + STBI_FREE(tga_palette); + } + } + + // swap RGB - if the source data was RGB16, it already is in the right order + if (tga_comp >= 3 && !tga_rgb16) { + unsigned char *tga_pixel = tga_data; + for (i = 0; i < tga_width * tga_height; ++i) { + unsigned char temp = tga_pixel[0]; + tga_pixel[0] = tga_pixel[2]; + tga_pixel[2] = temp; + tga_pixel += tga_comp; + } + } - // convert to target component count - if (req_comp && req_comp != tga_comp) - tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); + // convert to target component count + if (req_comp && req_comp != tga_comp) + tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, + tga_height); - // the things I do to get rid of an error message, and yet keep - // Microsoft's C compilers happy... [8^( - tga_palette_start = tga_palette_len = tga_palette_bits = - tga_x_origin = tga_y_origin = 0; - STBI_NOTUSED(tga_palette_start); - // OK, done - return tga_data; + // the things I do to get rid of an error message, and yet keep + // Microsoft's C compilers happy... [8^( + tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = + tga_y_origin = 0; + STBI_NOTUSED(tga_palette_start); + // OK, done + return tga_data; } #endif // ************************************************************************************************* -// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB +// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, +// tweaked by STB #ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s) -{ - int r = (stbi__get32be(s) == 0x38425053); - stbi__rewind(s); - return r; -} - -static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) -{ - int count, nleft, len; - - count = 0; - while ((nleft = pixelCount - count) > 0) { - len = stbi__get8(s); - if (len == 128) { - // No-op. - } else if (len < 128) { - // Copy next len+1 bytes literally. - len++; - if (len > nleft) return 0; // corrupt data - count += len; - while (len) { - *p = stbi__get8(s); - p += 4; - len--; - } - } else if (len > 128) { - stbi_uc val; - // Next -len+1 bytes in the dest are replicated from next source byte. - // (Interpret len as a negative 8-bit int.) - len = 257 - len; - if (len > nleft) return 0; // corrupt data - val = stbi__get8(s); - count += len; - while (len) { - *p = val; - p += 4; - len--; - } +static int stbi__psd_test(stbi__context *s) { + int r = (stbi__get32be(s) == 0x38425053); + stbi__rewind(s); + return r; +} + +static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) { + int count, nleft, len; + + count = 0; + while ((nleft = pixelCount - count) > 0) { + len = stbi__get8(s); + if (len == 128) { + // No-op. + } else if (len < 128) { + // Copy next len+1 bytes literally. + len++; + if (len > nleft) + return 0; // corrupt data + count += len; + while (len) { + *p = stbi__get8(s); + p += 4; + len--; } - } - - return 1; -} + } else if (len > 128) { + stbi_uc val; + // Next -len+1 bytes in the dest are replicated from next source byte. + // (Interpret len as a negative 8-bit int.) + len = 257 - len; + if (len > nleft) + return 0; // corrupt data + val = stbi__get8(s); + count += len; + while (len) { + *p = val; + p += 4; + len--; + } + } + } + + return 1; +} + +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri, int bpc) { + int pixelCount; + int channelCount, compression; + int channel, i; + int bitdepth; + int w, h; + stbi_uc *out; + STBI_NOTUSED(ri); + + // Check identifier + if (stbi__get32be(s) != 0x38425053) // "8BPS" + return stbi__errpuc("not PSD", "Corrupt PSD image"); + + // Check file type version. + if (stbi__get16be(s) != 1) + return stbi__errpuc("wrong version", "Unsupported version of PSD image"); + + // Skip 6 reserved bytes. + stbi__skip(s, 6); + + // Read the number of channels (R, G, B, A, etc). + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) + return stbi__errpuc("wrong channel count", + "Unsupported number of channels in PSD image"); + + // Read the rows and columns of the image. + h = stbi__get32be(s); + w = stbi__get32be(s); + + // Make sure the depth is 8 bits. + bitdepth = stbi__get16be(s); + if (bitdepth != 8 && bitdepth != 16) + return stbi__errpuc("unsupported bit depth", + "PSD bit depth is not 8 or 16 bit"); + + // Make sure the color mode is RGB. + // Valid options are: + // 0: Bitmap + // 1: Grayscale + // 2: Indexed color + // 3: RGB color + // 4: CMYK color + // 7: Multichannel + // 8: Duotone + // 9: Lab color + if (stbi__get16be(s) != 3) + return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); + + // Skip the Mode Data. (It's the palette for indexed color; other info for + // other modes.) + stbi__skip(s, stbi__get32be(s)); + + // Skip the image resources. (resolution, pen tool paths, etc) + stbi__skip(s, stbi__get32be(s)); + + // Skip the reserved data. + stbi__skip(s, stbi__get32be(s)); + + // Find out if the data is compressed. + // Known values: + // 0: no compression + // 1: RLE compressed + compression = stbi__get16be(s); + if (compression > 1) + return stbi__errpuc("bad compression", + "PSD has an unknown compression format"); + + // Check size + if (!stbi__mad3sizes_valid(4, w, h, 0)) + return stbi__errpuc("too large", "Corrupt PSD"); + + // Create the destination image. + + if (!compression && bitdepth == 16 && bpc == 16) { + out = (stbi_uc *)stbi__malloc_mad3(8, w, h, 0); + ri->bits_per_channel = 16; + } else + out = (stbi_uc *)stbi__malloc(4 * w * h); + + if (!out) + return stbi__errpuc("outofmem", "Out of memory"); + pixelCount = w * h; + + // Initialize the data to zero. + // memset( out, 0, pixelCount * 4 ); + + // Finally, the image data. + if (compression) { + // RLE as used by .PSD and .TIFF + // Loop until you get the number of unpacked bytes you are expecting: + // Read the next source byte into n. + // If n is between 0 and 127 inclusive, copy the next n+1 bytes + // literally. Else if n is between -127 and -1 inclusive, copy the next + // byte -n+1 times. Else if n is 128, noop. + // Endloop + + // The RLE-compressed data is preceded by a 2-byte data count for each row + // in the data, which we're going to just skip. + stbi__skip(s, h * channelCount * 2); + + // Read the RLE data by channel. + for (channel = 0; channel < 4; channel++) { + stbi_uc *p; + + p = out + channel; + if (channel >= channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++, p += 4) + *p = (channel == 3 ? 255 : 0); + } else { + // Read the RLE data. + if (!stbi__psd_decode_rle(s, p, pixelCount)) { + STBI_FREE(out); + return stbi__errpuc("corrupt", "bad RLE data"); + } + } + } -static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) -{ - int pixelCount; - int channelCount, compression; - int channel, i; - int bitdepth; - int w,h; - stbi_uc *out; - STBI_NOTUSED(ri); - - // Check identifier - if (stbi__get32be(s) != 0x38425053) // "8BPS" - return stbi__errpuc("not PSD", "Corrupt PSD image"); - - // Check file type version. - if (stbi__get16be(s) != 1) - return stbi__errpuc("wrong version", "Unsupported version of PSD image"); - - // Skip 6 reserved bytes. - stbi__skip(s, 6 ); - - // Read the number of channels (R, G, B, A, etc). - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) - return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); - - // Read the rows and columns of the image. - h = stbi__get32be(s); - w = stbi__get32be(s); - - // Make sure the depth is 8 bits. - bitdepth = stbi__get16be(s); - if (bitdepth != 8 && bitdepth != 16) - return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); - - // Make sure the color mode is RGB. - // Valid options are: - // 0: Bitmap - // 1: Grayscale - // 2: Indexed color - // 3: RGB color - // 4: CMYK color - // 7: Multichannel - // 8: Duotone - // 9: Lab color - if (stbi__get16be(s) != 3) - return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); - - // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) - stbi__skip(s,stbi__get32be(s) ); - - // Skip the image resources. (resolution, pen tool paths, etc) - stbi__skip(s, stbi__get32be(s) ); - - // Skip the reserved data. - stbi__skip(s, stbi__get32be(s) ); - - // Find out if the data is compressed. - // Known values: - // 0: no compression - // 1: RLE compressed - compression = stbi__get16be(s); - if (compression > 1) - return stbi__errpuc("bad compression", "PSD has an unknown compression format"); - - // Check size - if (!stbi__mad3sizes_valid(4, w, h, 0)) - return stbi__errpuc("too large", "Corrupt PSD"); - - // Create the destination image. - - if (!compression && bitdepth == 16 && bpc == 16) { - out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); - ri->bits_per_channel = 16; - } else - out = (stbi_uc *) stbi__malloc(4 * w*h); - - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - pixelCount = w*h; - - // Initialize the data to zero. - //memset( out, 0, pixelCount * 4 ); - - // Finally, the image data. - if (compression) { - // RLE as used by .PSD and .TIFF - // Loop until you get the number of unpacked bytes you are expecting: - // Read the next source byte into n. - // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. - // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. - // Else if n is 128, noop. - // Endloop - - // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, - // which we're going to just skip. - stbi__skip(s, h * channelCount * 2 ); - - // Read the RLE data by channel. - for (channel = 0; channel < 4; channel++) { - stbi_uc *p; - - p = out+channel; - if (channel >= channelCount) { - // Fill this channel with default data. + } else { + // We're at the raw image data. It's each channel in order (Red, Green, + // Blue, Alpha, ...) where each channel consists of an 8-bit (or 16-bit) + // value for each pixel in the image. + + // Read the data by channel. + for (channel = 0; channel < 4; channel++) { + if (channel >= channelCount) { + // Fill this channel with default data. + if (bitdepth == 16 && bpc == 16) { + stbi__uint16 *q = ((stbi__uint16 *)out) + channel; + stbi__uint16 val = channel == 3 ? 65535 : 0; + for (i = 0; i < pixelCount; i++, q += 4) + *q = val; + } else { + stbi_uc *p = out + channel; + stbi_uc val = channel == 3 ? 255 : 0; + for (i = 0; i < pixelCount; i++, p += 4) + *p = val; + } + } else { + if (ri->bits_per_channel == 16) { // output bpc + stbi__uint16 *q = ((stbi__uint16 *)out) + channel; + for (i = 0; i < pixelCount; i++, q += 4) + *q = (stbi__uint16)stbi__get16be(s); + } else { + stbi_uc *p = out + channel; + if (bitdepth == 16) { // input bpc for (i = 0; i < pixelCount; i++, p += 4) - *p = (channel == 3 ? 255 : 0); - } else { - // Read the RLE data. - if (!stbi__psd_decode_rle(s, p, pixelCount)) { - STBI_FREE(out); - return stbi__errpuc("corrupt", "bad RLE data"); - } - } + *p = (stbi_uc)(stbi__get16be(s) >> 8); + } else { + for (i = 0; i < pixelCount; i++, p += 4) + *p = stbi__get8(s); + } + } } - - } else { - // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) - // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. - - // Read the data by channel. - for (channel = 0; channel < 4; channel++) { - if (channel >= channelCount) { - // Fill this channel with default data. - if (bitdepth == 16 && bpc == 16) { - stbi__uint16 *q = ((stbi__uint16 *) out) + channel; - stbi__uint16 val = channel == 3 ? 65535 : 0; - for (i = 0; i < pixelCount; i++, q += 4) - *q = val; - } else { - stbi_uc *p = out+channel; - stbi_uc val = channel == 3 ? 255 : 0; - for (i = 0; i < pixelCount; i++, p += 4) - *p = val; - } - } else { - if (ri->bits_per_channel == 16) { // output bpc - stbi__uint16 *q = ((stbi__uint16 *) out) + channel; - for (i = 0; i < pixelCount; i++, q += 4) - *q = (stbi__uint16) stbi__get16be(s); - } else { - stbi_uc *p = out+channel; - if (bitdepth == 16) { // input bpc - for (i = 0; i < pixelCount; i++, p += 4) - *p = (stbi_uc) (stbi__get16be(s) >> 8); - } else { - for (i = 0; i < pixelCount; i++, p += 4) - *p = stbi__get8(s); - } - } - } + } + } + + // remove weird white matte from PSD + if (channelCount >= 4) { + if (ri->bits_per_channel == 16) { + for (i = 0; i < w * h; ++i) { + stbi__uint16 *pixel = (stbi__uint16 *)out + 4 * i; + if (pixel[3] != 0 && pixel[3] != 65535) { + float a = pixel[3] / 65535.0f; + float ra = 1.0f / a; + float inv_a = 65535.0f * (1 - ra); + pixel[0] = (stbi__uint16)(pixel[0] * ra + inv_a); + pixel[1] = (stbi__uint16)(pixel[1] * ra + inv_a); + pixel[2] = (stbi__uint16)(pixel[2] * ra + inv_a); + } } - } - - // remove weird white matte from PSD - if (channelCount >= 4) { - if (ri->bits_per_channel == 16) { - for (i=0; i < w*h; ++i) { - stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; - if (pixel[3] != 0 && pixel[3] != 65535) { - float a = pixel[3] / 65535.0f; - float ra = 1.0f / a; - float inv_a = 65535.0f * (1 - ra); - pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); - pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); - pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); - } - } - } else { - for (i=0; i < w*h; ++i) { - unsigned char *pixel = out + 4*i; - if (pixel[3] != 0 && pixel[3] != 255) { - float a = pixel[3] / 255.0f; - float ra = 1.0f / a; - float inv_a = 255.0f * (1 - ra); - pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); - pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); - pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); - } - } + } else { + for (i = 0; i < w * h; ++i) { + unsigned char *pixel = out + 4 * i; + if (pixel[3] != 0 && pixel[3] != 255) { + float a = pixel[3] / 255.0f; + float ra = 1.0f / a; + float inv_a = 255.0f * (1 - ra); + pixel[0] = (unsigned char)(pixel[0] * ra + inv_a); + pixel[1] = (unsigned char)(pixel[1] * ra + inv_a); + pixel[2] = (unsigned char)(pixel[2] * ra + inv_a); + } } - } - - // convert to desired output format - if (req_comp && req_comp != 4) { - if (ri->bits_per_channel == 16) - out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); - else - out = stbi__convert_format(out, 4, req_comp, w, h); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - - if (comp) *comp = 4; - *y = h; - *x = w; - - return out; + } + } + + // convert to desired output format + if (req_comp && req_comp != 4) { + if (ri->bits_per_channel == 16) + out = (stbi_uc *)stbi__convert_format16((stbi__uint16 *)out, 4, req_comp, + w, h); + else + out = stbi__convert_format(out, 4, req_comp, w, h); + if (out == NULL) + return out; // stbi__convert_format frees input on failure + } + + if (comp) + *comp = 4; + *y = h; + *x = w; + + return out; } #endif @@ -5978,211 +6646,216 @@ static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ #ifndef STBI_NO_PIC -static int stbi__pic_is4(stbi__context *s,const char *str) -{ - int i; - for (i=0; i<4; ++i) - if (stbi__get8(s) != (stbi_uc)str[i]) - return 0; +static int stbi__pic_is4(stbi__context *s, const char *str) { + int i; + for (i = 0; i < 4; ++i) + if (stbi__get8(s) != (stbi_uc)str[i]) + return 0; - return 1; + return 1; } -static int stbi__pic_test_core(stbi__context *s) -{ - int i; +static int stbi__pic_test_core(stbi__context *s) { + int i; - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) - return 0; + if (!stbi__pic_is4(s, "\x53\x80\xF6\x34")) + return 0; - for(i=0;i<84;++i) - stbi__get8(s); + for (i = 0; i < 84; ++i) + stbi__get8(s); - if (!stbi__pic_is4(s,"PICT")) - return 0; + if (!stbi__pic_is4(s, "PICT")) + return 0; - return 1; + return 1; } -typedef struct -{ - stbi_uc size,type,channel; +typedef struct { + stbi_uc size, type, channel; } stbi__pic_packet; -static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) -{ - int mask=0x80, i; +static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { + int mask = 0x80, i; - for (i=0; i<4; ++i, mask>>=1) { - if (channel & mask) { - if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); - dest[i]=stbi__get8(s); - } - } + for (i = 0; i < 4; ++i, mask >>= 1) { + if (channel & mask) { + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "PIC file too short"); + dest[i] = stbi__get8(s); + } + } - return dest; + return dest; } -static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) -{ - int mask=0x80,i; +static void stbi__copyval(int channel, stbi_uc *dest, const stbi_uc *src) { + int mask = 0x80, i; - for (i=0;i<4; ++i, mask>>=1) - if (channel&mask) - dest[i]=src[i]; + for (i = 0; i < 4; ++i, mask >>= 1) + if (channel & mask) + dest[i] = src[i]; } -static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) -{ - int act_comp=0,num_packets=0,y,chained; - stbi__pic_packet packets[10]; +static stbi_uc *stbi__pic_load_core(stbi__context *s, int width, int height, + int *comp, stbi_uc *result) { + int act_comp = 0, num_packets = 0, y, chained; + stbi__pic_packet packets[10]; - // this will (should...) cater for even some bizarre stuff like having data - // for the same channel in multiple packets. - do { - stbi__pic_packet *packet; + // this will (should...) cater for even some bizarre stuff like having data + // for the same channel in multiple packets. + do { + stbi__pic_packet *packet; - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return stbi__errpuc("bad format","too many packets"); + if (num_packets == sizeof(packets) / sizeof(packets[0])) + return stbi__errpuc("bad format", "too many packets"); - packet = &packets[num_packets++]; + packet = &packets[num_packets++]; - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); - act_comp |= packet->channel; + act_comp |= packet->channel; - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); - if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); - } while (chained); + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "file too short (reading packets)"); + if (packet->size != 8) + return stbi__errpuc("bad format", "packet isn't 8bpp"); + } while (chained); - *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? + *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? - for(y=0; ytype) { - default: - return stbi__errpuc("bad format","packet has bad compression type"); + switch (packet->type) { + default: + return stbi__errpuc("bad format", "packet has bad compression type"); - case 0: {//uncompressed - int x; + case 0: { // uncompressed + int x; - for(x=0;xchannel,dest)) - return 0; - break; - } + for (x = 0; x < width; ++x, dest += 4) + if (!stbi__readval(s, packet->channel, dest)) + return 0; + break; + } - case 1://Pure RLE - { - int left=width, i; - - while (left>0) { - stbi_uc count,value[4]; - - count=stbi__get8(s); - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); - - if (count > left) - count = (stbi_uc) left; - - if (!stbi__readval(s,packet->channel,value)) return 0; - - for(i=0; ichannel,dest,value); - left -= count; - } - } - break; - - case 2: {//Mixed RLE - int left=width; - while (left>0) { - int count = stbi__get8(s), i; - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); - - if (count >= 128) { // Repeated - stbi_uc value[4]; - - if (count==128) - count = stbi__get16be(s); - else - count -= 127; - if (count > left) - return stbi__errpuc("bad file","scanline overrun"); - - if (!stbi__readval(s,packet->channel,value)) - return 0; - - for(i=0;ichannel,dest,value); - } else { // Raw - ++count; - if (count>left) return stbi__errpuc("bad file","scanline overrun"); - - for(i=0;ichannel,dest)) - return 0; - } - left-=count; - } - break; - } - } + case 1: // Pure RLE + { + int left = width, i; + + while (left > 0) { + stbi_uc count, value[4]; + + count = stbi__get8(s); + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "file too short (pure read count)"); + + if (count > left) + count = (stbi_uc)left; + + if (!stbi__readval(s, packet->channel, value)) + return 0; + + for (i = 0; i < count; ++i, dest += 4) + stbi__copyval(packet->channel, dest, value); + left -= count; + } + } break; + + case 2: { // Mixed RLE + int left = width; + while (left > 0) { + int count = stbi__get8(s), i; + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", + "file too short (mixed read count)"); + + if (count >= 128) { // Repeated + stbi_uc value[4]; + + if (count == 128) + count = stbi__get16be(s); + else + count -= 127; + if (count > left) + return stbi__errpuc("bad file", "scanline overrun"); + + if (!stbi__readval(s, packet->channel, value)) + return 0; + + for (i = 0; i < count; ++i, dest += 4) + stbi__copyval(packet->channel, dest, value); + } else { // Raw + ++count; + if (count > left) + return stbi__errpuc("bad file", "scanline overrun"); + + for (i = 0; i < count; ++i, dest += 4) + if (!stbi__readval(s, packet->channel, dest)) + return 0; + } + left -= count; + } + break; } - } + } + } + } - return result; + return result; } -static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) -{ - stbi_uc *result; - int i, x,y, internal_comp; - STBI_NOTUSED(ri); +static void *stbi__pic_load(stbi__context *s, int *px, int *py, int *comp, + int req_comp, stbi__result_info *ri) { + stbi_uc *result; + int i, x, y, internal_comp; + STBI_NOTUSED(ri); - if (!comp) comp = &internal_comp; + if (!comp) + comp = &internal_comp; - for (i=0; i<92; ++i) - stbi__get8(s); + for (i = 0; i < 92; ++i) + stbi__get8(s); - x = stbi__get16be(s); - y = stbi__get16be(s); - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); - if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); + x = stbi__get16be(s); + y = stbi__get16be(s); + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "file too short (pic header)"); + if (!stbi__mad3sizes_valid(x, y, 4, 0)) + return stbi__errpuc("too large", "PIC image too large to decode"); - stbi__get32be(s); //skip `ratio' - stbi__get16be(s); //skip `fields' - stbi__get16be(s); //skip `pad' + stbi__get32be(s); // skip `ratio' + stbi__get16be(s); // skip `fields' + stbi__get16be(s); // skip `pad' - // intermediate buffer is RGBA - result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); - memset(result, 0xff, x*y*4); + // intermediate buffer is RGBA + result = (stbi_uc *)stbi__malloc_mad3(x, y, 4, 0); + memset(result, 0xff, x * y * 4); - if (!stbi__pic_load_core(s,x,y,comp, result)) { - STBI_FREE(result); - result=0; - } - *px = x; - *py = y; - if (req_comp == 0) req_comp = *comp; - result=stbi__convert_format(result,4,req_comp,x,y); + if (!stbi__pic_load_core(s, x, y, comp, result)) { + STBI_FREE(result); + result = 0; + } + *px = x; + *py = y; + if (req_comp == 0) + req_comp = *comp; + result = stbi__convert_format(result, 4, req_comp, x, y); - return result; + return result; } -static int stbi__pic_test(stbi__context *s) -{ - int r = stbi__pic_test_core(s); - stbi__rewind(s); - return r; +static int stbi__pic_test(stbi__context *s) { + int r = stbi__pic_test_core(s); + stbi__rewind(s); + return r; } #endif @@ -6190,495 +6863,517 @@ static int stbi__pic_test(stbi__context *s) // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb #ifndef STBI_NO_GIF -typedef struct -{ - stbi__int16 prefix; - stbi_uc first; - stbi_uc suffix; +typedef struct { + stbi__int16 prefix; + stbi_uc first; + stbi_uc suffix; } stbi__gif_lzw; -typedef struct -{ - int w,h; - stbi_uc *out; // output buffer (always 4 components) - stbi_uc *background; // The current "background" as far as a gif is concerned - stbi_uc *history; - int flags, bgindex, ratio, transparent, eflags; - stbi_uc pal[256][4]; - stbi_uc lpal[256][4]; - stbi__gif_lzw codes[8192]; - stbi_uc *color_table; - int parse, step; - int lflags; - int start_x, start_y; - int max_x, max_y; - int cur_x, cur_y; - int line_size; - int delay; +typedef struct { + int w, h; + stbi_uc *out; // output buffer (always 4 components) + stbi_uc *background; // The current "background" as far as a gif is concerned + stbi_uc *history; + int flags, bgindex, ratio, transparent, eflags; + stbi_uc pal[256][4]; + stbi_uc lpal[256][4]; + stbi__gif_lzw codes[8192]; + stbi_uc *color_table; + int parse, step; + int lflags; + int start_x, start_y; + int max_x, max_y; + int cur_x, cur_y; + int line_size; + int delay; } stbi__gif; -static int stbi__gif_test_raw(stbi__context *s) -{ - int sz; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; - sz = stbi__get8(s); - if (sz != '9' && sz != '7') return 0; - if (stbi__get8(s) != 'a') return 0; - return 1; -} - -static int stbi__gif_test(stbi__context *s) -{ - int r = stbi__gif_test_raw(s); - stbi__rewind(s); - return r; -} +static int stbi__gif_test_raw(stbi__context *s) { + int sz; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || + stbi__get8(s) != '8') + return 0; + sz = stbi__get8(s); + if (sz != '9' && sz != '7') + return 0; + if (stbi__get8(s) != 'a') + return 0; + return 1; +} + +static int stbi__gif_test(stbi__context *s) { + int r = stbi__gif_test_raw(s); + stbi__rewind(s); + return r; +} + +static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], + int num_entries, int transp) { + int i; + for (i = 0; i < num_entries; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + pal[i][3] = transp == i ? 0 : 255; + } +} + +static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, + int is_info) { + stbi_uc version; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || + stbi__get8(s) != '8') + return stbi__err("not GIF", "Corrupt GIF"); + + version = stbi__get8(s); + if (version != '7' && version != '9') + return stbi__err("not GIF", "Corrupt GIF"); + if (stbi__get8(s) != 'a') + return stbi__err("not GIF", "Corrupt GIF"); + + stbi__g_failure_reason = ""; + g->w = stbi__get16le(s); + g->h = stbi__get16le(s); + g->flags = stbi__get8(s); + g->bgindex = stbi__get8(s); + g->ratio = stbi__get8(s); + g->transparent = -1; + + if (comp != 0) + *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the + // comments + + if (is_info) + return 1; + + if (g->flags & 0x80) + stbi__gif_parse_colortable(s, g->pal, 2 << (g->flags & 7), -1); + + return 1; +} + +static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { + stbi__gif *g = (stbi__gif *)stbi__malloc(sizeof(stbi__gif)); + if (!stbi__gif_header(s, g, comp, 1)) { + STBI_FREE(g); + stbi__rewind(s); + return 0; + } + if (x) + *x = g->w; + if (y) + *y = g->h; + STBI_FREE(g); + return 1; +} + +static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { + stbi_uc *p, *c; + int idx; + + // recurse to decode the prefixes, since the linked-list is backwards, + // and working backwards through an interleaved image would be nasty + if (g->codes[code].prefix >= 0) + stbi__out_gif_code(g, g->codes[code].prefix); + + if (g->cur_y >= g->max_y) + return; + + idx = g->cur_x + g->cur_y; + p = &g->out[idx]; + g->history[idx / 4] = 1; + + c = &g->color_table[g->codes[code].suffix * 4]; + if (c[3] > 128) { // don't render transparent pixels; + p[0] = c[2]; + p[1] = c[1]; + p[2] = c[0]; + p[3] = c[3]; + } + g->cur_x += 4; + + if (g->cur_x >= g->max_x) { + g->cur_x = g->start_x; + g->cur_y += g->step; + + while (g->cur_y >= g->max_y && g->parse > 0) { + g->step = (1 << g->parse) * g->line_size; + g->cur_y = g->start_y + (g->step >> 1); + --g->parse; + } + } +} + +static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { + stbi_uc lzw_cs; + stbi__int32 len, init_code; + stbi__uint32 first; + stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; + stbi__gif_lzw *p; + + lzw_cs = stbi__get8(s); + if (lzw_cs > 12) + return NULL; + clear = 1 << lzw_cs; + first = 1; + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + bits = 0; + valid_bits = 0; + for (init_code = 0; init_code < clear; init_code++) { + g->codes[init_code].prefix = -1; + g->codes[init_code].first = (stbi_uc)init_code; + g->codes[init_code].suffix = (stbi_uc)init_code; + } + + // support no starting clear code + avail = clear + 2; + oldcode = -1; + + len = 0; + for (;;) { + if (valid_bits < codesize) { + if (len == 0) { + len = stbi__get8(s); // start new block + if (len == 0) + return g->out; + } + --len; + bits |= (stbi__int32)stbi__get8(s) << valid_bits; + valid_bits += 8; + } else { + stbi__int32 code = bits & codemask; + bits >>= codesize; + valid_bits -= codesize; + // @OPTIMIZE: is there some way we can accelerate the non-clear path? + if (code == clear) { // clear code + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + avail = clear + 2; + oldcode = -1; + first = 0; + } else if (code == clear + 1) { // end of stream code + stbi__skip(s, len); + while ((len = stbi__get8(s)) > 0) + stbi__skip(s, len); + return g->out; + } else if (code <= avail) { + if (first) { + return stbi__errpuc("no clear code", "Corrupt GIF"); + } -static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) -{ - int i; - for (i=0; i < num_entries; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - pal[i][3] = transp == i ? 0 : 255; - } -} + if (oldcode >= 0) { + p = &g->codes[avail++]; + if (avail > 8192) { + return stbi__errpuc("too many codes", "Corrupt GIF"); + } -static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) -{ - stbi_uc version; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') - return stbi__err("not GIF", "Corrupt GIF"); + p->prefix = (stbi__int16)oldcode; + p->first = g->codes[oldcode].first; + p->suffix = (code == avail) ? p->first : g->codes[code].first; + } else if (code == avail) + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - version = stbi__get8(s); - if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); - if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); + stbi__out_gif_code(g, (stbi__uint16)code); - stbi__g_failure_reason = ""; - g->w = stbi__get16le(s); - g->h = stbi__get16le(s); - g->flags = stbi__get8(s); - g->bgindex = stbi__get8(s); - g->ratio = stbi__get8(s); - g->transparent = -1; + if ((avail & codemask) == 0 && avail <= 0x0FFF) { + codesize++; + codemask = (1 << codesize) - 1; + } - if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments + oldcode = code; + } else { + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + } + } + } +} + +// this function is designed to support animated gifs, although stb_image +// doesn't support it two back is the image from two frames ago, used for a very +// specific disposal format +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, + int req_comp, stbi_uc *two_back) { + int dispose; + int first_frame; + int pi; + int pcount; + STBI_NOTUSED(req_comp); + + // on first frame, any non-written pixels get the background colour + // (non-transparent) + first_frame = 0; + if (g->out == 0) { + if (!stbi__gif_header(s, g, comp, 0)) + return 0; // stbi__g_failure_reason set by stbi__gif_header + if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) + return stbi__errpuc("too large", "GIF image is too large"); + pcount = g->w * g->h; + g->out = (stbi_uc *)stbi__malloc(4 * pcount); + g->background = (stbi_uc *)stbi__malloc(4 * pcount); + g->history = (stbi_uc *)stbi__malloc(pcount); + if (!g->out || !g->background || !g->history) + return stbi__errpuc("outofmem", "Out of memory"); - if (is_info) return 1; + // image is treated as "transparent" at the start - ie, nothing overwrites + // the current background; background colour is only used for pixels that + // are not rendered first frame, after that "background" color refers to the + // color that was there the previous frame. + memset(g->out, 0x00, 4 * pcount); + memset(g->background, 0x00, + 4 * pcount); // state of the background (starts transparent) + memset(g->history, 0x00, + pcount); // pixels that were affected previous frame + first_frame = 1; + } else { + // second frame - how do we dispoase of the previous one? + dispose = (g->eflags & 0x1C) >> 2; + pcount = g->w * g->h; + + if ((dispose == 3) && (two_back == 0)) { + dispose = 2; // if I don't have an image to revert back to, default to the + // old background + } - if (g->flags & 0x80) - stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); + if (dispose == 3) { // use previous graphic + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy(&g->out[pi * 4], &two_back[pi * 4], 4); + } + } + } else if (dispose == 2) { + // restore what was changed last frame to background before that frame; + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy(&g->out[pi * 4], &g->background[pi * 4], 4); + } + } + } else { + // This is a non-disposal case eithe way, so just + // leave the pixels as is, and they will become the new background + // 1: do not dispose + // 0: not specified. + } - return 1; -} + // background is what out is after the undoing of the previou frame; + memcpy(g->background, g->out, 4 * g->w * g->h); + } + + // clear my history; + memset(g->history, 0x00, + g->w * g->h); // pixels that were affected previous frame + + for (;;) { + int tag = stbi__get8(s); + switch (tag) { + case 0x2C: /* Image Descriptor */ + { + stbi__int32 x, y, w, h; + stbi_uc *o; + + x = stbi__get16le(s); + y = stbi__get16le(s); + w = stbi__get16le(s); + h = stbi__get16le(s); + if (((x + w) > (g->w)) || ((y + h) > (g->h))) + return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); + + g->line_size = g->w * 4; + g->start_x = x * 4; + g->start_y = y * g->line_size; + g->max_x = g->start_x + w * 4; + g->max_y = g->start_y + h * g->line_size; + g->cur_x = g->start_x; + g->cur_y = g->start_y; -static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); - if (!stbi__gif_header(s, g, comp, 1)) { - STBI_FREE(g); - stbi__rewind( s ); - return 0; - } - if (x) *x = g->w; - if (y) *y = g->h; - STBI_FREE(g); - return 1; -} + // if the width of the specified rectangle is 0, that means + // we may not see *any* pixels or the image is malformed; + // to make sure this is caught, move the current y down to + // max_y (which is what out_gif_code checks). + if (w == 0) + g->cur_y = g->max_y; -static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) -{ - stbi_uc *p, *c; - int idx; - - // recurse to decode the prefixes, since the linked-list is backwards, - // and working backwards through an interleaved image would be nasty - if (g->codes[code].prefix >= 0) - stbi__out_gif_code(g, g->codes[code].prefix); - - if (g->cur_y >= g->max_y) return; - - idx = g->cur_x + g->cur_y; - p = &g->out[idx]; - g->history[idx / 4] = 1; - - c = &g->color_table[g->codes[code].suffix * 4]; - if (c[3] > 128) { // don't render transparent pixels; - p[0] = c[2]; - p[1] = c[1]; - p[2] = c[0]; - p[3] = c[3]; - } - g->cur_x += 4; - - if (g->cur_x >= g->max_x) { - g->cur_x = g->start_x; - g->cur_y += g->step; + g->lflags = stbi__get8(s); - while (g->cur_y >= g->max_y && g->parse > 0) { - g->step = (1 << g->parse) * g->line_size; - g->cur_y = g->start_y + (g->step >> 1); - --g->parse; + if (g->lflags & 0x40) { + g->step = 8 * g->line_size; // first interlaced spacing + g->parse = 3; + } else { + g->step = g->line_size; + g->parse = 0; } - } -} -static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) -{ - stbi_uc lzw_cs; - stbi__int32 len, init_code; - stbi__uint32 first; - stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; - stbi__gif_lzw *p; - - lzw_cs = stbi__get8(s); - if (lzw_cs > 12) return NULL; - clear = 1 << lzw_cs; - first = 1; - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - bits = 0; - valid_bits = 0; - for (init_code = 0; init_code < clear; init_code++) { - g->codes[init_code].prefix = -1; - g->codes[init_code].first = (stbi_uc) init_code; - g->codes[init_code].suffix = (stbi_uc) init_code; - } - - // support no starting clear code - avail = clear+2; - oldcode = -1; - - len = 0; - for(;;) { - if (valid_bits < codesize) { - if (len == 0) { - len = stbi__get8(s); // start new block - if (len == 0) - return g->out; - } - --len; - bits |= (stbi__int32) stbi__get8(s) << valid_bits; - valid_bits += 8; - } else { - stbi__int32 code = bits & codemask; - bits >>= codesize; - valid_bits -= codesize; - // @OPTIMIZE: is there some way we can accelerate the non-clear path? - if (code == clear) { // clear code - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - avail = clear + 2; - oldcode = -1; - first = 0; - } else if (code == clear + 1) { // end of stream code - stbi__skip(s, len); - while ((len = stbi__get8(s)) > 0) - stbi__skip(s,len); - return g->out; - } else if (code <= avail) { - if (first) { - return stbi__errpuc("no clear code", "Corrupt GIF"); - } + if (g->lflags & 0x80) { + stbi__gif_parse_colortable(s, g->lpal, 2 << (g->lflags & 7), + g->eflags & 0x01 ? g->transparent : -1); + g->color_table = (stbi_uc *)g->lpal; + } else if (g->flags & 0x80) { + g->color_table = (stbi_uc *)g->pal; + } else + return stbi__errpuc("missing color table", "Corrupt GIF"); - if (oldcode >= 0) { - p = &g->codes[avail++]; - if (avail > 8192) { - return stbi__errpuc("too many codes", "Corrupt GIF"); - } + o = stbi__process_gif_raster(s, g); + if (!o) + return NULL; - p->prefix = (stbi__int16) oldcode; - p->first = g->codes[oldcode].first; - p->suffix = (code == avail) ? p->first : g->codes[code].first; - } else if (code == avail) - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + // if this was the first frame, + pcount = g->w * g->h; + if (first_frame && (g->bgindex > 0)) { + // if first frame, any pixel not drawn to gets the background color + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi] == 0) { + g->pal[g->bgindex][3] = + 255; // just in case it was made transparent, undo that; It will + // be reset next frame if need be; + memcpy(&g->out[pi * 4], &g->pal[g->bgindex], 4); + } + } + } - stbi__out_gif_code(g, (stbi__uint16) code); + return o; + } - if ((avail & codemask) == 0 && avail <= 0x0FFF) { - codesize++; - codemask = (1 << codesize) - 1; + case 0x21: // Comment Extension. + { + int len; + int ext = stbi__get8(s); + if (ext == 0xF9) { // Graphic Control Extension. + len = stbi__get8(s); + if (len == 4) { + g->eflags = stbi__get8(s); + g->delay = + 10 * stbi__get16le( + s); // delay - 1/100th of a second, saving as 1/1000ths. + + // unset old transparent + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 255; + } + if (g->eflags & 0x01) { + g->transparent = stbi__get8(s); + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 0; } - - oldcode = code; - } else { - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - } + } else { + // don't need transparent + stbi__skip(s, 1); + g->transparent = -1; + } + } else { + stbi__skip(s, len); + break; + } } - } -} - -// this function is designed to support animated gifs, although stb_image doesn't support it -// two back is the image from two frames ago, used for a very specific disposal format -static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) -{ - int dispose; - int first_frame; - int pi; - int pcount; - STBI_NOTUSED(req_comp); - - // on first frame, any non-written pixels get the background colour (non-transparent) - first_frame = 0; - if (g->out == 0) { - if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header - if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) - return stbi__errpuc("too large", "GIF image is too large"); - pcount = g->w * g->h; - g->out = (stbi_uc *) stbi__malloc(4 * pcount); - g->background = (stbi_uc *) stbi__malloc(4 * pcount); - g->history = (stbi_uc *) stbi__malloc(pcount); - if (!g->out || !g->background || !g->history) - return stbi__errpuc("outofmem", "Out of memory"); - - // image is treated as "transparent" at the start - ie, nothing overwrites the current background; - // background colour is only used for pixels that are not rendered first frame, after that "background" - // color refers to the color that was there the previous frame. - memset(g->out, 0x00, 4 * pcount); - memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) - memset(g->history, 0x00, pcount); // pixels that were affected previous frame - first_frame = 1; - } else { - // second frame - how do we dispoase of the previous one? - dispose = (g->eflags & 0x1C) >> 2; - pcount = g->w * g->h; - - if ((dispose == 3) && (two_back == 0)) { - dispose = 2; // if I don't have an image to revert back to, default to the old background + while ((len = stbi__get8(s)) != 0) { + stbi__skip(s, len); } + break; + } - if (dispose == 3) { // use previous graphic - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi]) { - memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); - } - } - } else if (dispose == 2) { - // restore what was changed last frame to background before that frame; - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi]) { - memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); - } - } - } else { - // This is a non-disposal case eithe way, so just - // leave the pixels as is, and they will become the new background - // 1: do not dispose - // 0: not specified. - } + case 0x3B: // gif stream termination code + return (stbi_uc *)s; // using '1' causes warning on some compilers - // background is what out is after the undoing of the previou frame; - memcpy( g->background, g->out, 4 * g->w * g->h ); - } - - // clear my history; - memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame - - for (;;) { - int tag = stbi__get8(s); - switch (tag) { - case 0x2C: /* Image Descriptor */ - { - stbi__int32 x, y, w, h; - stbi_uc *o; - - x = stbi__get16le(s); - y = stbi__get16le(s); - w = stbi__get16le(s); - h = stbi__get16le(s); - if (((x + w) > (g->w)) || ((y + h) > (g->h))) - return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); - - g->line_size = g->w * 4; - g->start_x = x * 4; - g->start_y = y * g->line_size; - g->max_x = g->start_x + w * 4; - g->max_y = g->start_y + h * g->line_size; - g->cur_x = g->start_x; - g->cur_y = g->start_y; - - // if the width of the specified rectangle is 0, that means - // we may not see *any* pixels or the image is malformed; - // to make sure this is caught, move the current y down to - // max_y (which is what out_gif_code checks). - if (w == 0) - g->cur_y = g->max_y; - - g->lflags = stbi__get8(s); - - if (g->lflags & 0x40) { - g->step = 8 * g->line_size; // first interlaced spacing - g->parse = 3; - } else { - g->step = g->line_size; - g->parse = 0; - } + default: + return stbi__errpuc("unknown code", "Corrupt GIF"); + } + } +} + +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, + int *z, int *comp, int req_comp) { + if (stbi__gif_test(s)) { + int layers = 0; + stbi_uc *u = 0; + stbi_uc *out = 0; + stbi_uc *two_back = 0; + stbi__gif g; + int stride; + memset(&g, 0, sizeof(g)); + if (delays) { + *delays = 0; + } - if (g->lflags & 0x80) { - stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); - g->color_table = (stbi_uc *) g->lpal; - } else if (g->flags & 0x80) { - g->color_table = (stbi_uc *) g->pal; - } else - return stbi__errpuc("missing color table", "Corrupt GIF"); - - o = stbi__process_gif_raster(s, g); - if (!o) return NULL; - - // if this was the first frame, - pcount = g->w * g->h; - if (first_frame && (g->bgindex > 0)) { - // if first frame, any pixel not drawn to gets the background color - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi] == 0) { - g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; - memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); - } - } - } + do { + u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); + if (u == (stbi_uc *)s) + u = 0; // end of animated gif marker + + if (u) { + *x = g.w; + *y = g.h; + ++layers; + stride = g.w * g.h * 4; + + if (out) { + out = (stbi_uc *)STBI_REALLOC(out, layers * stride); + if (delays) { + *delays = (int *)STBI_REALLOC(*delays, sizeof(int) * layers); + } + } else { + out = (stbi_uc *)stbi__malloc(layers * stride); + if (delays) { + *delays = (int *)stbi__malloc(layers * sizeof(int)); + } + } + memcpy(out + ((layers - 1) * stride), u, stride); + if (layers >= 2) { + two_back = out - 2 * stride; + } - return o; - } - - case 0x21: // Comment Extension. - { - int len; - int ext = stbi__get8(s); - if (ext == 0xF9) { // Graphic Control Extension. - len = stbi__get8(s); - if (len == 4) { - g->eflags = stbi__get8(s); - g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. - - // unset old transparent - if (g->transparent >= 0) { - g->pal[g->transparent][3] = 255; - } - if (g->eflags & 0x01) { - g->transparent = stbi__get8(s); - if (g->transparent >= 0) { - g->pal[g->transparent][3] = 0; - } - } else { - // don't need transparent - stbi__skip(s, 1); - g->transparent = -1; - } - } else { - stbi__skip(s, len); - break; - } - } - while ((len = stbi__get8(s)) != 0) { - stbi__skip(s, len); - } - break; - } + if (delays) { + (*delays)[layers - 1U] = g.delay; + } + } + } while (u != 0); - case 0x3B: // gif stream termination code - return (stbi_uc *) s; // using '1' causes warning on some compilers + // free temp buffer; + STBI_FREE(g.out); + STBI_FREE(g.history); + STBI_FREE(g.background); - default: - return stbi__errpuc("unknown code", "Corrupt GIF"); - } - } -} + // do the final conversion after loading everything; + if (req_comp && req_comp != 4) + out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); -static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) -{ - if (stbi__gif_test(s)) { - int layers = 0; - stbi_uc *u = 0; - stbi_uc *out = 0; - stbi_uc *two_back = 0; - stbi__gif g; - int stride; - memset(&g, 0, sizeof(g)); - if (delays) { - *delays = 0; - } + *z = layers; + return out; + } else { + return stbi__errpuc("not GIF", "Image was not as a gif type."); + } +} - do { - u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); - if (u == (stbi_uc *) s) u = 0; // end of animated gif marker - - if (u) { - *x = g.w; - *y = g.h; - ++layers; - stride = g.w * g.h * 4; - - if (out) { - out = (stbi_uc*) STBI_REALLOC( out, layers * stride ); - if (delays) { - *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers ); - } - } else { - out = (stbi_uc*)stbi__malloc( layers * stride ); - if (delays) { - *delays = (int*) stbi__malloc( layers * sizeof(int) ); - } - } - memcpy( out + ((layers - 1) * stride), u, stride ); - if (layers >= 2) { - two_back = out - 2 * stride; - } +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri) { + stbi_uc *u = 0; + stbi__gif g; + memset(&g, 0, sizeof(g)); + STBI_NOTUSED(ri); - if (delays) { - (*delays)[layers - 1U] = g.delay; - } - } - } while (u != 0); + u = stbi__gif_load_next(s, &g, comp, req_comp, 0); + if (u == (stbi_uc *)s) + u = 0; // end of animated gif marker + if (u) { + *x = g.w; + *y = g.h; - // free temp buffer; - STBI_FREE(g.out); - STBI_FREE(g.history); - STBI_FREE(g.background); + // moved conversion to after successful load so that the same + // can be done for multiple frames. + if (req_comp && req_comp != 4) + u = stbi__convert_format(u, 4, req_comp, g.w, g.h); + } else if (g.out) { + // if there was an error and we allocated an image buffer, free it! + STBI_FREE(g.out); + } - // do the final conversion after loading everything; - if (req_comp && req_comp != 4) - out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); + // free buffers needed for multiple frame loading; + STBI_FREE(g.history); + STBI_FREE(g.background); - *z = layers; - return out; - } else { - return stbi__errpuc("not GIF", "Image was not as a gif type."); - } + return u; } -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *u = 0; - stbi__gif g; - memset(&g, 0, sizeof(g)); - STBI_NOTUSED(ri); - - u = stbi__gif_load_next(s, &g, comp, req_comp, 0); - if (u == (stbi_uc *) s) u = 0; // end of animated gif marker - if (u) { - *x = g.w; - *y = g.h; - - // moved conversion to after successful load so that the same - // can be done for multiple frames. - if (req_comp && req_comp != 4) - u = stbi__convert_format(u, 4, req_comp, g.w, g.h); - } else if (g.out) { - // if there was an error and we allocated an image buffer, free it! - STBI_FREE(g.out); - } - - // free buffers needed for multiple frame loading; - STBI_FREE(g.history); - STBI_FREE(g.background); - - return u; -} - -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) -{ - return stbi__gif_info_raw(s,x,y,comp); +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { + return stbi__gif_info_raw(s, x, y, comp); } #endif @@ -6686,393 +7381,429 @@ static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR -static int stbi__hdr_test_core(stbi__context *s, const char *signature) -{ - int i; - for (i=0; signature[i]; ++i) - if (stbi__get8(s) != signature[i]) - return 0; - stbi__rewind(s); - return 1; -} - -static int stbi__hdr_test(stbi__context* s) -{ - int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); - stbi__rewind(s); - if(!r) { - r = stbi__hdr_test_core(s, "#?RGBE\n"); - stbi__rewind(s); - } - return r; -} - -#define STBI__HDR_BUFLEN 1024 -static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) -{ - int len=0; - char c = '\0'; - - c = (char) stbi__get8(z); - - while (!stbi__at_eof(z) && c != '\n') { - buffer[len++] = c; - if (len == STBI__HDR_BUFLEN-1) { - // flush to end of line - while (!stbi__at_eof(z) && stbi__get8(z) != '\n') - ; - break; +static int stbi__hdr_test_core(stbi__context *s, const char *signature) { + int i; + for (i = 0; signature[i]; ++i) + if (stbi__get8(s) != signature[i]) + return 0; + stbi__rewind(s); + return 1; +} + +static int stbi__hdr_test(stbi__context *s) { + int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); + stbi__rewind(s); + if (!r) { + r = stbi__hdr_test_core(s, "#?RGBE\n"); + stbi__rewind(s); + } + return r; +} + +#define STBI__HDR_BUFLEN 1024 +static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { + int len = 0; + char c = '\0'; + + c = (char)stbi__get8(z); + + while (!stbi__at_eof(z) && c != '\n') { + buffer[len++] = c; + if (len == STBI__HDR_BUFLEN - 1) { + // flush to end of line + while (!stbi__at_eof(z) && stbi__get8(z) != '\n') + ; + break; + } + c = (char)stbi__get8(z); + } + + buffer[len] = 0; + return buffer; +} + +static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { + if (input[3] != 0) { + float f1; + // Exponent + f1 = (float)ldexp(1.0f, input[3] - (int)(128 + 8)); + if (req_comp <= 2) + output[0] = (input[0] + input[1] + input[2]) * f1 / 3; + else { + output[0] = input[0] * f1; + output[1] = input[1] * f1; + output[2] = input[2] * f1; + } + if (req_comp == 2) + output[1] = 1; + if (req_comp == 4) + output[3] = 1; + } else { + switch (req_comp) { + case 4: + output[3] = 1; /* fallthrough */ + case 3: + output[0] = output[1] = output[2] = 0; + break; + case 2: + output[1] = 1; /* fallthrough */ + case 1: + output[0] = 0; + break; + } + } +} + +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri) { + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int width, height; + stbi_uc *scanline; + float *hdr_data; + int len; + unsigned char count, value; + int i, j, k, c1, c2, z; + const char *headerToken; + STBI_NOTUSED(ri); + + // Check identifier + headerToken = stbi__hdr_gettoken(s, buffer); + if (strcmp(headerToken, "#?RADIANCE") != 0 && + strcmp(headerToken, "#?RGBE") != 0) + return stbi__errpf("not HDR", "Corrupt HDR image"); + + // Parse header + for (;;) { + token = stbi__hdr_gettoken(s, buffer); + if (token[0] == 0) + break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) + valid = 1; + } + + if (!valid) + return stbi__errpf("unsupported format", "Unsupported HDR format"); + + // Parse width and height + // can't use sscanf() if we're not using stdio! + token = stbi__hdr_gettoken(s, buffer); + if (strncmp(token, "-Y ", 3)) + return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + height = (int)strtol(token, &token, 10); + while (*token == ' ') + ++token; + if (strncmp(token, "+X ", 3)) + return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + width = (int)strtol(token, NULL, 10); + + *x = width; + *y = height; + + if (comp) + *comp = 3; + if (req_comp == 0) + req_comp = 3; + + if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) + return stbi__errpf("too large", "HDR image is too large"); + + // Read data + hdr_data = + (float *)stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); + if (!hdr_data) + return stbi__errpf("outofmem", "Out of memory"); + + // Load image data + // image data is stored as some number of sca + if (width < 8 || width >= 32768) { + // Read flat data + for (j = 0; j < height; ++j) { + for (i = 0; i < width; ++i) { + stbi_uc rgbe[4]; + main_decode_loop: + stbi__getn(s, rgbe, 4); + stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, + req_comp); } - c = (char) stbi__get8(z); - } - - buffer[len] = 0; - return buffer; -} + } + } else { + // Read RLE-encoded data + scanline = NULL; -static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) -{ - if ( input[3] != 0 ) { - float f1; - // Exponent - f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); - if (req_comp <= 2) - output[0] = (input[0] + input[1] + input[2]) * f1 / 3; - else { - output[0] = input[0] * f1; - output[1] = input[1] * f1; - output[2] = input[2] * f1; + for (j = 0; j < height; ++j) { + c1 = stbi__get8(s); + c2 = stbi__get8(s); + len = stbi__get8(s); + if (c1 != 2 || c2 != 2 || (len & 0x80)) { + // not run-length encoded, so we have to actually use THIS data as a + // decoded pixel (note this can't be a valid pixel--one of RGB must be + // >= 128) + stbi_uc rgbe[4]; + rgbe[0] = (stbi_uc)c1; + rgbe[1] = (stbi_uc)c2; + rgbe[2] = (stbi_uc)len; + rgbe[3] = (stbi_uc)stbi__get8(s); + stbi__hdr_convert(hdr_data, rgbe, req_comp); + i = 1; + j = 0; + STBI_FREE(scanline); + goto main_decode_loop; // yes, this makes no sense } - if (req_comp == 2) output[1] = 1; - if (req_comp == 4) output[3] = 1; - } else { - switch (req_comp) { - case 4: output[3] = 1; /* fallthrough */ - case 3: output[0] = output[1] = output[2] = 0; - break; - case 2: output[1] = 1; /* fallthrough */ - case 1: output[0] = 0; - break; + len <<= 8; + len |= stbi__get8(s); + if (len != width) { + STBI_FREE(hdr_data); + STBI_FREE(scanline); + return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } - } -} - -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - int width, height; - stbi_uc *scanline; - float *hdr_data; - int len; - unsigned char count, value; - int i, j, k, c1,c2, z; - const char *headerToken; - STBI_NOTUSED(ri); - - // Check identifier - headerToken = stbi__hdr_gettoken(s,buffer); - if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) - return stbi__errpf("not HDR", "Corrupt HDR image"); - - // Parse header - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); - - // Parse width and height - // can't use sscanf() if we're not using stdio! - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - height = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - width = (int) strtol(token, NULL, 10); - - *x = width; - *y = height; - - if (comp) *comp = 3; - if (req_comp == 0) req_comp = 3; - - if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) - return stbi__errpf("too large", "HDR image is too large"); - - // Read data - hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); - if (!hdr_data) - return stbi__errpf("outofmem", "Out of memory"); - - // Load image data - // image data is stored as some number of sca - if ( width < 8 || width >= 32768) { - // Read flat data - for (j=0; j < height; ++j) { - for (i=0; i < width; ++i) { - stbi_uc rgbe[4]; - main_decode_loop: - stbi__getn(s, rgbe, 4); - stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); - } + if (scanline == NULL) { + scanline = (stbi_uc *)stbi__malloc_mad2(width, 4, 0); + if (!scanline) { + STBI_FREE(hdr_data); + return stbi__errpf("outofmem", "Out of memory"); + } } - } else { - // Read RLE-encoded data - scanline = NULL; - - for (j = 0; j < height; ++j) { - c1 = stbi__get8(s); - c2 = stbi__get8(s); - len = stbi__get8(s); - if (c1 != 2 || c2 != 2 || (len & 0x80)) { - // not run-length encoded, so we have to actually use THIS data as a decoded - // pixel (note this can't be a valid pixel--one of RGB must be >= 128) - stbi_uc rgbe[4]; - rgbe[0] = (stbi_uc) c1; - rgbe[1] = (stbi_uc) c2; - rgbe[2] = (stbi_uc) len; - rgbe[3] = (stbi_uc) stbi__get8(s); - stbi__hdr_convert(hdr_data, rgbe, req_comp); - i = 1; - j = 0; - STBI_FREE(scanline); - goto main_decode_loop; // yes, this makes no sense - } - len <<= 8; - len |= stbi__get8(s); - if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } - if (scanline == NULL) { - scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); - if (!scanline) { - STBI_FREE(hdr_data); - return stbi__errpf("outofmem", "Out of memory"); + + for (k = 0; k < 4; ++k) { + int nleft; + i = 0; + while ((nleft = width - i) > 0) { + count = stbi__get8(s); + if (count > 128) { + // Run + value = stbi__get8(s); + count -= 128; + if (count > nleft) { + STBI_FREE(hdr_data); + STBI_FREE(scanline); + return stbi__errpf("corrupt", "bad RLE data in HDR"); } - } - - for (k = 0; k < 4; ++k) { - int nleft; - i = 0; - while ((nleft = width - i) > 0) { - count = stbi__get8(s); - if (count > 128) { - // Run - value = stbi__get8(s); - count -= 128; - if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = value; - } else { - // Dump - if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = stbi__get8(s); - } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = value; + } else { + // Dump + if (count > nleft) { + STBI_FREE(hdr_data); + STBI_FREE(scanline); + return stbi__errpf("corrupt", "bad RLE data in HDR"); } - } - for (i=0; i < width; ++i) - stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = stbi__get8(s); + } + } } - if (scanline) - STBI_FREE(scanline); - } - - return hdr_data; -} - -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - int dummy; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - if (stbi__hdr_test(s) == 0) { - stbi__rewind( s ); - return 0; - } - - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) { - stbi__rewind( s ); - return 0; - } - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *y = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *x = (int) strtol(token, NULL, 10); - *comp = 3; - return 1; + for (i = 0; i < width; ++i) + stbi__hdr_convert(hdr_data + (j * width + i) * req_comp, + scanline + i * 4, req_comp); + } + if (scanline) + STBI_FREE(scanline); + } + + return hdr_data; +} + +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int dummy; + + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; + + if (stbi__hdr_test(s) == 0) { + stbi__rewind(s); + return 0; + } + + for (;;) { + token = stbi__hdr_gettoken(s, buffer); + if (token[0] == 0) + break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) + valid = 1; + } + + if (!valid) { + stbi__rewind(s); + return 0; + } + token = stbi__hdr_gettoken(s, buffer); + if (strncmp(token, "-Y ", 3)) { + stbi__rewind(s); + return 0; + } + token += 3; + *y = (int)strtol(token, &token, 10); + while (*token == ' ') + ++token; + if (strncmp(token, "+X ", 3)) { + stbi__rewind(s); + return 0; + } + token += 3; + *x = (int)strtol(token, NULL, 10); + *comp = 3; + return 1; } #endif // STBI_NO_HDR #ifndef STBI_NO_BMP -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) -{ - void *p; - stbi__bmp_data info; - - info.all_a = 255; - p = stbi__bmp_parse_header(s, &info); - stbi__rewind( s ); - if (p == NULL) - return 0; - if (x) *x = s->img_x; - if (y) *y = s->img_y; - if (comp) { - if (info.bpp == 24 && info.ma == 0xff000000) - *comp = 3; - else - *comp = info.ma ? 4 : 3; - } - return 1; +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { + void *p; + stbi__bmp_data info; + + info.all_a = 255; + p = stbi__bmp_parse_header(s, &info); + stbi__rewind(s); + if (p == NULL) + return 0; + if (x) + *x = s->img_x; + if (y) + *y = s->img_y; + if (comp) { + if (info.bpp == 24 && info.ma == 0xff000000) + *comp = 3; + else + *comp = info.ma ? 4 : 3; + } + return 1; } #endif #ifndef STBI_NO_PSD -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) -{ - int channelCount, dummy, depth; - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - if (stbi__get32be(s) != 0x38425053) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 1) { - stbi__rewind( s ); - return 0; - } - stbi__skip(s, 6); - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) { - stbi__rewind( s ); - return 0; - } - *y = stbi__get32be(s); - *x = stbi__get32be(s); - depth = stbi__get16be(s); - if (depth != 8 && depth != 16) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 3) { - stbi__rewind( s ); - return 0; - } - *comp = 4; - return 1; -} - -static int stbi__psd_is16(stbi__context *s) -{ - int channelCount, depth; - if (stbi__get32be(s) != 0x38425053) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 1) { - stbi__rewind( s ); - return 0; - } - stbi__skip(s, 6); - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) { - stbi__rewind( s ); - return 0; - } - (void) stbi__get32be(s); - (void) stbi__get32be(s); - depth = stbi__get16be(s); - if (depth != 16) { - stbi__rewind( s ); - return 0; - } - return 1; +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { + int channelCount, dummy, depth; + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind(s); + return 0; + } + *y = stbi__get32be(s); + *x = stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 8 && depth != 16) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 3) { + stbi__rewind(s); + return 0; + } + *comp = 4; + return 1; +} + +static int stbi__psd_is16(stbi__context *s) { + int channelCount, depth; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind(s); + return 0; + } + (void)stbi__get32be(s); + (void)stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 16) { + stbi__rewind(s); + return 0; + } + return 1; } #endif #ifndef STBI_NO_PIC -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) -{ - int act_comp=0,num_packets=0,chained,dummy; - stbi__pic_packet packets[10]; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { - stbi__rewind(s); +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { + int act_comp = 0, num_packets = 0, chained, dummy; + stbi__pic_packet packets[10]; + + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; + + if (!stbi__pic_is4(s, "\x53\x80\xF6\x34")) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 88); + + *x = stbi__get16be(s); + *y = stbi__get16be(s); + if (stbi__at_eof(s)) { + stbi__rewind(s); + return 0; + } + if ((*x) != 0 && (1 << 28) / (*x) < (*y)) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 8); + + do { + stbi__pic_packet *packet; + + if (num_packets == sizeof(packets) / sizeof(packets[0])) return 0; - } - stbi__skip(s, 88); + packet = &packets[num_packets++]; + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + act_comp |= packet->channel; - *x = stbi__get16be(s); - *y = stbi__get16be(s); - if (stbi__at_eof(s)) { - stbi__rewind( s); + if (stbi__at_eof(s)) { + stbi__rewind(s); return 0; - } - if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { - stbi__rewind( s ); + } + if (packet->size != 8) { + stbi__rewind(s); return 0; - } - - stbi__skip(s, 8); - - do { - stbi__pic_packet *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return 0; - - packet = &packets[num_packets++]; - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); - act_comp |= packet->channel; - - if (stbi__at_eof(s)) { - stbi__rewind( s ); - return 0; - } - if (packet->size != 8) { - stbi__rewind( s ); - return 0; - } - } while (chained); + } + } while (chained); - *comp = (act_comp & 0x10 ? 4 : 3); + *comp = (act_comp & 0x10 ? 4 : 3); - return 1; + return 1; } #endif @@ -7090,254 +7821,259 @@ static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) #ifndef STBI_NO_PNM -static int stbi__pnm_test(stbi__context *s) -{ - char p, t; - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind( s ); - return 0; - } - return 1; +static int stbi__pnm_test(stbi__context *s) { + char p, t; + p = (char)stbi__get8(s); + t = (char)stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } + return 1; } -static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *out; - STBI_NOTUSED(ri); +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, + int req_comp, stbi__result_info *ri) { + stbi_uc *out; + STBI_NOTUSED(ri); - if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) - return 0; + if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) + return 0; - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = s->img_n; + *x = s->img_x; + *y = s->img_y; + if (comp) + *comp = s->img_n; - if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) - return stbi__errpuc("too large", "PNM too large"); + if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "PNM too large"); - out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - stbi__getn(s, out, s->img_n * s->img_x * s->img_y); + out = (stbi_uc *)stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); + if (!out) + return stbi__errpuc("outofmem", "Out of memory"); + stbi__getn(s, out, s->img_n * s->img_x * s->img_y); - if (req_comp && req_comp != s->img_n) { - out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - return out; + if (req_comp && req_comp != s->img_n) { + out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); + if (out == NULL) + return out; // stbi__convert_format frees input on failure + } + return out; } -static int stbi__pnm_isspace(char c) -{ - return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; +static int stbi__pnm_isspace(char c) { + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || + c == '\r'; } -static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) -{ - for (;;) { - while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) - *c = (char) stbi__get8(s); +static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { + for (;;) { + while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) + *c = (char)stbi__get8(s); - if (stbi__at_eof(s) || *c != '#') - break; + if (stbi__at_eof(s) || *c != '#') + break; - while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) - *c = (char) stbi__get8(s); - } + while (!stbi__at_eof(s) && *c != '\n' && *c != '\r') + *c = (char)stbi__get8(s); + } } -static int stbi__pnm_isdigit(char c) -{ - return c >= '0' && c <= '9'; -} +static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } -static int stbi__pnm_getinteger(stbi__context *s, char *c) -{ - int value = 0; +static int stbi__pnm_getinteger(stbi__context *s, char *c) { + int value = 0; - while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { - value = value*10 + (*c - '0'); - *c = (char) stbi__get8(s); - } + while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { + value = value * 10 + (*c - '0'); + *c = (char)stbi__get8(s); + } - return value; + return value; } -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) -{ - int maxv, dummy; - char c, p, t; +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { + int maxv, dummy; + char c, p, t; - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; - stbi__rewind(s); + stbi__rewind(s); - // Get identifier - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind(s); - return 0; - } + // Get identifier + p = (char)stbi__get8(s); + t = (char)stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } - *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm + *comp = + (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm - c = (char) stbi__get8(s); - stbi__pnm_skip_whitespace(s, &c); + c = (char)stbi__get8(s); + stbi__pnm_skip_whitespace(s, &c); - *x = stbi__pnm_getinteger(s, &c); // read width - stbi__pnm_skip_whitespace(s, &c); + *x = stbi__pnm_getinteger(s, &c); // read width + stbi__pnm_skip_whitespace(s, &c); - *y = stbi__pnm_getinteger(s, &c); // read height - stbi__pnm_skip_whitespace(s, &c); + *y = stbi__pnm_getinteger(s, &c); // read height + stbi__pnm_skip_whitespace(s, &c); - maxv = stbi__pnm_getinteger(s, &c); // read max value + maxv = stbi__pnm_getinteger(s, &c); // read max value - if (maxv > 255) - return stbi__err("max value > 255", "PPM image not 8-bit"); - else - return 1; + if (maxv > 255) + return stbi__err("max value > 255", "PPM image not 8-bit"); + else + return 1; } #endif -static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) -{ - #ifndef STBI_NO_JPEG - if (stbi__jpeg_info(s, x, y, comp)) return 1; - #endif +static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { +#ifndef STBI_NO_JPEG + if (stbi__jpeg_info(s, x, y, comp)) + return 1; +#endif - #ifndef STBI_NO_PNG - if (stbi__png_info(s, x, y, comp)) return 1; - #endif +#ifndef STBI_NO_PNG + if (stbi__png_info(s, x, y, comp)) + return 1; +#endif - #ifndef STBI_NO_GIF - if (stbi__gif_info(s, x, y, comp)) return 1; - #endif +#ifndef STBI_NO_GIF + if (stbi__gif_info(s, x, y, comp)) + return 1; +#endif - #ifndef STBI_NO_BMP - if (stbi__bmp_info(s, x, y, comp)) return 1; - #endif +#ifndef STBI_NO_BMP + if (stbi__bmp_info(s, x, y, comp)) + return 1; +#endif - #ifndef STBI_NO_PSD - if (stbi__psd_info(s, x, y, comp)) return 1; - #endif +#ifndef STBI_NO_PSD + if (stbi__psd_info(s, x, y, comp)) + return 1; +#endif - #ifndef STBI_NO_PIC - if (stbi__pic_info(s, x, y, comp)) return 1; - #endif +#ifndef STBI_NO_PIC + if (stbi__pic_info(s, x, y, comp)) + return 1; +#endif - #ifndef STBI_NO_PNM - if (stbi__pnm_info(s, x, y, comp)) return 1; - #endif +#ifndef STBI_NO_PNM + if (stbi__pnm_info(s, x, y, comp)) + return 1; +#endif - #ifndef STBI_NO_HDR - if (stbi__hdr_info(s, x, y, comp)) return 1; - #endif +#ifndef STBI_NO_HDR + if (stbi__hdr_info(s, x, y, comp)) + return 1; +#endif - // test tga last because it's a crappy test! - #ifndef STBI_NO_TGA - if (stbi__tga_info(s, x, y, comp)) - return 1; - #endif - return stbi__err("unknown image type", "Image not of any known type, or corrupt"); +// test tga last because it's a crappy test! +#ifndef STBI_NO_TGA + if (stbi__tga_info(s, x, y, comp)) + return 1; +#endif + return stbi__err("unknown image type", + "Image not of any known type, or corrupt"); } -static int stbi__is_16_main(stbi__context *s) -{ - #ifndef STBI_NO_PNG - if (stbi__png_is16(s)) return 1; - #endif +static int stbi__is_16_main(stbi__context *s) { +#ifndef STBI_NO_PNG + if (stbi__png_is16(s)) + return 1; +#endif - #ifndef STBI_NO_PSD - if (stbi__psd_is16(s)) return 1; - #endif +#ifndef STBI_NO_PSD + if (stbi__psd_is16(s)) + return 1; +#endif - return 0; + return 0; } #ifndef STBI_NO_STDIO -STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result; - if (!f) return stbi__err("can't fopen", "Unable to open file"); - result = stbi_info_from_file(f, x, y, comp); - fclose(f); - return result; -} - -STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - int r; - stbi__context s; - long pos = ftell(f); - stbi__start_file(&s, f); - r = stbi__info_main(&s,x,y,comp); - fseek(f,pos,SEEK_SET); - return r; -} - -STBIDEF int stbi_is_16_bit(char const *filename) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result; - if (!f) return stbi__err("can't fopen", "Unable to open file"); - result = stbi_is_16_bit_from_file(f); - fclose(f); - return result; -} - -STBIDEF int stbi_is_16_bit_from_file(FILE *f) -{ - int r; - stbi__context s; - long pos = ftell(f); - stbi__start_file(&s, f); - r = stbi__is_16_main(&s); - fseek(f,pos,SEEK_SET); - return r; +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) + return stbi__err("can't fopen", "Unable to open file"); + result = stbi_info_from_file(f, x, y, comp); + fclose(f); + return result; +} + +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__info_main(&s, x, y, comp); + fseek(f, pos, SEEK_SET); + return r; +} + +STBIDEF int stbi_is_16_bit(char const *filename) { + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) + return stbi__err("can't fopen", "Unable to open file"); + result = stbi_is_16_bit_from_file(f); + fclose(f); + return result; +} + +STBIDEF int stbi_is_16_bit_from_file(FILE *f) { + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__is_16_main(&s); + fseek(f, pos, SEEK_SET); + return r; } #endif // !STBI_NO_STDIO -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__info_main(&s,x,y,comp); +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, + int *y, int *comp) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__info_main(&s, x, y, comp); } -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); - return stbi__info_main(&s,x,y,comp); +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, + int *x, int *y, int *comp) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)c, user); + return stbi__info_main(&s, x, y, comp); } -STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__is_16_main(&s); +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__is_16_main(&s); } -STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); - return stbi__is_16_main(&s); +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, + void *user) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)c, user); + return stbi__is_16_main(&s); } #endif // STB_IMAGE_IMPLEMENTATION /* revision history: - 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs - 2.19 (2018-02-11) fix warning - 2.18 (2018-01-30) fix warnings - 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and + platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix + warnings 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug 1-bit BMP *_is_16_bit api avoid warnings @@ -7352,13 +8088,11 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user warning fixes; disable run-time SSE detection on gcc; uniform handling of optional "return" values; thread-safe initialization of zlib tables - 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs - 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now - 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes - 2.11 (2016-04-02) allocate large structures on the stack - remove white matting for transparent PSD - fix reported channel count for PNG & BMP - re-enable SSE2 in non-gcc 64-bit + 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet + JPGs 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now 2.12 + (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) + allocate large structures on the stack remove white matting for transparent + PSD fix reported channel count for PNG & BMP re-enable SSE2 in non-gcc 64-bit support RGB-formatted JPEG read 16-bit PNGs (only as 8-bit) 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED @@ -7366,11 +8100,9 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user 16-bit-per-pixel TGA (not bit-per-component) info() for TGA could break due to .hdr handling info() for BMP to shares code instead of sloppy parse - can use STBI_REALLOC_SIZED if allocator doesn't support realloc - code cleanup - 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA - 2.07 (2015-09-13) fix compiler warnings - partial animated GIF support + can use STBI_REALLOC_SIZED if allocator doesn't support + realloc code cleanup 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD + as RGBA 2.07 (2015-09-13) fix compiler warnings partial animated GIF support limited 16-bpc PSD support #ifdef unused functions bug with < 92 byte PIC,PNM,HDR,TGA @@ -7381,23 +8113,18 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user stbi_set_flip_vertically_on_load (nguillemot) fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning - 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 - 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG - 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) - progressive JPEG (stb) - PGM/PPM support (Ken Miller) - STBI_MALLOC,STBI_REALLOC,STBI_FREE + 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit + without -msse2 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 + (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) progressive + JPEG (stb) PGM/PPM support (Ken Miller) STBI_MALLOC,STBI_REALLOC,STBI_FREE GIF bugfix -- seemingly never worked STBI_NO_*, STBI_ONLY_* 1.48 (2014-12-14) fix incorrectly-named assert() - 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) - optimize PNG (ryg) - fix bug in interlaced PNG with user-specified channel count (stb) - 1.46 (2014-08-26) - fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG - 1.45 (2014-08-16) - fix MSVC-ARM internal compiler error by wrapping malloc - 1.44 (2014-08-07) + 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar + Cornut & stb) optimize PNG (ryg) fix bug in interlaced PNG with + user-specified channel count (stb) 1.46 (2014-08-26) fix broken tRNS chunk + (colorkey-style transparency) in non-paletted PNG 1.45 (2014-08-16) fix + MSVC-ARM internal compiler error by wrapping malloc 1.44 (2014-08-07) various warning fixes from Ronny Chevalier 1.43 (2014-07-15) fix MSVC-only compiler problem in code changed in 1.42 @@ -7406,73 +8133,48 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user fixes to stbi__cleanup_jpeg path added STBI_ASSERT to avoid requiring assert.h 1.41 (2014-06-25) - fix search&replace from 1.36 that messed up comments/error messages - 1.40 (2014-06-22) - fix gcc struct-initialization warning - 1.39 (2014-06-15) - fix to TGA optimization when req_comp != number of components in TGA; - fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) - add support for BMP version 5 (more ignored fields) - 1.38 (2014-06-06) - suppress MSVC warnings on integer casts truncating values - fix accidental rename of 'skip' field of I/O - 1.37 (2014-06-04) - remove duplicate typedef - 1.36 (2014-06-03) - convert to header file single-file library - if de-iphone isn't set, load iphone images color-swapped instead of returning NULL - 1.35 (2014-05-27) - various warnings - fix broken STBI_SIMD path - fix bug where stbi_load_from_file no longer left file pointer in correct place - fix broken non-easy path for 32-bit BMP (possibly never used) - TGA optimization by Arseny Kapoulkine - 1.34 (unknown) - use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case - 1.33 (2011-07-14) - make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements - 1.32 (2011-07-13) - support for "info" function for all supported filetypes (SpartanJ) - 1.31 (2011-06-20) - a few more leak fixes, bug in PNG handling (SpartanJ) - 1.30 (2011-06-11) - added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) + fix search&replace from 1.36 that messed up comments/error + messages 1.40 (2014-06-22) fix gcc struct-initialization warning 1.39 + (2014-06-15) fix to TGA optimization when req_comp != number of components in + TGA; fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my + test suite) add support for BMP version 5 (more ignored fields) 1.38 + (2014-06-06) suppress MSVC warnings on integer casts truncating values fix + accidental rename of 'skip' field of I/O 1.37 (2014-06-04) remove duplicate + typedef 1.36 (2014-06-03) convert to header file single-file library if + de-iphone isn't set, load iphone images color-swapped instead of returning + NULL 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug + where stbi_load_from_file no longer left file pointer in correct place fix + broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by + Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in + stbi__resample_row_generic(), fix one more leak in tga failure case 1.33 + (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor + compiler-friendly improvements 1.32 (2011-07-13) support for "info" function + for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak + fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to + load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions - removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway - error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) - fix inefficiency in decoding 32-bit BMP (David Woo) - 1.29 (2010-08-16) - various warning fixes from Aurelien Pocheville - 1.28 (2010-08-01) - fix bug in GIF palette transparency (SpartanJ) - 1.27 (2010-08-01) - cast-to-stbi_uc to fix warnings - 1.26 (2010-07-24) - fix bug in file buffering for PNG reported by SpartanJ - 1.25 (2010-07-17) - refix trans_data warning (Won Chun) - 1.24 (2010-07-12) - perf improvements reading from files on platforms with lock-heavy fgetc() - minor perf improvements for jpeg - deprecated type-specific functions so we'll get feedback if they're needed - attempt to fix trans_data warning (Won Chun) - 1.23 fixed bug in iPhone support - 1.22 (2010-07-10) - removed image *writing* support - stbi_info support from Jetro Lauha - GIF support from Jean-Marc Lienher + removed support for installable file formats (stbi_loader) -- + would have been broken for IO callbacks anyway error cases in bmp and tga + give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in + decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from + Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency + (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to fix warnings 1.26 + (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 + (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf + improvements reading from files on platforms with lock-heavy fgetc() minor + perf improvements for jpeg deprecated type-specific functions so we'll get + feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 + fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* + support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown - warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) - 1.21 fix use of 'stbi_uc' in header (reported by jon blow) - 1.20 added support for Softimage PIC, by Tom Seddon - 1.19 bug in interlaced PNG corruption check (found by ryg) - 1.18 (2008-08-02) - fix a threading bug (local mutable static) - 1.17 support interlaced PNG - 1.16 major bugfix - stbi__convert_format converted one too many pixels - 1.15 initialize some fields for thread safety - 1.14 fix threadsafe conversion bug - header-file-only version (#define STBI_HEADER_FILE_ONLY before including) + warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. + Janez (U+017D)emva) 1.21 fix use of 'stbi_uc' in header (reported by jon + blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in + interlaced PNG corruption check (found by ryg) 1.18 (2008-08-02) fix a + threading bug (local mutable static) 1.17 support interlaced PNG 1.16 + major bugfix - stbi__convert_format converted one too many pixels 1.15 + initialize some fields for thread safety 1.14 fix threadsafe conversion + bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines @@ -7482,15 +8184,14 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again - 1.05 fix TGA loading to return correct *comp and use good luminance calc - 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free - 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR - 1.02 support for (subset of) HDR files, float interface for preferred access to them - 1.01 fix bug: possible bug in handling right-side up bmps... not sure - fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all - 1.00 interface to zlib that skips zlib header - 0.99 correct handling of alpha in palette - 0.98 TGA loader by lonesock; dynamically add loaders (untested) + 1.05 fix TGA loading to return correct *comp and use good luminance + calc 1.04 default float alpha is 1, not 255; use 'void *' for + stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support + for (subset of) HDR files, float interface for preferred access to them 1.01 + fix bug: possible bug in handling right-side up bmps... not sure fix bug: the + stbi__bmp_load() and stbi__tga_load() functions didn't work at all 1.00 + interface to zlib that skips zlib header 0.99 correct handling of alpha in + palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding @@ -7503,8 +8204,8 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian - 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available - 0.56 fix bug: zlib uncompressed mode len vs. nlen + 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but + less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding @@ -7515,7 +8216,6 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user first released version */ - /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. diff --git a/Sources/MaterialX/include/MaterialX/StbImageWrite.h b/Sources/MaterialX/include/MaterialX/StbImageWrite.h index aa7ec5ca..d05a6bf6 100644 --- a/Sources/MaterialX/include/MaterialX/StbImageWrite.h +++ b/Sources/MaterialX/include/MaterialX/StbImageWrite.h @@ -309,12 +309,13 @@ static void stbi__stdio_write(void *context, void *data, int size) { #else #define STBIW_EXTERN extern #endif -STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar( - unsigned int cp, unsigned long flags, const char *str, int cbmb, - wchar_t *widestr, int cchwide); -STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte( - unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, - char *str, int cbmb, const char *defchar, int *used_default); +STBIW_EXTERN __declspec(dllimport) int __stdcall +MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, + int cbmb, wchar_t *widestr, int cchwide); +STBIW_EXTERN __declspec(dllimport) int __stdcall +WideCharToMultiByte(unsigned int cp, unsigned long flags, + const wchar_t *widestr, int cchwide, char *str, int cbmb, + const char *defchar, int *used_default); STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t *input) { @@ -833,7 +834,7 @@ STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, #ifndef STBIW_ZLIB_COMPRESS // stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() // == vector<>::size() -#define stbiw__sbraw(a) ((int *)(a)-2) +#define stbiw__sbraw(a) ((int *)(a) - 2) #define stbiw__sbm(a) stbiw__sbraw(a)[0] #define stbiw__sbn(a) stbiw__sbraw(a)[1] @@ -909,9 +910,9 @@ static unsigned int stbiw__zhash(unsigned char *data) { #define stbiw__zlib_huffa(b, c) stbiw__zlib_add(stbiw__zlib_bitrev(b, c), c) // default huffman tables #define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) -#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) -#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256, 7) -#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280, 8) +#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n) - 144, 9) +#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n) - 256, 7) +#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n) - 280, 8) #define stbiw__zlib_huff(n) \ ((n) <= 143 ? stbiw__zlib_huff1(n) \ : (n) <= 255 ? stbiw__zlib_huff2(n) \ diff --git a/Sources/MaterialX/source/JsMaterialX/JsMaterialXCore/JsExceptions.cpp b/Sources/MaterialX/source/JsMaterialX/JsMaterialXCore/JsExceptions.cpp index b7958b2e..0c29bb56 100644 --- a/Sources/MaterialX/source/JsMaterialX/JsMaterialXCore/JsExceptions.cpp +++ b/Sources/MaterialX/source/JsMaterialX/JsMaterialXCore/JsExceptions.cpp @@ -9,15 +9,12 @@ namespace ems = emscripten; -namespace jsexceptions -{ -std::string getExceptionMessage(int exceptionPtr) -{ - return std::string(reinterpret_cast(exceptionPtr)->what()); +namespace jsexceptions { +std::string getExceptionMessage(int exceptionPtr) { + return std::string(reinterpret_cast(exceptionPtr)->what()); } } // namespace jsexceptions -EMSCRIPTEN_BINDINGS(exceptions) -{ - ems::function("getExceptionMessage", &jsexceptions::getExceptionMessage); +EMSCRIPTEN_BINDINGS(exceptions) { + ems::function("getExceptionMessage", &jsexceptions::getExceptionMessage); } diff --git a/Sources/MaterialX/source/MaterialXFormat/External/PugiXML/pugixml.cpp b/Sources/MaterialX/source/MaterialXFormat/External/PugiXML/pugixml.cpp index b0f7cfc2..c46d02ad 100644 --- a/Sources/MaterialX/source/MaterialXFormat/External/PugiXML/pugixml.cpp +++ b/Sources/MaterialX/source/MaterialXFormat/External/PugiXML/pugixml.cpp @@ -27,8 +27,8 @@ #endif #ifndef PUGIXML_NO_XPATH -#include #include +#include #endif #ifndef PUGIXML_NO_STL @@ -43,8 +43,8 @@ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4127) // conditional expression is constant -#pragma warning( \ - disable : 4324) // structure was padded due to __declspec(align()) +#pragma warning(disable \ + : 4324) // structure was padded due to __declspec(align()) #pragma warning(disable : 4702) // unreachable code #pragma warning(disable : 4996) // this function or variable may be unsafe #endif @@ -59,8 +59,8 @@ #pragma warning(disable : 177) // function was declared but never referenced #pragma warning(disable : 279) // controlling expression is constant #pragma warning(disable : 1478 1786) // function was declared "deprecated" -#pragma warning( \ - disable : 1684) // conversion from pointer to same-sized integral type +#pragma warning(disable \ + : 1684) // conversion from pointer to same-sized integral type #endif #if defined(__BORLANDC__) && defined(PUGIXML_HEADER_ONLY) @@ -2608,7 +2608,9 @@ PUGI__FN char_t *strconv_escape(char_t *s, gap &g) { PUGI__THROW_ERROR(status_out_of_memory, s); \ } #define PUGI__POPNODE() \ - { cursor = cursor->parent; } + { \ + cursor = cursor->parent; \ + } #define PUGI__SCANFOR(X) \ { \ while (*s != 0 && !(X)) \ @@ -8373,7 +8375,7 @@ PUGI__FN double convert_string_to_number(const char_t *string) { if (!check_string_to_number_format(string)) return gen_nan(); - // parse string + // parse string #ifdef PUGIXML_WCHAR_MODE return wcstod(string, 0); #else @@ -11804,8 +11806,9 @@ struct xpath_parser { // | AdditiveExpr '-' MultiplicativeExpr // MultiplicativeExpr ::= UnaryExpr // | MultiplicativeExpr '*' - //UnaryExpr | MultiplicativeExpr 'div' UnaryExpr | MultiplicativeExpr 'mod' - //UnaryExpr + // UnaryExpr | MultiplicativeExpr + // 'div' UnaryExpr | + // MultiplicativeExpr 'mod' UnaryExpr xpath_ast_node *parse_expression(int limit = 0) { xpath_ast_node *n = parse_path_or_unary_expression(); if (!n) diff --git a/Sources/MaterialX/source/MaterialXRenderGlsl/GLCocoaWrappers.m b/Sources/MaterialX/source/MaterialXRenderGlsl/GLCocoaWrappers.m index 18d85ec6..cf4b590e 100644 --- a/Sources/MaterialX/source/MaterialXRenderGlsl/GLCocoaWrappers.m +++ b/Sources/MaterialX/source/MaterialXRenderGlsl/GLCocoaWrappers.m @@ -4,13 +4,13 @@ // #if defined(__APPLE__) -# include +#include #if !TARGET_OS_IPHONE -# import -# import +#import +#import #else /* TARGET_OS_IPHONE */ -# import +#import #endif /* !TARGET_OS_IPHONE */ #import @@ -22,7 +22,8 @@ bool accelerated, bool mp_safe, bool stereo, bool supportMultiSample) { #if !TARGET_OS_IPHONE - // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is enabled. + // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is + // enabled. // TODO: refactor this objc code to cxx. // Create local autorelease pool for any objects that need to be autoreleased. #if !__has_feature(objc_arc) @@ -101,48 +102,51 @@ #if !__has_feature(objc_arc) [pool release]; #endif - - return (__bridge void*)pixelFormat; -#else /* TARGET_OS_IPHONE */ + + return (__bridge void *)pixelFormat; +#else /* TARGET_OS_IPHONE */ return nil; #endif /* !TARGET_OS_IPHONE */ } void NSOpenGLReleasePixelFormat(void *pPixelFormat) { #if !TARGET_OS_IPHONE - NSOpenGLPixelFormat *pixelFormat = (__bridge NSOpenGLPixelFormat *)pPixelFormat; - #if !__has_feature(objc_arc) + NSOpenGLPixelFormat *pixelFormat = + (__bridge NSOpenGLPixelFormat *)pPixelFormat; +#if !__has_feature(objc_arc) [pixelFormat release]; - #endif +#endif #endif /* !TARGET_OS_IPHONE */ } void NSOpenGLReleaseContext(void *pContext) { #if !TARGET_OS_IPHONE NSOpenGLContext *context = (__bridge NSOpenGLContext *)pContext; - #if !__has_feature(objc_arc) +#if !__has_feature(objc_arc) [context release]; - #endif +#endif #endif /* !TARGET_OS_IPHONE */ } void *NSOpenGLCreateContextWrapper(void *pPixelFormat, void *pDummyContext) { #if !TARGET_OS_IPHONE - NSOpenGLPixelFormat *pixelFormat = (__bridge NSOpenGLPixelFormat *)pPixelFormat; + NSOpenGLPixelFormat *pixelFormat = + (__bridge NSOpenGLPixelFormat *)pPixelFormat; NSOpenGLContext *dummyContext = (__bridge NSOpenGLContext *)pDummyContext; NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:dummyContext]; - return (__bridge void*)context; -#else /* TARGET_OS_IPHONE */ + return (__bridge void *)context; +#else /* TARGET_OS_IPHONE */ return nil; #endif /* !TARGET_OS_IPHONE */ } void NSOpenGLSetDrawable(void *pContext, void *pWindow) { #if !TARGET_OS_IPHONE - // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is enabled. + // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is + // enabled. // TODO: refactor this objc code to cxx. // Create local autorelease pool for any objects that need to be autoreleased. #if !__has_feature(objc_arc) @@ -170,7 +174,7 @@ void NSOpenGLMakeCurrent(void *pContext) { void *NSOpenGLGetCurrentContextWrapper() { #if !TARGET_OS_IPHONE - return (__bridge void*)[NSOpenGLContext currentContext]; + return (__bridge void *)[NSOpenGLContext currentContext]; #endif /* !TARGET_OS_IPHONE */ } @@ -181,20 +185,18 @@ void NSOpenGLSwapBuffers(void *pContext) { #endif /* !TARGET_OS_IPHONE */ } -void NSOpenGLClearCurrentContext() -{ +void NSOpenGLClearCurrentContext() { #if !TARGET_OS_IPHONE [NSOpenGLContext clearCurrentContext]; #endif /* !TARGET_OS_IPHONE */ } -void NSOpenGLDestroyContext(void **pContext) -{ +void NSOpenGLDestroyContext(void **pContext) { #if !TARGET_OS_IPHONE NSOpenGLContext *context = (__bridge NSOpenGLContext *)*pContext; - #if !__has_feature(objc_arc) +#if !__has_feature(objc_arc) [context release]; - #endif +#endif *pContext = NULL; #endif /* !TARGET_OS_IPHONE */ } @@ -203,16 +205,17 @@ void NSOpenGLDestroyCurrentContext(void **pContext) { #if !TARGET_OS_IPHONE [NSOpenGLContext clearCurrentContext]; NSOpenGLContext *context = (__bridge NSOpenGLContext *)*pContext; - #if !__has_feature(objc_arc) +#if !__has_feature(objc_arc) [context release]; - #endif +#endif *pContext = NULL; #endif /* !TARGET_OS_IPHONE */ } void NSOpenGLClearDrawable(void *pContext) { #if !TARGET_OS_IPHONE - // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is enabled. + // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is + // enabled. // TODO: refactor this objc code to cxx. // Create local autorelease pool for any objects that need to be autoreleased. #if !__has_feature(objc_arc) @@ -231,7 +234,8 @@ void NSOpenGLClearDrawable(void *pContext) { void NSOpenGLDescribePixelFormat(void *pPixelFormat, int attrib, int *vals) { #if !TARGET_OS_IPHONE - NSOpenGLPixelFormat *pixelFormat = (__bridge NSOpenGLPixelFormat *)pPixelFormat; + NSOpenGLPixelFormat *pixelFormat = + (__bridge NSOpenGLPixelFormat *)pPixelFormat; [pixelFormat getValues:vals forAttribute:attrib forVirtualScreen:0]; #endif /* !TARGET_OS_IPHONE */ } @@ -253,13 +257,14 @@ void NSOpenGLUpdate(void *pContext) { void *NSOpenGLGetWindow(void *pView) { #if !TARGET_OS_IPHONE NSView *view = (__bridge NSView *)pView; - return (__bridge void*)[view window]; + return (__bridge void *)[view window]; #endif /* !TARGET_OS_IPHONE */ } void NSOpenGLInitializeGLLibrary() { #if !TARGET_OS_IPHONE - // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is enabled. + // NOTE: the autoreleasepool (for the objc impl) only exists if ARC is + // enabled. // TODO: refactor this objc code to cxx. // Create local autorelease pool for any objects that need to be autoreleased. // (needed in batch mode). @@ -271,9 +276,9 @@ void NSOpenGLInitializeGLLibrary() { NSOpenGLPixelFormat *dummyPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrib]; if (nil != dummyPixelFormat) { - #if !__has_feature(objc_arc) +#if !__has_feature(objc_arc) [dummyPixelFormat release]; - #endif +#endif } // Free up memory (pool only exists if ARC is enabled) #if !__has_feature(objc_arc) diff --git a/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp b/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp index 423767c0..e0b6b493 100644 --- a/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp +++ b/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp @@ -8,8 +8,8 @@ #if defined(__linux__) || defined(__FreeBSD__) #include #elif defined(__APPLE__) -#include #include +#include #endif MATERIALX_NAMESPACE_BEGIN diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm index 6fb1b402..fe4f7b6d 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm @@ -18,7 +18,7 @@ MetalFramebufferPtr MetalFramebuffer::create(id device, unsigned int width, unsigned int height, unsigned channelCount, - Image::BaseType baseType, MTLTexture *colorTexture, + Image::BaseType baseType, id colorTexture, bool encodeSrgb, MTLPixelFormat pixelFormat) { return MetalFramebufferPtr( new MetalFramebuffer(device, width, height, channelCount, baseType, @@ -29,7 +29,7 @@ new MetalFramebuffer(device, width, height, channelCount, baseType, unsigned int height, unsigned int channelCount, Image::BaseType baseType, - MTLTexture *colorTexture, bool encodeSrgb, + id colorTexture, bool encodeSrgb, MTLPixelFormat pixelFormat) : _width(0), _height(0), _channelCount(channelCount), _baseType(baseType), _encodeSrgb(encodeSrgb), _device(device), _colorTexture(colorTexture), @@ -41,13 +41,15 @@ new MetalFramebuffer(device, width, height, channelCount, baseType, } MetalFramebuffer::~MetalFramebuffer() { - _colorTexture->release(); - _depthTexture->release(); +#if !__has_feature(objc_arc) + [_colorTexture release]; + [_depthTexture release]; +#endif // !__has_feature(objc_arc) } void MetalFramebuffer::resize(unsigned int width, unsigned int height, bool forceRecreate, MTLPixelFormat pixelFormat, - MTLTexture *extColorTexture) { + id extColorTexture) { if (width * height <= 0) { return; } @@ -59,23 +61,25 @@ new MetalFramebuffer(device, width, height, channelCount, baseType, _baseType, _channelCount, _encodeSrgb, dataType, pixelFormat); MTLTextureDescriptor *texDescriptor = - MTLTextureDescriptor::texture2DDescriptor(pixelFormat, width, height, - NO); - texDescriptor->setStorageMode(MTLStorageModePrivate); - texDescriptor->setUsage(MTLTextureUsageRenderTarget | - MTLTextureUsageShaderRead); + [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pixelFormat + width:width + height:height + mipmapped:NO]; + [texDescriptor setStorageMode:(MTLStorageModePrivate)]; + [texDescriptor + setUsage:(MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead)]; if (extColorTexture == nil) { - _colorTexture = _device->newTexture(texDescriptor); + _colorTexture = [_device newTextureWithDescriptor:(texDescriptor)]; _colorTextureOwned = true; } else { _colorTexture = extColorTexture; _colorTextureOwned = false; } - texDescriptor->setPixelFormat(MTLPixelFormatDepth32Float); - texDescriptor->setUsage(MTLTextureUsageRenderTarget); - _depthTexture = _device->newTexture(texDescriptor); + [texDescriptor setPixelFormat:(MTLPixelFormatDepth32Float)]; + [texDescriptor setUsage:(MTLTextureUsageRenderTarget)]; + _depthTexture = [_device newTextureWithDescriptor:(texDescriptor)]; _width = width; _height = height; @@ -83,25 +87,27 @@ new MetalFramebuffer(device, width, height, channelCount, baseType, } void MetalFramebuffer::bind(MTLRenderPassDescriptor *renderpassDesc) { - renderpassDesc->colorAttachments()->object(0)->setTexture(getColorTexture()); - renderpassDesc->colorAttachments()->object(0)->setLoadAction( - MTLLoadActionClear); - renderpassDesc->colorAttachments()->object(0)->setStoreAction( - MTLStoreActionStore); - - renderpassDesc->depthAttachment()->setTexture(getDepthTexture()); - renderpassDesc->depthAttachment()->setClearDepth(1.0); - renderpassDesc->depthAttachment()->setLoadAction(MTLLoadActionClear); - renderpassDesc->depthAttachment()->setStoreAction(MTLStoreActionStore); - renderpassDesc->setStencilAttachment(nil); - - renderpassDesc->setRenderTargetWidth(_width); - renderpassDesc->setRenderTargetHeight(_height); + [[[renderpassDesc colorAttachments] objectAtIndexedSubscript:0] + setTexture:getColorTexture()]; + + [[[renderpassDesc colorAttachments] objectAtIndexedSubscript:0] + setLoadAction:(MTLLoadActionClear)]; + [[[renderpassDesc colorAttachments] objectAtIndexedSubscript:0] + setStoreAction:(MTLStoreActionStore)]; + + [[renderpassDesc depthAttachment] setTexture:(getDepthTexture())]; + [[renderpassDesc depthAttachment] setClearDepth:(1.0)]; + [[renderpassDesc depthAttachment] setLoadAction:(MTLLoadActionClear)]; + [[renderpassDesc depthAttachment] setStoreAction:(MTLStoreActionStore)]; + [renderpassDesc setStencilAttachment:(nil)]; + + [renderpassDesc setRenderTargetWidth:(_width)]; + [renderpassDesc setRenderTargetHeight:(_height)]; } void MetalFramebuffer::unbind() {} -ImagePtr MetalFramebuffer::getColorImage(MTLCommandQueue *cmdQueue, +ImagePtr MetalFramebuffer::getColorImage(id cmdQueue, ImagePtr image) { if (!image) { image = Image::create(_width, _height, _channelCount, _baseType); @@ -116,26 +122,33 @@ new MetalFramebuffer(device, width, height, channelCount, baseType, MetalTextureHandler::getTextureBaseTypeSize(_baseType); size_t bytesPerImage = _height * bytesPerRow; - MTLBuffer *buffer = - _device->newBuffer(bytesPerImage, MTLResourceStorageModeShared); + id buffer = + [_device newBufferWithLength:bytesPerImage + options:MTLResourceStorageModeShared]; - MTLCommandBuffer *cmdBuffer = cmdQueue->commandBuffer(); + id cmdBuffer = [cmdQueue commandBuffer]; - MTLBlitCommandEncoder *blitCmdEncoder = cmdBuffer->blitCommandEncoder(); - blitCmdEncoder->copyFromTexture( - _colorTexture, 0, 0, MTLOrigin::Make(0, 0, 0), - MTLSize::Make(_width, _height, 1), buffer, 0, bytesPerRow, - bytesPerImage, MTLBlitOptionNone); + id blitCmdEncoder = [cmdBuffer blitCommandEncoder]; + [blitCmdEncoder copyFromTexture:_colorTexture + sourceSlice:0 + sourceLevel:0 + sourceOrigin:MTLOriginMake(0, 0, 0) + sourceSize:MTLSizeMake(_width, _height, 1) + toBuffer:buffer + destinationOffset:0 + destinationBytesPerRow:bytesPerRow + destinationBytesPerImage:bytesPerImage + options:MTLBlitOptionNone]; - blitCmdEncoder->endEncoding(); + [blitCmdEncoder endEncoding]; - cmdBuffer->commit(); - cmdBuffer->waitUntilCompleted(); + [cmdBuffer commit]; + [cmdBuffer waitUntilCompleted]; std::vector imageData(bytesPerImage); - memcpy(imageData.data(), buffer->contents(), bytesPerImage); + memcpy(imageData.data(), [buffer contents], bytesPerImage); - if (_colorTexture->pixelFormat() == MTLPixelFormatBGRA8Unorm) { + if ([_colorTexture pixelFormat] == MTLPixelFormatBGRA8Unorm) { for (unsigned int j = 0; j < _height; ++j) { unsigned int rawStart = j * (_width * _channelCount); for (unsigned int i = 0; i < _width; ++i) { @@ -148,7 +161,10 @@ new MetalFramebuffer(device, width, height, channelCount, baseType, } memcpy(image->getResourceBuffer(), imageData.data(), bytesPerImage); - buffer->release(); + +#if !__has_feature(objc_arc) + [buffer release]; +#endif // !__has_feature(objc_arc) return image; } diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm index a6dd869f..abafb40f 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #import +#include #import #include @@ -14,214 +14,234 @@ MetalState::MetalState() {} void MetalState::initialize(id mtlDevice, - MTLCommandQueue *mtlCmdQueue) { + id mtlCmdQueue) { device = mtlDevice; cmdQueue = mtlCmdQueue; #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - supportsTiledPipeline = device->supportsFamily(MTLGPUFamilyApple4); + supportsTiledPipeline = [device supportsFamily:(MTLGPUFamilyApple4)]; #else supportsTiledPipeline = false; #endif MTLDepthStencilDescriptor *depthStencilDesc = - MTLDepthStencilDescriptor::alloc()->init(); - depthStencilDesc->setDepthWriteEnabled(true); - depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionLess); - opaqueDepthStencilState = device->newDepthStencilState(depthStencilDesc); + [[MTLDepthStencilDescriptor alloc] init]; + [depthStencilDesc setDepthWriteEnabled:(true)]; + [depthStencilDesc setDepthCompareFunction:(MTLCompareFunctionLess)]; + opaqueDepthStencilState = + [device newDepthStencilStateWithDescriptor:(depthStencilDesc)]; - depthStencilDesc->setDepthWriteEnabled(false); - depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionLess); - transparentDepthStencilState = device->newDepthStencilState(depthStencilDesc); + [depthStencilDesc setDepthWriteEnabled:(false)]; + [depthStencilDesc setDepthCompareFunction:(MTLCompareFunctionLess)]; + transparentDepthStencilState = + [device newDepthStencilStateWithDescriptor:(depthStencilDesc)]; - depthStencilDesc->setDepthWriteEnabled(true); - depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionAlways); - envMapDepthStencilState = device->newDepthStencilState(depthStencilDesc); + [depthStencilDesc setDepthWriteEnabled:(true)]; + [depthStencilDesc setDepthCompareFunction:(MTLCompareFunctionAlways)]; + envMapDepthStencilState = + [device newDepthStencilStateWithDescriptor:(depthStencilDesc)]; initLinearToSRGBKernel(); } void MetalState::initLinearToSRGBKernel() { NSError *error = nil; - MTLCompileOptions *options = MTLCompileOptions::alloc()->init(); + MTLCompileOptions *options = [[MTLCompileOptions alloc] init]; #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - options->setLanguageVersion(MTLLanguageVersion2_3); + [options setLanguageVersion:(MTLLanguageVersion2_3)]; #else - options->setLanguageVersion(MTLLanguageVersion2_0); + [options setLanguageVersion:(MTLLanguageVersion2_0)]; #endif // defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - options->setFastMathEnabled(true); + [options setFastMathEnabled:(true)]; #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) bool useTiledPipeline = supportsTiledPipeline; if (useTiledPipeline) { - NSString *linearToSRGB_kernel = NSString::string( - "#include \n" - "#include \n" - "\n" - "\n" - "using namespace metal;\n" - "\n" - "\n" - "struct RenderTarget {\n" - " half4 colorTarget [[color(0)]];\n" - "};\n" - "\n" - "\n" - "\n" - "\n" - "half4 linearToSRGB(half4 color_linear)\n" - "{\n" - " \n" - " half4 color_srgb;\n" - " \n" - " for(int i = 0; i < 3; ++i)\n" - " color_srgb[i] = (color_linear[i] < 0.0031308) ?\n" - " (12.92 * color_linear[i]) :\n" - " (1.055 * pow(color_linear[i], 1.0h / 2.2h) - 0.055);\n" - " color_srgb[3] = color_linear[3];\n" - " return color_srgb;\n" - "}\n" - "\n" - "kernel void LinearToSRGB_kernel(\n" - " imageblock imageBlock,\n" - " ushort2 tid [[ thread_position_in_threadgroup ]])\n" - "{\n" - " \n" - " RenderTarget linearValue = imageBlock.read(tid);\n" - " RenderTarget srgbValue;\n" - " srgbValue.colorTarget = linearToSRGB(linearValue.colorTarget);\n" - " imageBlock.write(srgbValue, tid);\n" - "};\n", - NS::UTF8StringEncoding); - MTLLibrary *library = - device->newLibrary(linearToSRGB_kernel, options, &error); - MTLFunction *function = library->newFunction( - NSString::string("LinearToSRGB_kernel", NS::UTF8StringEncoding)); + NSString *linearToSRGB_kernel = [NSString + stringWithCString: + ("#include \n" + "#include \n" + "\n" + "\n" + "using namespace metal;\n" + "\n" + "\n" + "struct RenderTarget {\n" + " half4 colorTarget [[color(0)]];\n" + "};\n" + "\n" + "\n" + "\n" + "\n" + "half4 linearToSRGB(half4 color_linear)\n" + "{\n" + " \n" + " half4 color_srgb;\n" + " \n" + " for(int i = 0; i < 3; ++i)\n" + " color_srgb[i] = (color_linear[i] < 0.0031308) ?\n" + " (12.92 * color_linear[i]) :\n" + " (1.055 * pow(color_linear[i], 1.0h / 2.2h) - " + "0.055);\n" + " color_srgb[3] = color_linear[3];\n" + " return color_srgb;\n" + "}\n" + "\n" + "kernel void LinearToSRGB_kernel(\n" + " imageblock " + "imageBlock,\n" + " ushort2 tid [[ thread_position_in_threadgroup ]])\n" + "{\n" + " \n" + " RenderTarget linearValue = imageBlock.read(tid);\n" + " RenderTarget srgbValue;\n" + " srgbValue.colorTarget = " + "linearToSRGB(linearValue.colorTarget);\n" + " imageBlock.write(srgbValue, tid);\n" + "};\n") + encoding:NSUTF8StringEncoding]; + id library = [device newLibraryWithSource:linearToSRGB_kernel + options:options + error:&error]; + id function = [library + newFunctionWithName:([NSString + stringWithCString:("LinearToSRGB_kernel") + encoding:NSUTF8StringEncoding])]; MTLTileRenderPipelineDescriptor *renderPipelineDescriptor = - MTLTileRenderPipelineDescriptor::alloc()->init(); - renderPipelineDescriptor->setRasterSampleCount(1); - renderPipelineDescriptor->colorAttachments()->object(0)->setPixelFormat( - MTLPixelFormatBGRA8Unorm); - renderPipelineDescriptor->setTileFunction(function); - linearToSRGB_pso = device->newRenderPipelineState(renderPipelineDescriptor, - 0, nil, &error); + [[MTLTileRenderPipelineDescriptor alloc] init]; + [renderPipelineDescriptor setRasterSampleCount:(1)]; + [[[renderPipelineDescriptor colorAttachments] objectAtIndexedSubscript:0] + setPixelFormat:MTLPixelFormatBGRA8Unorm]; + [renderPipelineDescriptor setTileFunction:(function)]; + + linearToSRGB_pso = [device + newRenderPipelineStateWithTileDescriptor:(renderPipelineDescriptor) + options:0 + reflection:nil + error:&error]; } #else useTiledPipeline = false; #endif if (!useTiledPipeline) { - NSString *linearToSRGB_kernel = NSString::string( - "#include \n" - "#include \n" - " \n" - "using namespace metal; \n" - " \n" - "struct VSOutput \n" - "{ \n" - " float4 position [[position]]; \n" - "}; \n" - " \n" - "vertex VSOutput VertexMain(uint vertexId [[ vertex_id ]]) \n" - "{ \n" - " VSOutput vsOut; \n" - " \n" - " switch(vertexId) \n" - " { \n" - " case 0: vsOut.position = float4(-1, -1, 0.5, 1); break; \n" - " case 1: vsOut.position = float4(-1, 3, 0.5, 1); break; \n" - " case 2: vsOut.position = float4( 3, -1, 0.5, 1); break; \n" - " }; \n" - " \n" - " return vsOut; \n" - "} \n" - " \n" - "half4 linearToSRGB(half4 color_linear) \n" - "{ \n" - " half4 color_srgb; \n" - " for(int i = 0; i < 3; ++i) \n" - " color_srgb[i] = (color_linear[i] < 0.0031308) ? \n" - " (12.92 * color_linear[i]) : \n" - " (1.055 * pow(color_linear[i], 1.0h / 2.2h) - 0.055);\n" - " color_srgb[3] = color_linear[3]; \n" - " return color_srgb; \n" - "} \n" - " \n" - "fragment half4 FragmentMain( \n" - " texture2d inputTex [[ texture(0) ]], \n" - " float4 fragCoord [[ position ]] \n" - ") \n" - "{ \n" - " constexpr sampler ss( \n" - " coord::pixel, \n" - " address::clamp_to_border, \n" - " filter::linear); \n" - " return linearToSRGB(inputTex.sample(ss, fragCoord.xy)); \n" - "} \n", - NS::UTF8StringEncoding); - - MTLLibrary *library = - device->newLibrary(linearToSRGB_kernel, options, &error); - - MTLFunction *vertexfunction = library->newFunction( - NSString::string("VertexMain", NS::UTF8StringEncoding)); - MTLFunction *Fragmentfunction = library->newFunction( - NSString::string("FragmentMain", NS::UTF8StringEncoding)); + NSString *linearToSRGB_kernel = [NSString + stringWithCString: + ("#include \n" + "#include \n" + " \n" + "using namespace metal; \n" + " \n" + "struct VSOutput \n" + "{ \n" + " float4 position [[position]]; \n" + "}; \n" + " \n" + "vertex VSOutput VertexMain(uint vertexId [[ vertex_id ]]) \n" + "{ \n" + " VSOutput vsOut; \n" + " \n" + " switch(vertexId) \n" + " { \n" + " case 0: vsOut.position = float4(-1, -1, 0.5, 1); break; \n" + " case 1: vsOut.position = float4(-1, 3, 0.5, 1); break; \n" + " case 2: vsOut.position = float4( 3, -1, 0.5, 1); break; \n" + " }; \n" + " \n" + " return vsOut; \n" + "} \n" + " \n" + "half4 linearToSRGB(half4 color_linear) \n" + "{ \n" + " half4 color_srgb; \n" + " for(int i = 0; i < 3; ++i) \n" + " color_srgb[i] = (color_linear[i] < 0.0031308) ? \n" + " (12.92 * color_linear[i]) : \n" + " (1.055 * pow(color_linear[i], 1.0h / 2.2h) - 0.055);\n" + " color_srgb[3] = color_linear[3]; \n" + " return color_srgb; \n" + "} \n" + " \n" + "fragment half4 FragmentMain( \n" + " texture2d inputTex [[ texture(0) ]], \n" + " float4 fragCoord [[ position ]] \n" + ") \n" + "{ \n" + " constexpr sampler ss( \n" + " coord::pixel, \n" + " address::clamp_to_border, \n" + " filter::linear); \n" + " return linearToSRGB(inputTex.sample(ss, fragCoord.xy)); \n" + "} \n") + encoding:NSUTF8StringEncoding]; + + id library = [device newLibraryWithSource:(linearToSRGB_kernel) + options:options + error:&error]; + + id vertexfunction = [library + newFunctionWithName:([NSString + stringWithCString:("VertexMain") + encoding:NSUTF8StringEncoding])]; + id Fragmentfunction = [library + newFunctionWithName:([NSString + stringWithCString:("FragmentMain") + encoding:NSUTF8StringEncoding])]; MTLRenderPipelineDescriptor *renderPipelineDesc = - MTLRenderPipelineDescriptor::alloc()->init(); - renderPipelineDesc->setVertexFunction(vertexfunction); - renderPipelineDesc->setFragmentFunction(Fragmentfunction); - renderPipelineDesc->colorAttachments()->object(0)->setPixelFormat( - MTLPixelFormatBGRA8Unorm); - renderPipelineDesc->setDepthAttachmentPixelFormat( - MTLPixelFormatDepth32Float); + [[MTLRenderPipelineDescriptor alloc] init]; + [renderPipelineDesc setVertexFunction:(vertexfunction)]; + [renderPipelineDesc setFragmentFunction:(Fragmentfunction)]; + [[[renderPipelineDesc colorAttachments] objectAtIndexedSubscript:0] + setPixelFormat:(MTLPixelFormatBGRA8Unorm)]; + [renderPipelineDesc + setDepthAttachmentPixelFormat:(MTLPixelFormatDepth32Float)]; linearToSRGB_pso = - device->newRenderPipelineState(renderPipelineDesc, &error); + [device newRenderPipelineStateWithDescriptor:(renderPipelineDesc) + error:&error]; } } void MetalState::triggerProgrammaticCapture() { - MTLCaptureManager *captureManager = - MTLCaptureManager::sharedCaptureManager(); - MTLCaptureDescriptor *captureDescriptor = - MTLCaptureDescriptor::alloc()->init(); + MTLCaptureManager *captureManager = [MTLCaptureManager sharedCaptureManager]; + MTLCaptureDescriptor *captureDescriptor = [[MTLCaptureDescriptor alloc] init]; - captureDescriptor->setCaptureObject(device); + [captureDescriptor setCaptureObject:(device)]; NSError *error = nil; - if (!captureManager->startCapture(captureDescriptor, &error)) { + if (![captureManager startCaptureWithDescriptor:captureDescriptor + error:&error]) { #if WITH_APPLE_NSLOG - NS::Log(NSString::string("Failed to start capture, error %@", error)); + NSLog(@"Failed to start capture, error %@", error); #endif /* WITH_APPLE_NSLOG */ } } void MetalState::stopProgrammaticCapture() { - MTLCaptureManager *captureManager = - MTLCaptureManager::sharedCaptureManager(); - captureManager->stopCapture(); + MTLCaptureManager *captureManager = [MTLCaptureManager sharedCaptureManager]; + [captureManager stopCapture]; } void MetalState::beginCommandBuffer() { - cmdBuffer = cmdQueue->commandBuffer(); + cmdBuffer = [cmdQueue commandBuffer]; inFlightCommandBuffers++; } void MetalState::beginEncoder(MTLRenderPassDescriptor *renderpassDesc) { - renderCmdEncoder = cmdBuffer->renderCommandEncoder(renderpassDesc); + renderCmdEncoder = + [cmdBuffer renderCommandEncoderWithDescriptor:renderpassDesc]; } -void MetalState::endEncoder() { renderCmdEncoder->endEncoding(); } +void MetalState::endEncoder() { [renderCmdEncoder endEncoding]; } void MetalState::endCommandBuffer() { endEncoder(); - cmdBuffer->addCompletedHandler([&](MTLCommandBuffer *buffer) -> void { - inFlightCommandBuffers--; - inFlightCV.notify_one(); - }); - cmdBuffer->commit(); - cmdBuffer->waitUntilCompleted(); + [cmdBuffer addCompletedHandler:([&](id buffer) -> void { + inFlightCommandBuffers--; + inFlightCV.notify_one(); + })]; + [cmdBuffer commit]; + [cmdBuffer waitUntilCompleted]; } void MetalState::waitForComplition() { diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm index 2b5f9b3c..6882877f 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm @@ -33,41 +33,41 @@ return true; } -MTLSamplerState *MetalTextureHandler::getSamplerState( +id MetalTextureHandler::getSamplerState( const ImageSamplingProperties &samplingProperties) { if (_imageSamplerStateMap.find(samplingProperties) == _imageSamplerStateMap.end()) { - MTLSamplerDescriptor *samplerDesc = - MTLSamplerDescriptor::alloc()->init(); - samplerDesc->setSAddressMode( - mapAddressModeToMetal(samplingProperties.uaddressMode)); - samplerDesc->setRAddressMode( - mapAddressModeToMetal(samplingProperties.uaddressMode)); - samplerDesc->setTAddressMode( - mapAddressModeToMetal(samplingProperties.vaddressMode)); - samplerDesc->setBorderColor(samplingProperties.defaultColor[0] == 0 + MTLSamplerDescriptor *samplerDesc = [[MTLSamplerDescriptor alloc] init]; + [samplerDesc + setSAddressMode:mapAddressModeToMetal(samplingProperties.uaddressMode)]; + [samplerDesc + setRAddressMode:mapAddressModeToMetal(samplingProperties.uaddressMode)]; + [samplerDesc + setTAddressMode:mapAddressModeToMetal(samplingProperties.vaddressMode)]; + [samplerDesc setBorderColor:samplingProperties.defaultColor[0] == 0 ? MTLSamplerBorderColorOpaqueBlack - : MTLSamplerBorderColorOpaqueWhite); + : MTLSamplerBorderColorOpaqueWhite]; MTLSamplerMinMagFilter minmagFilter; MTLSamplerMipFilter mipFilter; mapFilterTypeToMetal(samplingProperties.filterType, samplingProperties.enableMipmaps, minmagFilter, mipFilter); // Magnification filters are more restrictive than minification - samplerDesc->setMagFilter(MTLSamplerMinMagFilterLinear); - samplerDesc->setMinFilter(minmagFilter); - samplerDesc->setMipFilter(mipFilter); - samplerDesc->setMaxAnisotropy(16); + [samplerDesc setMagFilter:MTLSamplerMinMagFilterLinear]; + [samplerDesc setMinFilter:minmagFilter]; + [samplerDesc setMipFilter:mipFilter]; + [samplerDesc setMaxAnisotropy:16]; _imageSamplerStateMap[samplingProperties] = - _device->newSamplerState(samplerDesc); + [_device newSamplerStateWithDescriptor:samplerDesc]; } return _imageSamplerStateMap[samplingProperties]; } -bool MetalTextureHandler::bindImage(MTLRenderCommandEncoder *renderCmdEncoder, - int textureUnit, ImagePtr image) { +bool MetalTextureHandler::bindImage( + id renderCmdEncoder, int textureUnit, + ImagePtr image) { // Create renderer resources if needed. if (image->getResourceId() == MslProgram::UNDEFINED_METAL_RESOURCE_ID) { if (!createRenderResources(image, true)) { @@ -77,16 +77,18 @@ _boundTextureLocations[textureUnit] = image->getResourceId(); - renderCmdEncoder->setFragmentTexture(_metalTextureMap[image->getResourceId()], - textureUnit); - renderCmdEncoder->setFragmentSamplerState( - getSamplerState(_imageBindingInfo[image->getResourceId()].second), - textureUnit); + [renderCmdEncoder setFragmentTexture:_metalTextureMap[image->getResourceId()] + atIndex:textureUnit]; + [renderCmdEncoder + setFragmentSamplerState:getSamplerState( + _imageBindingInfo[image->getResourceId()] + .second) + atIndex:textureUnit]; return true; } -MTLTexture *MetalTextureHandler::getAssociatedMetalTexture(ImagePtr image) { +id MetalTextureHandler::getAssociatedMetalTexture(ImagePtr image) { if (image) { auto tex = _metalTextureMap.find(image->getResourceId()); if (tex != _metalTextureMap.end()) @@ -95,7 +97,7 @@ return nil; } -MTLTexture * +id MetalTextureHandler::getMTLTextureForImage(unsigned int index) const { auto imageInfo = _imageBindingInfo.find(index); if (imageInfo != _imageBindingInfo.end()) { @@ -111,7 +113,7 @@ return nil; } -MTLSamplerState * +id MetalTextureHandler::getMTLSamplerStateForImage(unsigned int index) { auto imageInfo = _imageBindingInfo.find(index); if (imageInfo != _imageBindingInfo.end()) { @@ -134,7 +136,7 @@ bool MetalTextureHandler::createRenderResources(ImagePtr image, bool generateMipMaps) { - MTLTexture *texture = nil; + id texture = nil; MTLPixelFormat pixelFormat; MTLDataType dataType; @@ -146,29 +148,30 @@ mapTextureFormatToMetal(image->getBaseType(), image->getChannelCount(), false, dataType, pixelFormat); - MTLTextureDescriptor *texDesc = MTLTextureDescriptor::alloc()->init(); - texDesc->setTextureType(MTLTextureType2D); - texDesc->setWidth(image->getWidth()); - texDesc->setHeight(image->getHeight()); - texDesc->setMipmapLevelCount(generateMipMaps ? image->getMaxMipCount() : 1); - texDesc->setUsage(MTLTextureUsageShaderRead | + MTLTextureDescriptor *texDesc = [MTLTextureDescriptor + texture2DDescriptorWithPixelFormat:pixelFormat + width:image->getWidth() + height:image->getHeight() + mipmapped:generateMipMaps ? YES : NO]; + + [texDesc setMipmapLevelCount:generateMipMaps ? image->getMaxMipCount() : 1]; + [texDesc setUsage:MTLTextureUsageShaderRead | // For now, we set generate mip maps flag off, // when we want to use the texture as render target - (!generateMipMaps ? MTLTextureUsageRenderTarget : 0)); - texDesc->setResourceOptions(MTLResourceStorageModePrivate); - texDesc->setPixelFormat(pixelFormat); + (!generateMipMaps ? MTLTextureUsageRenderTarget : 0)]; + [texDesc setResourceOptions:MTLResourceStorageModePrivate]; if (generateMipMaps) { if (image->getChannelCount() == 1) { - texDesc->setSwizzle(MTLTextureSwizzleChannels{ - MTLTextureSwizzleRed, MTLTextureSwizzleRed, - MTLTextureSwizzleRed, MTLTextureSwizzleRed}); + [texDesc setSwizzle:(MTLTextureSwizzleChannels){ + MTLTextureSwizzleRed, MTLTextureSwizzleRed, + MTLTextureSwizzleRed, MTLTextureSwizzleRed}]; } else if (image->getChannelCount() == 2) { - texDesc->setSwizzle(MTLTextureSwizzleChannels{ - MTLTextureSwizzleRed, MTLTextureSwizzleGreen, - MTLTextureSwizzleRed, MTLTextureSwizzleGreen}); + [texDesc setSwizzle:(MTLTextureSwizzleChannels){ + MTLTextureSwizzleRed, MTLTextureSwizzleGreen, + MTLTextureSwizzleRed, MTLTextureSwizzleGreen}]; } } - texture = _device->newTexture(texDesc); + texture = [_device newTextureWithDescriptor:texDesc]; _metalTextureMap[resourceId] = texture; image->setResourceId(resourceId); } else { @@ -178,16 +181,16 @@ texture = _metalTextureMap[image->getResourceId()]; } - MTLCommandQueue *cmdQueue = _device->newCommandQueue(); - MTLCommandBuffer *cmdBuffer = cmdQueue->commandBuffer(); + id cmdQueue = [_device newCommandQueue]; + id cmdBuffer = [cmdQueue commandBuffer]; - MTLBlitCommandEncoder *blitCmdEncoder = cmdBuffer->blitCommandEncoder(); + id blitCmdEncoder = [cmdBuffer blitCommandEncoder]; - NS::UInteger channelCount = image->getChannelCount(); + NSUInteger channelCount = image->getChannelCount(); - NS::UInteger sourceBytesPerRow = image->getWidth() * channelCount * - getTextureBaseTypeSize(image->getBaseType()); - NS::UInteger sourceBytesPerImage = sourceBytesPerRow * image->getHeight(); + NSUInteger sourceBytesPerRow = image->getWidth() * channelCount * + getTextureBaseTypeSize(image->getBaseType()); + NSUInteger sourceBytesPerImage = sourceBytesPerRow * image->getHeight(); std::vector rearrangedDataF; std::vector rearrangedDataC; @@ -232,26 +235,35 @@ channelCount = 4; } - MTLBuffer *buffer = nil; + id buffer = nil; if (imageData) { - buffer = _device->newBuffer(imageData, sourceBytesPerImage, - MTLStorageModeShared); - blitCmdEncoder->copyFromBuffer( - buffer, 0, sourceBytesPerRow, sourceBytesPerImage, - MTLSize::Make(image->getWidth(), image->getHeight(), 1), texture, 0, - 0, MTLOrigin::Make(0, 0, 0)); + buffer = [_device newBufferWithBytes:imageData + length:sourceBytesPerImage + options:MTLResourceStorageModeShared]; + [blitCmdEncoder copyFromBuffer:buffer + sourceOffset:0 + sourceBytesPerRow:sourceBytesPerRow + sourceBytesPerImage:sourceBytesPerImage + sourceSize:MTLSizeMake(image->getWidth(), + image->getHeight(), 1) + toTexture:texture + destinationSlice:0 + destinationLevel:0 + destinationOrigin:MTLOriginMake(0, 0, 0)]; } if (generateMipMaps && image->getMaxMipCount() > 1) - blitCmdEncoder->generateMipmaps(texture); + [blitCmdEncoder generateMipmapsForTexture:texture]; - blitCmdEncoder->endEncoding(); + [blitCmdEncoder endEncoding]; - cmdBuffer->commit(); - cmdBuffer->waitUntilCompleted(); + [cmdBuffer commit]; + [cmdBuffer waitUntilCompleted]; if (buffer) - buffer->release(); +#if !__has_feature(objc_arc) + [buffer release]; +#endif // !__has_feature(objc_arc) return true; } @@ -268,7 +280,9 @@ unsigned int resourceId = image->getResourceId(); auto tex = _metalTextureMap.find(resourceId); if (tex != _metalTextureMap.end()) { - tex->second->release(); +#if !__has_feature(objc_arc) + [tex->second release]; +#endif // // !__has_feature(objc_arc) } _metalTextureMap.erase(resourceId); image->setResourceId(MslProgram::UNDEFINED_METAL_RESOURCE_ID); @@ -332,9 +346,11 @@ } } -void MetalTextureHandler::mapTextureFormatToMetal( - Image::BaseType baseType, unsigned int channelCount, bool srgb, - MTLDataType &dataType, MTLPixelFormat &pixelFormat) { +void MetalTextureHandler::mapTextureFormatToMetal(Image::BaseType baseType, + unsigned int channelCount, + bool srgb, + MTLDataType &dataType, + MTLPixelFormat &pixelFormat) { if (baseType == Image::BaseType::UINT8) { dataType = MTLDataTypeChar; switch (channelCount) { diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm index 9e097de1..f92872cb 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm @@ -233,10 +233,11 @@ } MeshIndexBuffer &indexData = part->getIndices(); - MTL(renderCmdEncoder) - ->drawIndexedPrimitives(MTLPrimitiveTypeTriangle, indexData.size(), - MTLIndexTypeUInt32, - _glProgram->getIndexBuffer(part), 0); + [MTL(renderCmdEncoder) drawIndexedPrimitives:(MTLPrimitiveTypeTriangle) + indexCount:indexData.size() + indexType:MTLIndexTypeUInt32 + indexBuffer:_glProgram->getIndexBuffer(part) + indexBufferOffset:0]; } void MslMaterial::unbindGeometry() { diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm index 166f27a3..daa4d23b 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm @@ -3,10 +3,12 @@ // SPDX-License-Identifier: Apache-2.0 // -// #import +#import + #include #include #include + #import #include @@ -124,8 +126,8 @@ int GetStrideOfMetalType(MTLDataType type) { return 0; } -MTLRenderPipelineState *MslProgram::build(id device, - MetalFramebufferPtr framebuffer) { +id MslProgram::build(id device, + MetalFramebufferPtr framebuffer) { StringVec errors; const string errorType("MSL program creation error."); @@ -142,16 +144,16 @@ int GetStrideOfMetalType(MTLDataType type) { desiredStages++; } - MTLCompileOptions *options = MTLCompileOptions::alloc()->init(); + MTLCompileOptions *options = [[MTLCompileOptions alloc] init]; #if defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - options->setLanguageVersion(MTLLanguageVersion2_3); + [options setLanguageVersion:(MTLLanguageVersion2_3)]; #else - options->setLanguageVersion(MTLLanguageVersion2_0); + [options setLanguageVersion:(MTLLanguageVersion2_0)]; #endif // defined(MAC_OS_VERSION_11_0) || defined(IPHONE_OS_VERSION_14_0) - options->setFastMathEnabled(true); + [options setFastMathEnabled:(true)]; // Create vertex shader - MTLFunction *vertexShaderId = nil; + id vertexShaderId = nil; { string &vertexShaderSource = _stages[Stage::VERTEX]; if (vertexShaderSource.length() < 1) { @@ -160,19 +162,24 @@ int GetStrideOfMetalType(MTLDataType type) { } NSString *sourcCode = - NSString::string(vertexShaderSource.c_str(), NS::UTF8StringEncoding); - MTLLibrary *library = device->newLibrary(sourcCode, options, &error); + [NSString stringWithCString:(vertexShaderSource.c_str()) + encoding:NSUTF8StringEncoding]; + id library = [device newLibraryWithSource:sourcCode + options:options + error:&error]; if (library == nil) { errors.push_back("Error in compiling vertex shader:"); if (error) { - errors.push_back(error->localizedDescription()->utf8String()); + errors.push_back([[error localizedDescription] UTF8String]); } return nil; } - vertexShaderId = library->newFunction( - NSString::string("VertexMain", NS::UTF8StringEncoding)); + vertexShaderId = [library + newFunctionWithName:([NSString + stringWithCString:("VertexMain") + encoding:NSUTF8StringEncoding])]; if (vertexShaderId) { stagesBuilt++; @@ -187,24 +194,29 @@ int GetStrideOfMetalType(MTLDataType type) { } // Fragment shader compilation code - MTLFunction *fragmentShaderId = nil; + id fragmentShaderId = nil; { - NSString *sourcCode = NSString::string(fragmentShaderSource.c_str(), - NS::UTF8StringEncoding); - MTLLibrary *library = device->newLibrary(sourcCode, options, &error); + NSString *sourcCode = + [NSString stringWithCString:(fragmentShaderSource.c_str()) + encoding:NSUTF8StringEncoding]; + id library = [device newLibraryWithSource:sourcCode + options:options + error:&error]; if (!library) { errors.push_back("Error in compiling fragment shader:"); if (error) { std::string libCompilationError = - error->localizedDescription()->utf8String(); + [[error localizedDescription] UTF8String]; printf("Compilation Errors:%s\n", libCompilationError.c_str()); errors.push_back(libCompilationError); return nil; } } - fragmentShaderId = library->newFunction( - NSString::string("FragmentMain", NS::UTF8StringEncoding)); + fragmentShaderId = [library + newFunctionWithName:([NSString + stringWithCString:("FragmentMain") + encoding:NSUTF8StringEncoding])]; assert(fragmentShaderId); if (library) { @@ -212,51 +224,48 @@ int GetStrideOfMetalType(MTLDataType type) { } } - // Link stages to a programs + // Link stages to a program if (stagesBuilt == desiredStages) { MTLRenderPipelineDescriptor *psoDesc = - MTLRenderPipelineDescriptor::alloc()->init(); - psoDesc->setVertexFunction(vertexShaderId); - psoDesc->setFragmentFunction(fragmentShaderId); - psoDesc->colorAttachments()->object(0)->setPixelFormat( - framebuffer->getColorTexture()->pixelFormat()); - psoDesc->setDepthAttachmentPixelFormat(MTLPixelFormatDepth32Float); + [[MTLRenderPipelineDescriptor alloc] init]; + psoDesc.vertexFunction = vertexShaderId; + psoDesc.fragmentFunction = fragmentShaderId; + psoDesc.colorAttachments[0].pixelFormat = + framebuffer->getColorTexture().pixelFormat; + psoDesc.depthAttachmentPixelFormat = MTLPixelFormatDepth32Float; if (_shader->hasAttribute(HW::ATTR_TRANSPARENT)) { - psoDesc->colorAttachments()->object(0)->setBlendingEnabled(YES); - psoDesc->colorAttachments()->object(0)->setRgbBlendOperation( - MTLBlendOperationAdd); - psoDesc->colorAttachments()->object(0)->setAlphaBlendOperation( - MTLBlendOperationAdd); - psoDesc->colorAttachments()->object(0)->setSourceRGBBlendFactor( - MTLBlendFactorSourceAlpha); - psoDesc->colorAttachments()->object(0)->setSourceAlphaBlendFactor( - MTLBlendFactorSourceAlpha); - psoDesc->colorAttachments()->object(0)->setDestinationRGBBlendFactor( - MTLBlendFactorOneMinusSourceAlpha); - psoDesc->colorAttachments()->object(0)->setDestinationAlphaBlendFactor( - MTLBlendFactorOneMinusSourceAlpha); + psoDesc.colorAttachments[0].blendingEnabled = YES; + psoDesc.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd; + psoDesc.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd; + psoDesc.colorAttachments[0].sourceRGBBlendFactor = + MTLBlendFactorSourceAlpha; + psoDesc.colorAttachments[0].sourceAlphaBlendFactor = + MTLBlendFactorSourceAlpha; + psoDesc.colorAttachments[0].destinationRGBBlendFactor = + MTLBlendFactorOneMinusSourceAlpha; + psoDesc.colorAttachments[0].destinationAlphaBlendFactor = + MTLBlendFactorOneMinusSourceAlpha; _alphaBlendingEnabled = true; } - MTLVertexDescriptor *vd = MTLVertexDescriptor::alloc()->init(); + MTLVertexDescriptor *vd = [[MTLVertexDescriptor alloc] init]; - for (int i = 0; i < vertexShaderId->vertexAttributes()->count(); ++i) { - MTLVertexAttribute *vertexAttrib = - vertexShaderId->vertexAttributes()->object(i); + for (int i = 0; i < (int)vertexShaderId.vertexAttributes.count; ++i) { + MTLVertexAttribute *vertexAttrib = vertexShaderId.vertexAttributes[i]; - vd->attributes()->object(i)->setBufferIndex(i); - vd->attributes()->object(i)->setFormat( - GetMetalFormatFromMetalType(vertexAttrib->attributeType())); - vd->attributes()->object(i)->setOffset(0); + vd.attributes[i].bufferIndex = i; + vd.attributes[i].format = + GetMetalFormatFromMetalType(vertexAttrib.attributeType); + vd.attributes[i].offset = 0; InputPtr inputPtr = std::make_shared( - vertexAttrib->attributeIndex(), vertexAttrib->attributeType(), - GetStrideOfMetalType(vertexAttrib->attributeType()), EMPTY_STRING); + [vertexAttrib attributeIndex], [vertexAttrib attributeType], + GetStrideOfMetalType([vertexAttrib attributeType]), EMPTY_STRING); // Attempt to pull out the set number for specific attributes // - string sattributeName(vertexAttrib->name()->utf8String()); + string sattributeName([[vertexAttrib name] UTF8String]); const string colorSet(HW::IN_COLOR + "_"); const string uvSet(HW::IN_TEXCOORD + "_"); if (string::npos != sattributeName.find(colorSet)) { @@ -273,25 +282,29 @@ int GetStrideOfMetalType(MTLDataType type) { _attributeList[sattributeName] = inputPtr; - vd->layouts()->object(i)->setStride( - GetStrideOfMetalType(vertexAttrib->attributeType())); - vd->layouts()->object(i)->setStepFunction( - MTLVertexStepFunctionPerVertex); + vd.layouts[i].stride = GetStrideOfMetalType(vertexAttrib.attributeType); + vd.layouts[i].stepFunction = MTLVertexStepFunctionPerVertex; } - psoDesc->setVertexDescriptor(vd); + psoDesc.vertexDescriptor = vd; - _pso = device->newRenderPipelineState(psoDesc, - MTLPipelineOptionArgumentInfo | - MTLPipelineOptionBufferTypeInfo, - &_psoReflection, &error); + MTLRenderPipelineReflection *reflection = nil; + _pso = [device + newRenderPipelineStateWithDescriptor:psoDesc + options:(MTLPipelineOptionArgumentInfo | + MTLPipelineOptionBufferTypeInfo) + reflection:&reflection + error:&error]; + _psoReflection = reflection; - _pso->retain(); - _psoReflection->retain(); +#if !__has_feature(objc_arc) + [_pso retain]; + [_psoReflection retain]; +#endif // !__has_feature(objc_arc) if (error) { errors.push_back("Error in linking program:"); - errors.push_back(error->localizedDescription()->utf8String()); + errors.push_back([[error localizedDescription] UTF8String]); } } else { errors.push_back("Failed to build all stages."); @@ -310,16 +323,16 @@ int GetStrideOfMetalType(MTLDataType type) { return _pso; } -bool MslProgram::bind(MTLRenderCommandEncoder *renderCmdEncoder) { +bool MslProgram::bind(id renderCmdEncoder) { if (_pso != nil) { - renderCmdEncoder->setRenderPipelineState(_pso); + [renderCmdEncoder setRenderPipelineState:_pso]; return true; } return false; } void MslProgram::prepareUsedResources( - MTLRenderCommandEncoder *renderCmdEncoder, CameraPtr cam, + id renderCmdEncoder, CameraPtr cam, GeometryHandlerPtr geometryHandler, ImageHandlerPtr imageHandler, LightHandlerPtr lightHandler) { // Bind the program to use @@ -342,7 +355,7 @@ int GetStrideOfMetalType(MTLDataType type) { bindUniformBuffers(renderCmdEncoder, lightHandler, cam); } -void MslProgram::bindAttribute(MTLRenderCommandEncoder *renderCmdEncoder, +void MslProgram::bindAttribute(id renderCmdEncoder, const MslProgram::InputMap &inputs, MeshPtr mesh) { const string errorType("MSL bind attribute error."); @@ -400,13 +413,16 @@ int GetStrideOfMetalType(MTLDataType type) { } // Create a buffer based on attribute type. - MTLBuffer *buffer = _device->newBuffer(bufferData, bufferSize, - MTLResourceStorageModeShared); + id buffer = + [_device newBufferWithBytes:bufferData + length:bufferSize + options:MTLResourceStorageModeShared]; _attributeBufferIds[input.first] = buffer; } - renderCmdEncoder->setVertexBuffer(_attributeBufferIds[input.first], 0, - location); + [renderCmdEncoder setVertexBuffer:_attributeBufferIds[input.first] + offset:0 + atIndex:location]; } } @@ -421,14 +437,15 @@ int GetStrideOfMetalType(MTLDataType type) { if (_indexBufferIds.find(part) == _indexBufferIds.end()) { MeshIndexBuffer &indexData = part->getIndices(); size_t indexBufferSize = indexData.size(); - MTLBuffer *indexBuffer = - _device->newBuffer(&indexData[0], indexBufferSize * sizeof(uint32_t), - MTLStorageModeShared); + id indexBuffer = + [_device newBufferWithBytes:&indexData[0] + length:indexBufferSize * sizeof(uint32_t) + options:MTLStorageModeShared]; _indexBufferIds[part] = indexBuffer; } } -void MslProgram::bindMesh(MTLRenderCommandEncoder *renderCmdEncoder, +void MslProgram::bindMesh(id renderCmdEncoder, MeshPtr mesh) { StringVec errors; const string errorType("MSL geometry bind error."); @@ -496,17 +513,25 @@ int GetStrideOfMetalType(MTLDataType type) { void MslProgram::unbindGeometry() { // Clean up buffers // + // (1) slight optimization when ARC is enabled... +#if !__has_feature(objc_arc) for (const auto &attributeBufferId : _attributeBufferIds) { - attributeBufferId.second->release(); + [attributeBufferId.second release]; } +#endif // !__has_feature(objc_arc) + _attributeBufferIds.clear(); + + // (2) slight optimization when ARC is enabled... +#if !__has_feature(objc_arc) for (const auto &indexBufferId : _indexBufferIds) { - indexBufferId.second->release(); + [indexBufferId.second release]; } +#endif // !__has_feature(objc_arc) _indexBufferIds.clear(); } -ImagePtr MslProgram::bindTexture(MTLRenderCommandEncoder *renderCmdEncoder, +ImagePtr MslProgram::bindTexture(id renderCmdEncoder, unsigned int uniformLocation, const FilePath &filePath, ImageSamplingProperties samplingProperties, @@ -519,7 +544,7 @@ int GetStrideOfMetalType(MTLDataType type) { return bindTexture(renderCmdEncoder, uniformLocation, image, imageHandler); } -ImagePtr MslProgram::bindTexture(MTLRenderCommandEncoder *renderCmdEncoder, +ImagePtr MslProgram::bindTexture(id renderCmdEncoder, unsigned int uniformLocation, ImagePtr image, ImageHandlerPtr imageHandler) { // Acquire the image. @@ -544,16 +569,15 @@ int GetStrideOfMetalType(MTLDataType type) { return nullptr; } -void MslProgram::bindTextures(MTLRenderCommandEncoder *renderCmdEncoder, +void MslProgram::bindTextures(id renderCmdEncoder, LightHandlerPtr lightHandler, ImageHandlerPtr imageHandler) { const VariableBlock &publicUniforms = _shader->getStage(Stage::PIXEL).getUniformBlock(HW::PUBLIC_UNIFORMS); - for (NS::UInteger argIdx = 0; - argIdx < _psoReflection->fragmentArguments()->count(); argIdx++) { - if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTLArgumentTypeTexture) { + for (NSUInteger argIdx = 0; argIdx < [_psoReflection fragmentArguments].count; + argIdx++) { + if ([[_psoReflection fragmentArguments] objectAtIndex:(argIdx)].type == + MTLArgumentTypeTexture) { bool found = false; if (lightHandler) { @@ -562,10 +586,9 @@ int GetStrideOfMetalType(MTLDataType type) { {HW::ENV_RADIANCE, lightHandler->getEnvRadianceMap()}, {HW::ENV_IRRADIANCE, lightHandler->getEnvIrradianceMap()}}; for (const auto &env : envLights) { - std::string str(_psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String()); + std::string str( + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String); size_t loc = str.find(env.first); if (loc != std::string::npos && env.second) { ImageSamplingProperties samplingProperties; @@ -579,9 +602,9 @@ int GetStrideOfMetalType(MTLDataType type) { static_cast(imageHandler.get()) ->bindImage(env.second, samplingProperties); bindTexture(renderCmdEncoder, - (unsigned int)_psoReflection->fragmentArguments() - ->object(argIdx) - ->index(), + (unsigned int)[[_psoReflection fragmentArguments] + objectAtIndex:(argIdx)] + .index, env.second, imageHandler); found = true; } @@ -590,32 +613,28 @@ int GetStrideOfMetalType(MTLDataType type) { if (!found) { ImagePtr image = nullptr; - if (_explicitBoundImages.find(_psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String()) != - _explicitBoundImages.end()) { - image = _explicitBoundImages[_psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String()]; + if (_explicitBoundImages.find( + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String) != _explicitBoundImages.end()) { + image = _explicitBoundImages[ + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String]; } if (image && (image->getWidth() > 1 || image->getHeight() > 1)) { bindTexture(renderCmdEncoder, - (unsigned int)_psoReflection->fragmentArguments() - ->object(argIdx) - ->index(), + (unsigned int)[[_psoReflection fragmentArguments] + objectAtIndex:(argIdx)] + .index, image, imageHandler); found = true; } } if (!found) { - auto uniform = _uniformList.find(_psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String()); + auto uniform = _uniformList.find( + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String); if (uniform != _uniformList.end()) { string fileName = uniform->second->value ? uniform->second->value->getValueString() @@ -633,9 +652,9 @@ int GetStrideOfMetalType(MTLDataType type) { publicUniforms); samplingProperties.enableMipmaps = _enableMipMapping; bindTexture(renderCmdEncoder, - (unsigned int)_psoReflection->fragmentArguments() - ->object(argIdx) - ->index(), + (unsigned int)[[_psoReflection fragmentArguments] + objectAtIndex:(argIdx)] + .index, fileName, samplingProperties, imageHandler); } } @@ -860,125 +879,94 @@ int GetStrideOfMetalType(MTLDataType type) { throw ExceptionRenderError(errorType, errors); } - for (NS::UInteger argIdx = 0; - argIdx < _psoReflection->vertexArguments()->count(); argIdx++) { - if (_psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataType() == MTLDataTypeStruct) { - for (NS::UInteger memberIdx = 0; - memberIdx < _psoReflection->vertexArguments() - ->object(argIdx) - ->structType() - ->members() - ->count(); + for (NSUInteger argIdx = 0; argIdx < [_psoReflection vertexArguments].count; + argIdx++) { + if ([[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferDataType == MTLDataTypeStruct) { + for (NSUInteger memberIdx = 0; + memberIdx < [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferStructType.members.count; memberIdx++) { - InputPtr inputPtr = - std::make_shared(_psoReflection->vertexArguments() - ->object(argIdx) - ->index(), - _psoReflection->vertexArguments() - ->object(argIdx) - ->dataType(), - _psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataSize(), - EMPTY_STRING); - std::string memberName = _psoReflection->vertexArguments() - ->object(argIdx) - ->name() - ->utf8String(); + InputPtr inputPtr = std::make_shared( + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)].index, + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferDataType, + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferDataSize, + EMPTY_STRING); + std::string memberName = + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .name.UTF8String; std::string uboDotMemberName = - std::string(_psoReflection->vertexArguments() - ->object(argIdx) - ->name() - ->utf8String()) + + std::string( + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .name.UTF8String) + "." + - _psoReflection->vertexArguments() - ->object(argIdx) - ->name() - ->utf8String(); + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .name.UTF8String; _uniformList[uboDotMemberName] = inputPtr; - _globalUniformNameList[_psoReflection->vertexArguments() - ->object(argIdx) - ->name() - ->utf8String()] = uboDotMemberName; + _globalUniformNameList[ + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .name.UTF8String] = uboDotMemberName; } } } - for (NS::UInteger argIdx = 0; - argIdx < _psoReflection->fragmentArguments()->count(); argIdx++) { - if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTLArgumentTypeBuffer && - _psoReflection->fragmentArguments() - ->object(argIdx) - ->bufferDataType() == MTLDataTypeStruct) { - for (NS::UInteger memberIdx = 0; - memberIdx < _psoReflection->fragmentArguments() - ->object(argIdx) - ->structType() - ->members() - ->count(); + for (NSUInteger argIdx = 0; argIdx < [_psoReflection fragmentArguments].count; + argIdx++) { + if ([[_psoReflection fragmentArguments] objectAtIndex:(argIdx)].type == + MTLArgumentTypeBuffer && + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .bufferDataType == MTLDataTypeStruct) { + for (NSUInteger memberIdx = 0; + memberIdx < [[_psoReflection fragmentArguments] + objectAtIndex:(argIdx)] + .bufferStructType.members.count; memberIdx++) { - std::string uboObjectName = - std::string(_psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String()); - std::string memberName = _psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String(); + std::string uboObjectName = std::string( + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String); + std::string memberName = + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String; std::string uboDotMemberName = uboObjectName + "." + memberName; - InputPtr inputPtr = - std::make_shared(_psoReflection->fragmentArguments() - ->object(argIdx) - ->index(), - _psoReflection->fragmentArguments() - ->object(argIdx) - ->dataType(), - _psoReflection->fragmentArguments() - ->object(argIdx) - ->bufferDataSize(), - EMPTY_STRING); + InputPtr inputPtr = std::make_shared( + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)].index, + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .bufferDataType, + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .bufferDataSize, + EMPTY_STRING); _uniformList[uboDotMemberName] = inputPtr; _globalUniformNameList[memberName] = uboDotMemberName; - if (MTLArrayType *arrayMember = - _psoReflection->fragmentArguments() - ->object(argIdx) - ->arrayType()) { - for (int i = 0; i < arrayMember->arrayLength(); ++i) { - for (NS::UInteger arrayStructIdx = 0; - arrayStructIdx < - arrayMember->elementStructType()->members()->count(); + if (MTLArgument *arrayMember = + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)]) { + + for (int i = 0; i < arrayMember.arrayLength; ++i) { + for (NSUInteger arrayStructIdx = 0; + arrayStructIdx < arrayMember.bufferStructType.members.count; arrayStructIdx++) { std::string memberNameDotSubmember = memberName + "[" + std::to_string(i) + "]." + - arrayMember->elementStructType() - ->members() - ->object(arrayStructIdx) - ->name() - ->utf8String(); + [arrayMember.bufferStructType.members + objectAtIndex:(arrayStructIdx)] + .name.UTF8String; std::string uboDotMemberNameDotSubmemberName = uboObjectName + "." + memberNameDotSubmember; - InputPtr inputPtr = std::make_shared( - arrayMember->elementStructType() - ->members() - ->object(arrayStructIdx) - ->argumentIndex(), - arrayMember->elementStructType() - ->members() - ->object(arrayStructIdx) - ->dataType(), - arrayMember->elementStructType() - ->members() - ->object(arrayStructIdx) - ->offset(), - EMPTY_STRING); + InputPtr inputPtr = + std::make_shared([arrayMember.bufferStructType.members + objectAtIndex:(arrayStructIdx)] + .argumentIndex, + [arrayMember.bufferStructType.members + objectAtIndex:(arrayStructIdx)] + .dataType, + [arrayMember.bufferStructType.members + objectAtIndex:(arrayStructIdx)] + .offset, + EMPTY_STRING); _uniformList[uboDotMemberNameDotSubmemberName] = inputPtr; _globalUniformNameList[memberNameDotSubmember] = uboDotMemberNameDotSubmemberName; @@ -988,26 +976,20 @@ int GetStrideOfMetalType(MTLDataType type) { } } - if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTLArgumentTypeTexture) { - if (HW::ENV_RADIANCE != _psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String() && - HW::ENV_IRRADIANCE != _psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String()) { - std::string texture_name = _psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String(); - InputPtr inputPtr = - std::make_shared(_psoReflection->fragmentArguments() - ->object(argIdx) - ->index(), - 58, -1, EMPTY_STRING); + if ([[_psoReflection fragmentArguments] objectAtIndex:(argIdx)].type == + MTLArgumentTypeTexture) { + if (HW::ENV_RADIANCE != + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String && + HW::ENV_IRRADIANCE != + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String) { + std::string texture_name = + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String; + InputPtr inputPtr = std::make_shared( + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)].index, + 58, -1, EMPTY_STRING); _uniformList[texture_name] = inputPtr; } } @@ -1136,9 +1118,9 @@ int GetStrideOfMetalType(MTLDataType type) { return _uniformList; } -void MslProgram::bindUniformBuffers(MTLRenderCommandEncoder *renderCmdEncoder, - LightHandlerPtr lightHandler, - CameraPtr cam) { +void MslProgram::bindUniformBuffers( + id renderCmdEncoder, LightHandlerPtr lightHandler, + CameraPtr cam) { auto setCommonUniform = [this](LightHandlerPtr lightHandler, CameraPtr cam, std::string uniformName, std::vector &data, @@ -1302,149 +1284,120 @@ throw ExceptionRenderError( } }; - for (NS::UInteger argIdx = 0; - argIdx < _psoReflection->vertexArguments()->count(); argIdx++) { - if (_psoReflection->vertexArguments() - ->object(argIdx) - ->type() == MTLArgumentTypeBuffer && - _psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataType() == MTLDataTypeStruct) { + for (NSUInteger argIdx = 0; argIdx < [_psoReflection vertexArguments].count; + argIdx++) { + if ([[_psoReflection vertexArguments] objectAtIndex:(argIdx)].type == + MTLArgumentTypeBuffer && + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferDataType == MTLDataTypeStruct) { std::vector uniformBufferData( - _psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataSize()); - for (NS::UInteger memberIdx = 0; - memberIdx < _psoReflection->vertexArguments() - ->object(argIdx) - ->structType() - ->members() - ->count(); + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferDataSize); + for (NSUInteger memberIdx = 0; + memberIdx < [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferStructType.members.count; memberIdx++) { - if (!setCommonUniform(lightHandler, cam, - _psoReflection->vertexArguments() - ->object(argIdx) - ->name() - ->utf8String(), - uniformBufferData, - _psoReflection->vertexArguments() - ->object(argIdx) - ->offset())) { + if (!setCommonUniform( + lightHandler, cam, + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .name.UTF8String, + uniformBufferData, + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferAlignment)) { MaterialX::ValuePtr value = - _uniformList[string(_psoReflection->vertexArguments() - ->object(argIdx) - ->name() - ->utf8String()) + + _uniformList[string([[_psoReflection vertexArguments] + objectAtIndex:(argIdx)] + .name.UTF8String) + "." + - _psoReflection->vertexArguments() - ->object(argIdx) - ->name() - ->utf8String()] + [[_psoReflection vertexArguments] + objectAtIndex:(argIdx)] + .name.UTF8String] ->value; if (value) { setValue(value, uniformBufferData, - _psoReflection->vertexArguments() - ->object(argIdx) - ->offset()); + [[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferAlignment); } } } - if (_psoReflection->vertexArguments() - ->object(argIdx) - ->bufferStructType()) - renderCmdEncoder->setVertexBytes((void *)uniformBufferData.data(), - _psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataSize(), - _psoReflection->vertexArguments() - ->object(argIdx) - ->index()); + if ([[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferStructType) + [renderCmdEncoder setVertexBytes:(void *)uniformBufferData.data() + length:[[_psoReflection vertexArguments] + objectAtIndex:(argIdx)] + .bufferDataSize + atIndex:[[_psoReflection vertexArguments] + objectAtIndex:(argIdx)] + .index]; } } - for (NS::UInteger argIdx = 0; - argIdx < _psoReflection->fragmentArguments()->count(); argIdx++) { - if (_psoReflection->fragmentArguments() - ->object(argIdx) - ->type() == MTLArgumentTypeBuffer && - _psoReflection->fragmentArguments() - ->object(argIdx) - ->bufferDataType() == MTLDataTypeStruct) { + for (NSUInteger argIdx = 0; argIdx < [_psoReflection fragmentArguments].count; + argIdx++) { + if ([[_psoReflection fragmentArguments] objectAtIndex:(argIdx)].type == + MTLArgumentTypeBuffer && + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .bufferDataType == MTLDataTypeStruct) { std::vector uniformBufferData( - _psoReflection->fragmentArguments() - ->object(argIdx) - ->bufferDataSize()); - - for (NS::UInteger memberIdx = 0; - memberIdx < _psoReflection->fragmentArguments() - ->object(argIdx) - ->structType() - ->members() - ->count(); + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .bufferDataSize); + + for (NSUInteger memberIdx = 0; + memberIdx < [[_psoReflection fragmentArguments] + objectAtIndex:(argIdx)] + .bufferStructType.members.count; memberIdx++) { - string uniformName = string(_psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String()) + - "." + - _psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String(); - - if (!setCommonUniform(lightHandler, cam, - _psoReflection->fragmentArguments() - ->object(argIdx) - ->name() - ->utf8String(), - uniformBufferData, - _psoReflection->fragmentArguments() - ->object(argIdx) - ->offset())) { + string uniformName = + string([[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String) + + "." + + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String; + + if (!setCommonUniform( + lightHandler, cam, + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .name.UTF8String, + uniformBufferData, + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .bufferAlignment)) { auto uniformInfo = _uniformList.find(uniformName); if (uniformInfo != _uniformList.end()) { MaterialX::ValuePtr value = uniformInfo->second->value; if (value) { - setValue(value, uniformBufferData, - _psoReflection->fragmentArguments() - ->object(argIdx) - ->offset()); + setValue( + value, uniformBufferData, + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)] + .bufferAlignment); } } else { } } - if (MTLArrayType *arrayMember = - _psoReflection->fragmentArguments() - ->object(argIdx) - ->arrayType()) { - for (int i = 0; i < arrayMember->arrayLength(); ++i) { - for (NS::UInteger memberIdx = 0; - memberIdx < - arrayMember->elementStructType()->members()->count(); + if (MTLArgument *arrayMember = + [[_psoReflection fragmentArguments] objectAtIndex:(argIdx)]) { + for (int i = 0; i < arrayMember.arrayLength; ++i) { + for (NSUInteger memberIdx = 0; + memberIdx < [arrayMember bufferStructType].members.count; memberIdx++) { - string uniformNameSubArray = - uniformName + "[" + std::to_string(i) + "]." + - arrayMember->elementStructType() - ->members() - ->object(memberIdx) - ->name() - ->utf8String(); + string uniformNameSubArray = uniformName + "[" + + std::to_string(i) + "]." + + [arrayMember bufferStructType] + .members[memberIdx] + .name.UTF8String; auto uniformInfo = _uniformList.find(uniformNameSubArray); if (uniformInfo != _uniformList.end()) { MaterialX::ValuePtr value = uniformInfo->second->value; if (value) { setValue(value, uniformBufferData, - _psoReflection->fragmentArguments() - ->object(argIdx) - ->offset() + - i * arrayMember->stride() + - arrayMember->elementStructType() - ->members() - ->object(memberIdx) - ->offset()); + [[_psoReflection fragmentArguments] + objectAtIndex:(argIdx)] + .bufferAlignment + + i * arrayMember.bufferDataSize + + arrayMember.bufferStructType.members[memberIdx] + .offset); } } } @@ -1452,28 +1405,31 @@ throw ExceptionRenderError( } } - if (_psoReflection->vertexArguments() - ->object(argIdx) - ->bufferStructType()) - renderCmdEncoder->setFragmentBytes((void *)uniformBufferData.data(), - _psoReflection->vertexArguments() - ->object(argIdx) - ->bufferDataSize(), - _psoReflection->vertexArguments() - ->object(argIdx) - ->index()); + if ([[_psoReflection vertexArguments] objectAtIndex:(argIdx)] + .bufferStructType) + [renderCmdEncoder setFragmentBytes:(void *)uniformBufferData.data() + length:[[_psoReflection vertexArguments] + objectAtIndex:(argIdx)] + .bufferDataSize + atIndex:[[_psoReflection vertexArguments] + objectAtIndex:(argIdx)] + .index]; } } } void MslProgram::reset() { if (_pso != nil) { - _pso->release(); +#if !__has_feature(objc_arc) + [_pso release]; +#endif // !__has_feature(objc_arc) } _pso = nil; if (_psoReflection != nil) { - _psoReflection->release(); +#if !__has_feature(objc_arc) + [_psoReflection release]; +#endif // !__has_feature(objc_arc) } _psoReflection = nil; diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm index ec5615cf..dec157ef 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm @@ -4,6 +4,7 @@ // #import + #include #include #include @@ -46,7 +47,7 @@ } _device = MTLCreateSystemDefaultDevice(); - _cmdQueue = _device->newCommandQueue(); + _cmdQueue = [_device newCommandQueue]; createFrameBuffer(true); _initialized = true; @@ -72,13 +73,13 @@ if (captureRenderTextureSpace) triggerProgrammaticCapture(); - MTLRenderPassDescriptor *desc = MTLRenderPassDescriptor::alloc()->init(); + MTLRenderPassDescriptor *desc = [[MTLRenderPassDescriptor alloc] init]; _framebuffer->bind(desc); - _cmdBuffer = _cmdQueue->commandBuffer(); + _cmdBuffer = [_cmdQueue commandBuffer]; - MTLRenderCommandEncoder *rendercmdEncoder = - _cmdBuffer->renderCommandEncoder(desc); + id rendercmdEncoder = + [_cmdBuffer renderCommandEncoderWithDescriptor:(desc)]; _program->bind(rendercmdEncoder); _program->prepareUsedResources(rendercmdEncoder, _camera, _geometryHandler, _imageHandler, _lightHandler); @@ -88,17 +89,21 @@ MeshPartitionPtr part = mesh->getPartition(0); _program->bindPartition(part); MeshIndexBuffer &indexData = part->getIndices(); - rendercmdEncoder->drawIndexedPrimitives( - MTLPrimitiveTypeTriangle, indexData.size(), MTLIndexTypeUInt32, - _program->getIndexBuffer(part), 0); + [rendercmdEncoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle + indexCount:indexData.size() + indexType:MTLIndexTypeUInt32 + indexBuffer:_program->getIndexBuffer(part) + indexBufferOffset:0]; _framebuffer->unbind(); - rendercmdEncoder->endEncoding(); + [rendercmdEncoder endEncoding]; - _cmdBuffer->commit(); - _cmdBuffer->waitUntilCompleted(); + [_cmdBuffer commit]; + [_cmdBuffer waitUntilCompleted]; - desc->release(); +#if !__has_feature(objc_arc) + [desc release]; +#endif // !__has_feature(objc_arc) if (captureRenderTextureSpace) stopProgrammaticCapture(); @@ -130,14 +135,13 @@ } void MslRenderer::triggerProgrammaticCapture() { - MTLCaptureManager *captureManager = - MTLCaptureManager::sharedCaptureManager(); - MTLCaptureDescriptor *captureDescriptor = - MTLCaptureDescriptor::alloc()->init(); - captureDescriptor->setCaptureObject(_device); + MTLCaptureManager *captureManager = [MTLCaptureManager sharedCaptureManager]; + MTLCaptureDescriptor *captureDescriptor = [[MTLCaptureDescriptor alloc] init]; + [captureDescriptor setCaptureObject:_device]; NSError *error = nil; - if (!captureManager->startCapture(captureDescriptor, &error)) { + if (![captureManager startCaptureWithDescriptor:captureDescriptor + error:&error]) { #if WITH_APPLE_NSLOG NS::Log(NSString::string("Failed to start capture, error %@", error), NS::UTF8StringEncoding); @@ -146,9 +150,8 @@ } void MslRenderer::stopProgrammaticCapture() { - MTLCaptureManager *captureManager = - MTLCaptureManager::sharedCaptureManager(); - captureManager->stopCapture(); + MTLCaptureManager *captureManager = [MTLCaptureManager sharedCaptureManager]; + [captureManager stopCapture]; } void MslRenderer::render() { @@ -156,28 +159,27 @@ if (captureFrame) triggerProgrammaticCapture(); - _cmdBuffer = _cmdQueue->commandBuffer(); + _cmdBuffer = [_cmdQueue commandBuffer]; MTLRenderPassDescriptor *renderpassDesc = - MTLRenderPassDescriptor::alloc()->init(); + [[MTLRenderPassDescriptor alloc] init]; _framebuffer->bind(renderpassDesc); - renderpassDesc->colorAttachments()->object(0)->setClearColor( - MTLClearColor::Make(_screenColor[0], _screenColor[1], _screenColor[2], - 1.0f)); + [[renderpassDesc colorAttachments][0] + setClearColor:MTLClearColorMake(_screenColor[0], _screenColor[1], + _screenColor[2], 1.0f)]; - MTLRenderCommandEncoder *renderCmdEncoder = - _cmdBuffer->renderCommandEncoder(renderpassDesc); + id renderCmdEncoder = + [_cmdBuffer renderCommandEncoderWithDescriptor:renderpassDesc]; MTLDepthStencilDescriptor *depthStencilDesc = - MTLDepthStencilDescriptor::alloc()->init(); - depthStencilDesc->setDepthWriteEnabled(!(_program->isTransparent())); - depthStencilDesc->setDepthCompareFunction(MTLCompareFunctionLess); - - MTLDepthStencilState *depthStencilState = - _device->newDepthStencilState(depthStencilDesc); - renderCmdEncoder->setDepthStencilState(depthStencilState); + [[MTLDepthStencilDescriptor alloc] init]; + [depthStencilDesc setDepthWriteEnabled:!(_program->isTransparent())]; + [depthStencilDesc setDepthCompareFunction:(MTLCompareFunctionLess)]; - renderCmdEncoder->setCullMode(MTLCullModeBack); + id depthStencilState = + [_device newDepthStencilStateWithDescriptor:(depthStencilDesc)]; + [renderCmdEncoder setDepthStencilState:(depthStencilState)]; + [renderCmdEncoder setCullMode:(MTLCullModeBack)]; try { // Bind program and input parameters @@ -198,16 +200,22 @@ MeshIndexBuffer &indexData = part->getIndices(); if (_program->isTransparent()) { - renderCmdEncoder->setCullMode(MTLCullModeFront); - renderCmdEncoder->drawIndexedPrimitives( - MTLPrimitiveTypeTriangle, (int)indexData.size(), - MTLIndexTypeUInt32, _program->getIndexBuffer(part), 0); - renderCmdEncoder->setCullMode(MTLCullModeBack); + [renderCmdEncoder setCullMode:(MTLCullModeFront)]; + [renderCmdEncoder + drawIndexedPrimitives:MTLPrimitiveTypeTriangle + indexCount:(int)indexData.size() + indexType:MTLIndexTypeUInt32 + indexBuffer:(_program->getIndexBuffer( + part))indexBufferOffset:0]; + [renderCmdEncoder setCullMode:(MTLCullModeBack)]; } - renderCmdEncoder->drawIndexedPrimitives( - MTLPrimitiveTypeTriangle, (int)indexData.size(), - MTLIndexTypeUInt32, _program->getIndexBuffer(part), 0); + [renderCmdEncoder + drawIndexedPrimitives:MTLPrimitiveTypeTriangle + indexCount:(int)indexData.size() + indexType:MTLIndexTypeUInt32 + indexBuffer:(_program->getIndexBuffer( + part))indexBufferOffset:0]; } } } @@ -216,14 +224,16 @@ throw e; } - renderCmdEncoder->endEncoding(); + [renderCmdEncoder endEncoding]; _framebuffer->unbind(); - _cmdBuffer->commit(); - _cmdBuffer->waitUntilCompleted(); + [_cmdBuffer commit]; + [_cmdBuffer waitUntilCompleted]; - _cmdBuffer->release(); +#if !__has_feature(objc_arc) + [_cmdBuffer release]; +#endif // __has_feature(objc_arc) _cmdBuffer = nil; if (captureFrame) diff --git a/Sources/MaterialX/source/MaterialXRenderOsl/OslRenderer.cpp b/Sources/MaterialX/source/MaterialXRenderOsl/OslRenderer.cpp index 66786ff3..ed5c5ff6 100644 --- a/Sources/MaterialX/source/MaterialXRenderOsl/OslRenderer.cpp +++ b/Sources/MaterialX/source/MaterialXRenderOsl/OslRenderer.cpp @@ -179,9 +179,9 @@ void OslRenderer::renderOSL(const FilePath &dirPath, const string &shaderName, // Repeat the render command to allow for sporadic errors. int returnValue = 0; for (int i = 0; i < 5; i++) { - #if !TARGET_OS_IPHONE +#if !TARGET_OS_IPHONE returnValue = std::system(command.c_str()); - #endif /* !TARGET_OS_IPHONE */ +#endif /* !TARGET_OS_IPHONE */ if (!returnValue) { break; } @@ -238,10 +238,10 @@ void OslRenderer::shadeOSL(const FilePath &dirPath, const string &shaderName, command += " -o " + outputName + " " + outputFileName; command += " -g 256 256"; command += " > " + errorFile + redirectString; - + #if !TARGET_OS_IPHONE int returnValue = std::system(command.c_str()); -#else /* TARGET_OS_IPHONE */ +#else /* TARGET_OS_IPHONE */ int returnValue = 0; #endif /* !TARGET_OS_IPHONE */ @@ -298,7 +298,7 @@ void OslRenderer::compileOSL(const FilePath &oslFilePath) { #if !TARGET_OS_IPHONE int returnValue = std::system(command.c_str()); -#else /* TARGET_OS_IPHONE */ +#else /* TARGET_OS_IPHONE */ int returnValue = 0; #endif /* !TARGET_OS_IPHONE */ diff --git a/Sources/MaterialX/source/MaterialXView/RenderPipelineMetal.mm b/Sources/MaterialX/source/MaterialXView/RenderPipelineMetal.mm index da7b6a6e..093a9f57 100644 --- a/Sources/MaterialX/source/MaterialXView/RenderPipelineMetal.mm +++ b/Sources/MaterialX/source/MaterialXView/RenderPipelineMetal.mm @@ -26,8 +26,8 @@ void MetalRenderPipeline::initialize(void *metal_device, void *metal_cmd_queue) { - MTL(initialize((MTL::Device)metal_device, - (MTL::CommandQueue *)metal_cmd_queue)); + MTL(initialize((MTLDevice)metal_device, + (id)metal_cmd_queue)); } mx::ImageHandlerPtr MetalRenderPipeline::createImageHandler() { @@ -51,8 +51,8 @@ MTL_PUSH_FRAMEBUFFER(mx::MetalFramebuffer::create( MTL(device), width * _viewer->m_pixel_ratio, height * _viewer->m_pixel_ratio, 4, mx::Image::BaseType::UINT8, - MTL(supportsTiledPipeline) ? (MTL::Texture *)color_texture : nil, false, - MTL::PixelFormatBGRA8Unorm)); + MTL(supportsTiledPipeline) ? (id)color_texture : nil, false, + MTLPixelFormatBGRA8Unorm)); } void MetalRenderPipeline::resizeFramebuffer(int width, int height, @@ -82,7 +82,7 @@ MTL(beginCommandBuffer()); - MTL::RenderPassDescriptor *renderpassDesc = [MTL::RenderPassDescriptor new]; + id renderpassDesc = [MTLRenderPassDescriptor new]; [renderpassDesc.colorAttachments[0] setTexture:framebuffer->getColorTexture()]; @@ -149,7 +149,7 @@ mx::MetalTextureHandlerPtr mtlImageHandler = std::dynamic_pointer_cast(imageHandler); - MTL::Texture *shadowMapTex[SHADOWMAP_TEX_COUNT]; + id shadowMapTex[SHADOWMAP_TEX_COUNT]; for (int i = 0; i < SHADOWMAP_TEX_COUNT; ++i) { if (!_shadowMap[i] || _shadowMap[i]->getWidth() != shadowMapSize || !mtlImageHandler->getAssociatedMetalTexture(_shadowMap[i])) { @@ -202,8 +202,8 @@ MTL_TRIGGER_CAPTURE; MTL(beginCommandBuffer()); - MTL::RenderPassDescriptor *renderpassDesc = - [MTL::RenderPassDescriptor new]; + id renderpassDesc = + [MTLRenderPassDescriptor new]; _shadowMapFramebuffer->setColorTexture(shadowMapTex[0]); _shadowMapFramebuffer->bind(renderpassDesc); MTL(beginEncoder(renderpassDesc)); @@ -308,10 +308,10 @@ } MTL(beginCommandBuffer()); - MTL::RenderPassDescriptor *renderpassDesc = [MTL::RenderPassDescriptor new]; + id renderpassDesc = [MTLRenderPassDescriptor new]; if (useTiledPipeline) { [renderpassDesc.colorAttachments[0] - setTexture:(MTL::Texture *)color_texture]; + setTexture:(id)color_texture]; } else { [renderpassDesc.colorAttachments[0] setTexture:MTL(currentFramebuffer())->getColorTexture()]; @@ -469,7 +469,7 @@ { MTL(endEncoder()); [renderpassDesc.colorAttachments[0] - setTexture:(MTL::Texture *)color_texture]; + setTexture:(id)color_texture]; MTL(beginEncoder(renderpassDesc)); [MTL(renderCmdEncoder) setRenderPipelineState:MTL(linearToSRGB_pso)]; [MTL(renderCmdEncoder) @@ -541,9 +541,9 @@ MTL(waitForComplition()); mx::MetalFramebufferPtr framebuffer = mx::MetalFramebuffer::create( MTL(device), width, height, 4, mx::Image::BaseType::UINT8, - MTL(supportsTiledPipeline) ? (MTL::Texture *)_viewer->_colorTexture + MTL(supportsTiledPipeline) ? (id)_viewer->_colorTexture : MTL(currentFramebuffer())->getColorTexture(), - false, MTL::PixelFormatBGRA8Unorm); + false, MTLPixelFormatBGRA8Unorm); mx::ImagePtr frame = framebuffer->getColorImage(MTL(cmdQueue)); // Flips the captured image diff --git a/Sources/MetaversalDemo/Creator.swift b/Sources/MetaversalDemo/Creator.swift index ee0df477..1b35e096 100644 --- a/Sources/MetaversalDemo/Creator.swift +++ b/Sources/MetaversalDemo/Creator.swift @@ -97,7 +97,7 @@ class Creator let app = OSApp.shared let delegate = AppDelegate() - public init() + init() { app.delegate = delegate } @@ -166,8 +166,8 @@ class Creator { print("Error writing image: \(comp.geterror(true))") } - } - else + } + else { print("Error filling fg image.") } diff --git a/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceMTLCommon.h b/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceMTLCommon.h index 3c98f83c..fbe03a48 100644 --- a/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceMTLCommon.h +++ b/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceMTLCommon.h @@ -39,7 +39,7 @@ namespace Osd { class MTLContext { public: - id device = nullptr; + id device = nullptr; id commandQueue = nullptr; }; diff --git a/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm b/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm index a27c4d0f..2c600179 100644 --- a/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm +++ b/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm @@ -25,7 +25,7 @@ #include "OpenSubdiv/OSDSurfaceMTLComputeEvaluator.h" #include "OpenSubdiv/OSDSurfaceMTLPatchShaderSource.h" -#include +#import #include #include #include @@ -355,7 +355,7 @@ _parameterBuffer = [context->device newBufferWithLength:sizeof(mtl::KernelUniformArgs) - options:MTLResourceOptionCPUCacheModeDefault]; + options:MTLResourceCPUCacheModeDefaultCache]; return true; } diff --git a/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm b/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm index 411b02c4..e6585b7e 100644 --- a/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm +++ b/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm @@ -23,7 +23,7 @@ // #include "OpenSubdiv/OSDSurfaceMTLLegacyGregoryPatchTable.h" -#include +#import namespace OpenSubdiv { namespace OPENSUBDIV_VERSION { @@ -38,7 +38,7 @@ auto stageBuffer = [context->device newBufferWithBytes:data length:length - options:MTLResourceOptionCPUCacheModeDefault]; + options:MTLResourceCPUCacheModeDefaultCache]; auto finalBuffer = [context->device newBufferWithLength:length diff --git a/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm b/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm index 5cb136cd..66bbee2a 100644 --- a/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm +++ b/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm @@ -23,7 +23,7 @@ // #include "OpenSubdiv/OSDSurfaceMTLVertexBuffer.h" -#include +#import #include namespace OpenSubdiv { diff --git a/Tests/MetaverseKitTests/MetaverseKitTests.swift b/Tests/MetaverseKitTests/MetaverseKitTests.swift index 18b75be9..033e82fc 100644 --- a/Tests/MetaverseKitTests/MetaverseKitTests.swift +++ b/Tests/MetaverseKitTests/MetaverseKitTests.swift @@ -49,7 +49,7 @@ import XCTest class MetaverseKitTests: XCTestCase { - func testMetaverse() throws + func testMetaverse() { print("it works!") } From 7ff8d6de81ecccaf051fcd2a6e963f61e8bfdc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furby=E2=84=A2?= Date: Mon, 8 Jun 2026 23:03:53 -0600 Subject: [PATCH 3/7] Add experimental Android support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Furby™ --- Package.swift | 33 ++++++--- Sources/Draco/include/draco/core/options.h | 2 +- Sources/GLFW/cocoa_init.m | 4 + Sources/GLFW/cocoa_joystick.m | 4 + Sources/GLFW/cocoa_monitor.m | 4 + Sources/GLFW/cocoa_time.c | 4 + Sources/GLFW/cocoa_window.m | 4 + Sources/GLFW/egl_context.c | 7 ++ Sources/GLFW/nsgl_context.m | 4 + Sources/GLFW/null_init.c | 4 + Sources/GLFW/null_joystick.c | 4 + Sources/GLFW/null_monitor.c | 4 + Sources/GLFW/null_window.c | 4 + Sources/GLFW/posix_time.c | 6 ++ Sources/ImGui/backends/ImplGLUT.cpp | 5 ++ Sources/ImGui/backends/ImplMacOS.mm | 5 ++ Sources/ImGui/backends/ImplMetal.mm | 5 ++ Sources/Imath | 2 +- .../include/MaterialX/MXRenderGlslGLContext.h | 10 ++- .../MaterialX/MXRenderHwWindowWrapper.h | 8 +- .../source/MaterialXRenderGlsl/GLContext.cpp | 74 +++++++++++++++++++ .../MaterialXRenderHw/SimpleWindowAndroid.cpp | 38 ++++++++++ .../MaterialXRenderHw/SimpleWindowLinux.cpp | 2 +- .../MaterialXRenderHw/WindowWrapper.cpp | 22 +++++- .../MaterialXRenderMsl/MetalFramebuffer.mm | 5 ++ .../source/MaterialXRenderMsl/MetalState.mm | 5 ++ .../MaterialXRenderMsl/MetalTextureHandler.mm | 5 ++ .../source/MaterialXRenderMsl/MslMaterial.mm | 5 ++ .../MslPipelineStateObject.mm | 5 ++ .../source/MaterialXRenderMsl/MslRenderer.mm | 5 ++ .../source/MaterialXRenderMsl/TextureBaker.mm | 5 ++ .../include/OpenSubdiv/OSDSurfaceOpenGL.h | 2 +- Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm | 5 ++ .../osd/MTLLegacyGregoryPatchTable.mm | 5 ++ Sources/OpenSubdiv/osd/MTLMesh.mm | 5 ++ .../OpenSubdiv/osd/MTLPatchShaderSource.mm | 5 ++ Sources/OpenSubdiv/osd/MTLPatchTable.mm | 5 ++ Sources/OpenSubdiv/osd/MTLVertexBuffer.mm | 5 ++ 38 files changed, 303 insertions(+), 23 deletions(-) create mode 100644 Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowAndroid.cpp diff --git a/Package.swift b/Package.swift index ceb4d0d4..b56e7654 100644 --- a/Package.swift +++ b/Package.swift @@ -176,7 +176,8 @@ let package = Package( .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), ], linkerSettings: [ - .linkedLibrary("bz2", .when(platforms: Arch.OS.nix.platform)) + // bzip2 is not in the Android NDK sysroot; exclude Android. + .linkedLibrary("bz2", .when(platforms: Arch.OS.nixnodroid.platform)) ] ), @@ -376,7 +377,7 @@ let package = Package( name: "OpenSubdiv", dependencies: [ .target(name: "MetaTBB"), - .target(name: "OpenMP", condition: .when(platforms: Arch.OS.nodroid.platform)), + .target(name: "OpenMP"), ], exclude: getConfig(for: .osd).exclude, publicHeadersPath: "include", @@ -507,7 +508,8 @@ let package = Package( .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), ], linkerSettings: [ - .linkedLibrary("deflate", .when(platforms: Arch.OS.linux.platform)), + // libdeflate is not in the Android NDK sysroot; Android uses the bundled DEFLATE target. + .linkedLibrary("deflate", .when(platforms: [.linux, .openbsd])), ] ), @@ -678,7 +680,8 @@ let package = Package( .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), ], linkerSettings: [ - .linkedLibrary("pthread", .when(platforms: Arch.OS.linux.platform)), + // Android pthreads are part of libc (bionic); no separate -lpthread needed. + .linkedLibrary("pthread", .when(platforms: [.linux, .openbsd])), ] ), @@ -860,14 +863,15 @@ func getConfig(for target: PkgTarget) -> TargetInfo ] #endif /* os(Windows) */ case .glfw: + // null_*.c are guarded internally with #if defined(_GLFW_OSMESA) so they + // compile to empty translation units on macOS/Linux (where _GLFW_OSMESA is + // not defined) and provide the full null-platform implementation on Android + // (where _GLFW_OSMESA is set via .when(platforms: [.android]) in cxxSettings). + // Do NOT add them to the exclude list. config.exclude = [ "wl_init.c", "wl_window.c", "wl_monitor.c", - "null_init.c", - "null_joystick.c", - "null_monitor.c", - "null_window.c", ] #if !os(Windows) config.exclude += [ @@ -895,21 +899,26 @@ func getConfig(for target: PkgTarget) -> TargetInfo "cocoa_time.c", ] #endif /* !os(macOS) && !os(visionOS) && !os(iOS) && !os(tvOS) && !os(watchOS) */ - #if !os(Linux) && !os(Android) && !os(OpenBSD) && !os(FreeBSD) + // Exclude X11/GLX files on every platform that does not use X11. + // Android uses the null/OSMESA platform, so it also gets excluded here. + #if !os(Linux) && !os(OpenBSD) && !os(FreeBSD) config.exclude += [ "xkb_unicode.c", "x11_init.c", "x11_monitor.c", "x11_window.c", - "posix_time.c", "glx_context.c", "linux_joystick.c", ] - #endif /* !os(Linux) && !os(Android) && !os(OpenBSD) && !os(FreeBSD) */ + #endif /* !os(Linux) && !os(OpenBSD) && !os(FreeBSD) */ + // posix_time.c is guarded internally with #if !defined(_GLFW_COCOA) so it + // compiles to nothing on macOS (which uses cocoa_time.c instead) and + // provides POSIX timer functions on Linux, Android, and other POSIX targets. config.cxxSettings = [ .headerSearchPath("."), .define("_GLFW_COCOA", to: "1", .when(platforms: Arch.OS.apple.platform)), - .define("_GLFW_X11", to: "1", .when(platforms: Arch.OS.linux.platform)), + .define("_GLFW_X11", to: "1", .when(platforms: [.linux, .openbsd])), + .define("_GLFW_OSMESA", to: "1", .when(platforms: [.android])), .define("_GLFW_WIN32", to: "1", .when(platforms: Arch.OS.windows.platform)), .define("GL_SILENCE_DEPRECATION", to: "1"), .define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])), diff --git a/Sources/Draco/include/draco/core/options.h b/Sources/Draco/include/draco/core/options.h index 3f15d13b..1d22addf 100644 --- a/Sources/Draco/include/draco/core/options.h +++ b/Sources/Draco/include/draco/core/options.h @@ -88,7 +88,7 @@ void Options::SetVector(const std::string &name, const DataTypeT *vec, // GNU STL on android doesn't include a proper std::to_string, but the libc++ // version does -#if defined(ANDROID) && !defined(_LIBCPP_VERSION) +#if defined(__ANDROID__) && !defined(_LIBCPP_VERSION) out += to_string(vec[i]); #else out += std::to_string(vec[i]); diff --git a/Sources/GLFW/cocoa_init.m b/Sources/GLFW/cocoa_init.m index 497629a6..1308e4db 100644 --- a/Sources/GLFW/cocoa_init.m +++ b/Sources/GLFW/cocoa_init.m @@ -26,6 +26,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_COCOA) + #include "internal.h" #include #include @@ -801,3 +803,5 @@ void _glfwPlatformTerminate(void) ; } + +#endif // defined(_GLFW_COCOA) diff --git a/Sources/GLFW/cocoa_joystick.m b/Sources/GLFW/cocoa_joystick.m index e01583e4..6af0d1e8 100644 --- a/Sources/GLFW/cocoa_joystick.m +++ b/Sources/GLFW/cocoa_joystick.m @@ -27,6 +27,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_COCOA) + #include "internal.h" #include @@ -499,3 +501,5 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) } } + +#endif // defined(_GLFW_COCOA) diff --git a/Sources/GLFW/cocoa_monitor.m b/Sources/GLFW/cocoa_monitor.m index 0a5b43ab..e358d9c5 100644 --- a/Sources/GLFW/cocoa_monitor.m +++ b/Sources/GLFW/cocoa_monitor.m @@ -27,6 +27,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_COCOA) + #include "internal.h" #include @@ -648,3 +650,5 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) return monitor->ns.displayID; } #endif /* !TARGET_OS_IPHONE */ + +#endif // defined(_GLFW_COCOA) diff --git a/Sources/GLFW/cocoa_time.c b/Sources/GLFW/cocoa_time.c index 4bf646c8..60ed02dc 100644 --- a/Sources/GLFW/cocoa_time.c +++ b/Sources/GLFW/cocoa_time.c @@ -26,6 +26,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_COCOA) + #include "internal.h" #include @@ -60,3 +62,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void) return _glfw.timer.ns.frequency; } + +#endif // defined(_GLFW_COCOA) diff --git a/Sources/GLFW/cocoa_window.m b/Sources/GLFW/cocoa_window.m index 0e83bc12..006609f1 100644 --- a/Sources/GLFW/cocoa_window.m +++ b/Sources/GLFW/cocoa_window.m @@ -26,6 +26,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_COCOA) + #include "internal.h" #include @@ -2155,3 +2157,5 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) _GLFW_REQUIRE_INIT_OR_RETURN(nil); return window->ns.object; } + +#endif // defined(_GLFW_COCOA) diff --git a/Sources/GLFW/egl_context.c b/Sources/GLFW/egl_context.c index 706a7922..2b7929b3 100644 --- a/Sources/GLFW/egl_context.c +++ b/Sources/GLFW/egl_context.c @@ -27,6 +27,11 @@ // Please use C89 style variable declarations in this file because VS 2010 //======================================================================== +// EGL context is only meaningful when a real windowing platform is in use. +// _GLFW_OSMESA selects the null/headless platform (e.g. Android cross-builds) +// where egl_context.h is never pulled in and EGL types are undefined. +#if !defined(_GLFW_OSMESA) + #include "internal.h" #include @@ -787,3 +792,5 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) return window->context.egl.surface; } + +#endif // !defined(_GLFW_OSMESA) diff --git a/Sources/GLFW/nsgl_context.m b/Sources/GLFW/nsgl_context.m index 60db82b2..2b72322e 100644 --- a/Sources/GLFW/nsgl_context.m +++ b/Sources/GLFW/nsgl_context.m @@ -26,6 +26,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_COCOA) + #include "internal.h" #include @@ -382,3 +384,5 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) return window->context.nsgl.object; } + +#endif // defined(_GLFW_COCOA) diff --git a/Sources/GLFW/null_init.c b/Sources/GLFW/null_init.c index 20c76dc5..413830d8 100644 --- a/Sources/GLFW/null_init.c +++ b/Sources/GLFW/null_init.c @@ -27,6 +27,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_OSMESA) + #include "internal.h" @@ -50,3 +52,5 @@ const char* _glfwPlatformGetVersionString(void) return _GLFW_VERSION_NUMBER " null OSMesa"; } + +#endif // defined(_GLFW_OSMESA) diff --git a/Sources/GLFW/null_joystick.c b/Sources/GLFW/null_joystick.c index 36c18aa2..82b660cc 100644 --- a/Sources/GLFW/null_joystick.c +++ b/Sources/GLFW/null_joystick.c @@ -26,6 +26,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_OSMESA) + #include "internal.h" @@ -42,3 +44,5 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) { } + +#endif // defined(_GLFW_OSMESA) diff --git a/Sources/GLFW/null_monitor.c b/Sources/GLFW/null_monitor.c index 0a7fe064..dcd8a29b 100644 --- a/Sources/GLFW/null_monitor.c +++ b/Sources/GLFW/null_monitor.c @@ -27,6 +27,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_OSMESA) + #include "internal.h" @@ -75,3 +77,5 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { } + +#endif // defined(_GLFW_OSMESA) diff --git a/Sources/GLFW/null_window.c b/Sources/GLFW/null_window.c index 936400d3..a2c0eb7c 100644 --- a/Sources/GLFW/null_window.c +++ b/Sources/GLFW/null_window.c @@ -27,6 +27,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(_GLFW_OSMESA) + #include "internal.h" @@ -330,3 +332,5 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, return VK_ERROR_INITIALIZATION_FAILED; } + +#endif // defined(_GLFW_OSMESA) diff --git a/Sources/GLFW/posix_time.c b/Sources/GLFW/posix_time.c index ae3d5c78..c1e496a8 100644 --- a/Sources/GLFW/posix_time.c +++ b/Sources/GLFW/posix_time.c @@ -27,6 +27,10 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +// Guard: macOS uses cocoa_time.c for timers; this file is for POSIX platforms +// (Linux with _GLFW_X11, Android with _GLFW_OSMESA, and other POSIX targets). +#if !defined(_GLFW_COCOA) + #define _POSIX_C_SOURCE 199309L #include "internal.h" @@ -88,3 +92,5 @@ uint64_t _glfwPlatformGetTimerFrequency(void) return _glfw.timer.posix.frequency; } +#endif // !defined(_GLFW_COCOA) + diff --git a/Sources/ImGui/backends/ImplGLUT.cpp b/Sources/ImGui/backends/ImplGLUT.cpp index bc6353b1..39ca8bb6 100644 --- a/Sources/ImGui/backends/ImplGLUT.cpp +++ b/Sources/ImGui/backends/ImplGLUT.cpp @@ -43,6 +43,9 @@ // zero. 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be // displayed in the About Window. 2018-03-22: Added GLUT Platform binding. +#ifdef __APPLE__ +// only for apple platforms... + #include "ImGui/ImGui.h" #ifndef IMGUI_DISABLE #include "ImplGLUT.h" @@ -436,3 +439,5 @@ void ImGui_ImplGLUT_MotionFunc(int x, int y) { //----------------------------------------------------------------------------- #endif // #ifndef IMGUI_DISABLE + +#endif // __APPLE__ diff --git a/Sources/ImGui/backends/ImplMacOS.mm b/Sources/ImGui/backends/ImplMacOS.mm index 08c39bf5..292c1833 100644 --- a/Sources/ImGui/backends/ImplMacOS.mm +++ b/Sources/ImGui/backends/ImplMacOS.mm @@ -25,6 +25,9 @@ // from the docs/ folder + read the top of imgui.cpp. Read online: // https://github.com/ocornut/imgui/tree/master/docs +#ifdef __APPLE__ +// only for apple platforms... + #import "ImGui/ImGui.h" #ifndef IMGUI_DISABLE #import "ImplMacOS.h" @@ -1033,3 +1036,5 @@ static void ImGui_ImplOSX_AddTrackingArea(NSView *_Nonnull view) { //----------------------------------------------------------------------------- #endif // #ifndef IMGUI_DISABLE + +#endif // __APPLE__ diff --git a/Sources/ImGui/backends/ImplMetal.mm b/Sources/ImGui/backends/ImplMetal.mm index 369c8675..abc18503 100644 --- a/Sources/ImGui/backends/ImplMetal.mm +++ b/Sources/ImGui/backends/ImplMetal.mm @@ -38,6 +38,9 @@ // io.BackendRendererName so it can be displayed in the About Window. // 2018-07-05: Metal: Added new Metal backend implementation. +#ifdef __APPLE__ +// only for apple platforms... + #include "ImGui/ImGui.h" #ifndef IMGUI_DISABLE #include "ImplMetal.h" @@ -675,3 +678,5 @@ - (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length //----------------------------------------------------------------------------- #endif // #ifndef IMGUI_DISABLE + +#endif // __APPLE__ diff --git a/Sources/Imath b/Sources/Imath index c19754d5..fc419a30 160000 --- a/Sources/Imath +++ b/Sources/Imath @@ -1 +1 @@ -Subproject commit c19754d5c25ace147733841a2a4dbe584ecad942 +Subproject commit fc419a3098b142b6a45e797254972e2f30372fbd diff --git a/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h b/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h index 86d11884..9092eea6 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderGlslGLContext.h @@ -18,6 +18,8 @@ #if !TARGET_OS_IPHONE #include #endif /* !TARGET_OS_IPHONE */ +#elif defined(__ANDROID__) +#include #elif defined(__linux__) || defined(__FreeBSD__) #include #endif @@ -27,6 +29,8 @@ MATERIALX_NAMESPACE_BEGIN /// Platform dependent definition of a hardware context #if defined(_WIN32) using HardwareContextHandle = HGLRC; +#elif defined(__ANDROID__) +using HardwareContextHandle = EGLContext; #elif defined(__linux__) || defined(__FreeBSD__) using HardwareContextHandle = GLXContext; #else @@ -74,7 +78,11 @@ class MX_RENDERGLSL_API GLContext { // Flag to indicate validity bool _isValid; -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__ANDROID__) + // EGL display and surface used by context operations on Android. + EGLDisplay _eglDisplay; + EGLSurface _eglSurface; +#elif defined(__linux__) || defined(__FreeBSD__) // An X window used by context operations Window _xWindow; diff --git a/Sources/MaterialX/include/MaterialX/MXRenderHwWindowWrapper.h b/Sources/MaterialX/include/MaterialX/MXRenderHwWindowWrapper.h index 2952958b..5c8fbef0 100644 --- a/Sources/MaterialX/include/MaterialX/MXRenderHwWindowWrapper.h +++ b/Sources/MaterialX/include/MaterialX/MXRenderHwWindowWrapper.h @@ -10,7 +10,7 @@ #define WIN32_LEAN_AND_MEAN #undef APIENTRY #include -#elif defined(__linux__) || defined(__FreeBSD__) +#elif !defined(__ANDROID__) && (defined(__linux__) || defined(__FreeBSD__)) #include // for Window #include // for Display using Widget = struct _WidgetRec *; @@ -28,7 +28,7 @@ using ExternalWindowHandle = HWND; using InternalWindowHandle = HDC; /// Display handle concept has no equivalence on Windows using DisplayHandle = void *; -#elif defined(__linux__) || defined(__FreeBSD__) +#elif !defined(__ANDROID__) && (defined(__linux__) || defined(__FreeBSD__)) /// External handle is a widget using ExternalWindowHandle = Widget; /// Internal handle is the window for the widget @@ -81,7 +81,7 @@ class WindowWrapper { /// Release resources stored in wrapper void release(); -#if defined(__linux__) || defined(__FreeBSD__) +#if !defined(__ANDROID__) && (defined(__linux__) || defined(__FreeBSD__)) /// Return X display Display *getXDisplay() const { return _xDisplay; } #endif @@ -94,7 +94,7 @@ class WindowWrapper { ExternalWindowHandle _externalHandle; InternalWindowHandle _internalHandle; -#if defined(__linux__) || defined(__FreeBSD__) +#if !defined(__ANDROID__) && (defined(__linux__) || defined(__FreeBSD__)) /// Window ID of framebuffer instance created in the wrapper Window _framebufferWindow; /// X Display diff --git a/Sources/MaterialX/source/MaterialXRenderGlsl/GLContext.cpp b/Sources/MaterialX/source/MaterialXRenderGlsl/GLContext.cpp index 77823db2..0ac6d9e0 100644 --- a/Sources/MaterialX/source/MaterialXRenderGlsl/GLContext.cpp +++ b/Sources/MaterialX/source/MaterialXRenderGlsl/GLContext.cpp @@ -5,6 +5,8 @@ #if defined(_WIN32) #include +#elif defined(__ANDROID__) +/* EGL included via MXRenderGlslGLContext.h */ #elif defined(__linux__) || defined(__FreeBSD__) #include #elif defined(__APPLE__) @@ -78,6 +80,65 @@ GLContext::GLContext(SimpleWindowPtr window, } } +#elif defined(__ANDROID__) + +GLContext::GLContext(const SimpleWindowPtr window, + HardwareContextHandle sharedWithContext) + : _window(window), _contextHandle(EGL_NO_CONTEXT), _isValid(false), + _eglDisplay(EGL_NO_DISPLAY), _eglSurface(EGL_NO_SURFACE) { + _eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (_eglDisplay == EGL_NO_DISPLAY) { + return; + } + if (!eglInitialize(_eglDisplay, nullptr, nullptr)) { + return; + } + + // Request an OpenGL ES 3.x-capable pbuffer config. + static const EGLint configAttribs[] = { + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_DEPTH_SIZE, 24, + EGL_STENCIL_SIZE, 8, + EGL_NONE + }; + EGLConfig config; + EGLint numConfigs = 0; + if (!eglChooseConfig(_eglDisplay, configAttribs, &config, 1, &numConfigs) || numConfigs == 0) { + return; + } + + // Offscreen pbuffer surface (mirrors the 10x10 X window on Linux). + static const EGLint pbufferAttribs[] = { + EGL_WIDTH, 10, + EGL_HEIGHT, 10, + EGL_NONE + }; + _eglSurface = eglCreatePbufferSurface(_eglDisplay, config, pbufferAttribs); + if (_eglSurface == EGL_NO_SURFACE) { + return; + } + + static const EGLint contextAttribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 3, + EGL_NONE + }; + _contextHandle = eglCreateContext(_eglDisplay, config, + sharedWithContext ? sharedWithContext : EGL_NO_CONTEXT, + contextAttribs); + if (_contextHandle == EGL_NO_CONTEXT) { + return; + } + + if (!eglMakeCurrent(_eglDisplay, _eglSurface, _eglSurface, _contextHandle)) { + return; + } + _isValid = true; +} + #elif defined(__linux__) || defined(__FreeBSD__) GLContext::GLContext(const SimpleWindowPtr window, @@ -161,6 +222,17 @@ GLContext::~GLContext() { wglDeleteContext(_contextHandle); +#elif defined(__ANDROID__) + + eglMakeCurrent(_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + if (_contextHandle != EGL_NO_CONTEXT) { + eglDestroyContext(_eglDisplay, _contextHandle); + } + if (_eglSurface != EGL_NO_SURFACE) { + eglDestroySurface(_eglDisplay, _eglSurface); + } + eglTerminate(_eglDisplay); + #elif defined(__linux__) || defined(__FreeBSD__) glXMakeCurrent(_xDisplay, None, NULL); @@ -192,6 +264,8 @@ int GLContext::makeCurrent() { #if defined(_WIN32) makeCurrentOk = wglMakeCurrent(_window->getWindowWrapper()->internalHandle(), _contextHandle); +#elif defined(__ANDROID__) + makeCurrentOk = eglMakeCurrent(_eglDisplay, _eglSurface, _eglSurface, _contextHandle) ? 1 : 0; #elif defined(__linux__) || defined(__FreeBSD__) makeCurrentOk = glXMakeCurrent(_xDisplay, _xWindow, _contextHandle); #elif defined(__APPLE__) diff --git a/Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowAndroid.cpp b/Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowAndroid.cpp new file mode 100644 index 00000000..9a3fca73 --- /dev/null +++ b/Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowAndroid.cpp @@ -0,0 +1,38 @@ +// +// Copyright Contributors to the MaterialX Project +// SPDX-License-Identifier: Apache-2.0 +// + +#if defined(__ANDROID__) + +#include + +MATERIALX_NAMESPACE_BEGIN + +// Android has no native X11/Cocoa window system for offline MaterialX rendering. +// These are intentional no-op stubs; actual rendering is driven by the Android +// runtime (GLSurfaceView / ANativeActivity) via EGL. + +SimpleWindow::SimpleWindow() : _width(0), _height(0) +{ + static unsigned int windowCount = 1; + _id = windowCount; + windowCount++; +} + +bool SimpleWindow::initialize(const char * /*title*/, + unsigned int width, + unsigned int height, + void * /*applicationShell*/) +{ + _width = width; + _height = height; + _windowWrapper = WindowWrapper::create(nullptr); + return true; +} + +SimpleWindow::~SimpleWindow() {} + +MATERIALX_NAMESPACE_END + +#endif // defined(__ANDROID__) diff --git a/Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowLinux.cpp b/Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowLinux.cpp index e3a97dfb..5d9584f7 100644 --- a/Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowLinux.cpp +++ b/Sources/MaterialX/source/MaterialXRenderHw/SimpleWindowLinux.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if defined(__linux__) || defined(__FreeBSD__) +#if !defined(__ANDROID__) && (defined(__linux__) || defined(__FreeBSD__)) #include diff --git a/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp b/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp index e0b6b493..88dba175 100644 --- a/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp +++ b/Sources/MaterialX/source/MaterialXRenderHw/WindowWrapper.cpp @@ -5,7 +5,7 @@ #include -#if defined(__linux__) || defined(__FreeBSD__) +#if !defined(__ANDROID__) && (defined(__linux__) || defined(__FreeBSD__)) #include #elif defined(__APPLE__) #include @@ -39,7 +39,7 @@ void WindowWrapper::release() { _internalHandle = 0; } -#elif defined(__linux__) || defined(__FreeBSD__) +#elif !defined(__ANDROID__) && (defined(__linux__) || defined(__FreeBSD__)) WindowWrapper::WindowWrapper(ExternalWindowHandle externalHandle, InternalWindowHandle internalHandle, @@ -64,6 +64,24 @@ void WindowWrapper::release() { _xDisplay = 0; } +#elif defined(__ANDROID__) + +// Android has no X11/Cocoa window wrapper; EGL surfaces are managed by the +// Android runtime. These are intentional no-op stubs. +WindowWrapper::WindowWrapper(ExternalWindowHandle externalHandle, + InternalWindowHandle internalHandle, + DisplayHandle /*display*/) { + _externalHandle = externalHandle; + _internalHandle = internalHandle; +} + +WindowWrapper::~WindowWrapper() { release(); } + +void WindowWrapper::release() { + _externalHandle = nullptr; + _internalHandle = nullptr; +} + #elif defined(__APPLE__) WindowWrapper::WindowWrapper(ExternalWindowHandle externalHandle, diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm index fe4f7b6d..0cb8c166 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalFramebuffer.mm @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#ifdef __APPLE__ +// only for apple platforms... + #include #include @@ -170,3 +173,5 @@ new MetalFramebuffer(device, width, height, channelCount, baseType, } MATERIALX_NAMESPACE_END + +#endif // __APPLE__ diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm index abafb40f..ca0bb5d5 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalState.mm @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#ifdef __APPLE__ +// only for apple platforms... + #import #include #import @@ -255,3 +258,5 @@ MaterialX::MetalFramebufferPtr MetalState::currentFramebuffer() { return framebufferStack.top(); } + +#endif // __APPLE__ diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm index 6882877f..c35b2631 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MetalTextureHandler.mm @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#ifdef __APPLE__ +// only for apple platforms... + #include #include #include @@ -457,3 +460,5 @@ } MATERIALX_NAMESPACE_END + +#endif // __APPLE__ diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm index f92872cb..f84ecfee 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslMaterial.mm @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#ifdef __APPLE__ +// only for apple platforms... + #include #include @@ -303,3 +306,5 @@ } MATERIALX_NAMESPACE_END + +#endif // __APPLE__ diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm index daa4d23b..2fabb11b 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslPipelineStateObject.mm @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#ifdef __APPLE__ +// only for apple platforms... + #import #include @@ -1600,3 +1603,5 @@ throw ExceptionRenderError( } MATERIALX_NAMESPACE_END + +#endif // __APPLE__ diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm b/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm index dec157ef..a5ded7ac 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/MslRenderer.mm @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#ifdef __APPLE__ +// only for apple platforms... + #import #include @@ -245,3 +248,5 @@ } MATERIALX_NAMESPACE_END + +#endif // __APPLE__ diff --git a/Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.mm b/Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.mm index 894e6c5a..a1f90988 100644 --- a/Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.mm +++ b/Sources/MaterialX/source/MaterialXRenderMsl/TextureBaker.mm @@ -3,6 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#ifdef __APPLE__ +// only for apple platforms... + #include #include @@ -21,3 +24,5 @@ false) {} MATERIALX_NAMESPACE_END + +#endif // __APPLE__ diff --git a/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceOpenGL.h b/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceOpenGL.h index 989177a6..10971fca 100644 --- a/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceOpenGL.h +++ b/Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceOpenGL.h @@ -36,7 +36,7 @@ #include #endif #endif -#elif defined(ANDROID) +#elif defined(__ANDROID__) #include #else #if defined(_WIN32) diff --git a/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm b/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm index 2c600179..70308afb 100644 --- a/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm +++ b/Sources/OpenSubdiv/osd/MTLComputeEvaluator.mm @@ -22,6 +22,9 @@ // language governing permissions and limitations under the Apache License. // +#ifdef __APPLE__ +// only for apple platforms... + #include "OpenSubdiv/OSDSurfaceMTLComputeEvaluator.h" #include "OpenSubdiv/OSDSurfaceMTLPatchShaderSource.h" @@ -611,3 +614,5 @@ } // end namespace OPENSUBDIV_VERSION } // end namespace OpenSubdiv + +#endif // __APPLE__ diff --git a/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm b/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm index e6585b7e..f781f551 100644 --- a/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm +++ b/Sources/OpenSubdiv/osd/MTLLegacyGregoryPatchTable.mm @@ -22,6 +22,9 @@ // language governing permissions and limitations under the Apache License. // +#ifdef __APPLE__ +// only for apple platforms... + #include "OpenSubdiv/OSDSurfaceMTLLegacyGregoryPatchTable.h" #import @@ -107,3 +110,5 @@ } // end namespace OPENSUBDIV_VERSION } // end namespace OpenSubdiv + +#endif // __APPLE__ diff --git a/Sources/OpenSubdiv/osd/MTLMesh.mm b/Sources/OpenSubdiv/osd/MTLMesh.mm index 6fc9e505..18d2f352 100644 --- a/Sources/OpenSubdiv/osd/MTLMesh.mm +++ b/Sources/OpenSubdiv/osd/MTLMesh.mm @@ -1 +1,6 @@ +#ifdef __APPLE__ +// only for apple platforms... + #import "OpenSubdiv/OSDSurfaceMTLMesh.h" + +#endif // __APPLE__ diff --git a/Sources/OpenSubdiv/osd/MTLPatchShaderSource.mm b/Sources/OpenSubdiv/osd/MTLPatchShaderSource.mm index 08be823b..ef5db05f 100644 --- a/Sources/OpenSubdiv/osd/MTLPatchShaderSource.mm +++ b/Sources/OpenSubdiv/osd/MTLPatchShaderSource.mm @@ -22,6 +22,9 @@ // language governing permissions and limitations under the Apache License. // +#ifdef __APPLE__ +// only for apple platforms... + #include "OpenSubdiv/OSDAdaptiveError.h" #include "OpenSubdiv/OSDSurfaceMTLPatchShaderSource.h" @@ -6348,3 +6351,5 @@ } // end namespace OPENSUBDIV_VERSION } // end namespace OpenSubdiv + +#endif // __APPLE__ diff --git a/Sources/OpenSubdiv/osd/MTLPatchTable.mm b/Sources/OpenSubdiv/osd/MTLPatchTable.mm index 815cd11c..6facddfe 100644 --- a/Sources/OpenSubdiv/osd/MTLPatchTable.mm +++ b/Sources/OpenSubdiv/osd/MTLPatchTable.mm @@ -22,6 +22,9 @@ // language governing permissions and limitations under the Apache License. // +#ifdef __APPLE__ +// only for apple platforms... + #import "OpenSubdiv/OSDAdaptivePatchTable.h" #import "OpenSubdiv/OSDSurfaceCpuPatchTable.h" #import "OpenSubdiv/OSDSurfaceMTLPatchTable.h" @@ -155,3 +158,5 @@ } // end namespace Osd } // end namespace OPENSUBDIV_VERSION } // end namespace OpenSubdiv + +#endif // __APPLE__ diff --git a/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm b/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm index 66bbee2a..06fdd712 100644 --- a/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm +++ b/Sources/OpenSubdiv/osd/MTLVertexBuffer.mm @@ -22,6 +22,9 @@ // language governing permissions and limitations under the Apache License. // +#ifdef __APPLE__ +// only for apple platforms... + #include "OpenSubdiv/OSDSurfaceMTLVertexBuffer.h" #import #include @@ -90,3 +93,5 @@ } // end namespace OPENSUBDIV_VERSION } // end namespace OpenSubdiv + +#endif // __APPLE__ From 6e5ebeb1c4f3b4c9032d30f83b09f799acf13988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furby=E2=84=A2?= Date: Tue, 9 Jun 2026 00:11:53 -0600 Subject: [PATCH 4/7] Update Imath module for Android support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Furby™ --- Sources/Imath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Imath b/Sources/Imath index fc419a30..a4d3cc9d 160000 --- a/Sources/Imath +++ b/Sources/Imath @@ -1 +1 @@ -Subproject commit fc419a3098b142b6a45e797254972e2f30372fbd +Subproject commit a4d3cc9da5e3bd9eca23934ec8c0a462eb6f1cf0 From 11bd6a12c953859f873a52f3c12ba212110db1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furby=E2=84=A2?= Date: Sun, 21 Jun 2026 11:51:49 -0600 Subject: [PATCH 5/7] MaterialX: Remove 'WindowCocoaWrappers.m' on non-apple platforms. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Furby™ --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index b56e7654..30d2b35c 100644 --- a/Package.swift +++ b/Package.swift @@ -1006,6 +1006,7 @@ func getConfig(for target: PkgTarget) -> TargetInfo /* no metal on linux or windows or wasm */ config.exclude += [ "source/MaterialXRenderMsl", + "source/MaterialXRenderHw/WindowCocoaWrappers.m" ] #endif /* !os(macOS) && !os(visionOS) && !os(iOS) && !os(tvOS) && !os(watchOS) */ case .osd: From 9bf48df19a5d1e2a5352e8b4c4da9e7570c0c076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furby=E2=84=A2?= Date: Sun, 21 Jun 2026 13:00:06 -0600 Subject: [PATCH 6/7] MaterialX: Remove 'GLCocoaWrappers.m' on non-apple platforms. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Furby™ --- Package.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 30d2b35c..d2844aa3 100644 --- a/Package.swift +++ b/Package.swift @@ -1006,7 +1006,8 @@ func getConfig(for target: PkgTarget) -> TargetInfo /* no metal on linux or windows or wasm */ config.exclude += [ "source/MaterialXRenderMsl", - "source/MaterialXRenderHw/WindowCocoaWrappers.m" + "source/MaterialXRenderHw/WindowCocoaWrappers.m", + "source/MaterialXRenderGlsl/GLCocoaWrappers.m", ] #endif /* !os(macOS) && !os(visionOS) && !os(iOS) && !os(tvOS) && !os(watchOS) */ case .osd: From 5a49dfb50d9cd29da57776021675f4daf7992b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furby=E2=84=A2?= Date: Tue, 14 Jul 2026 15:48:15 -0600 Subject: [PATCH 7/7] Align TBB linkage and config with OpenUSD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OpenUSD links one TBB component (COMPONENTS tbb) and never references tbbmalloc or tbbmalloc_proxy. The proxy replaces the process's global malloc/free/malloc_size by symbol interposition, which had a tendency to crash when using Swift Testing. TBB_USE_DEBUG and TBB_USE_PROFILING_TOOLS pinned to 0 across OneTBB, tbb, and MetaTBB - matching what the values resolve to on clang/gcc, set explicitly because SwiftPM's C++ interop can't resolve the #ifndef chain reliably. Signed-off-by: Furby™ --- Package.swift | 132 +++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 54 deletions(-) diff --git a/Package.swift b/Package.swift index d2844aa3..4d7cb3f6 100644 --- a/Package.swift +++ b/Package.swift @@ -40,36 +40,36 @@ let package = Package( ] ), - .target( - name: "TBBMallocProxy", - dependencies: [ - .target(name: "OneTBB"), - ], - cxxSettings: [ - .define("_XOPEN_SOURCE", to: "1", .when(platforms: Arch.OS.apple.platform)), - .define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])), - .define("_ALLOW_KEYWORD_MACROS", to: "1", .when(platforms: [.windows])), - .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), - .define("TBBPROXY_NO_DLLMAIN") - ] - ), - - .target( - name: "TBBMalloc", - dependencies: [ - .target(name: "OneTBB"), - .target(name: "TBBMallocProxy"), - ], - cxxSettings: [ - .headerSearchPath("include/TBBMalloc"), - .define("_XOPEN_SOURCE", to: "1", .when(platforms: Arch.OS.apple.platform)), - .define("__TBBMALLOC_BUILD", to: "1"), - .define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])), - .define("_ALLOW_KEYWORD_MACROS", to: "1", .when(platforms: [.windows])), - .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), - .define("TBBMALLOC_NO_DLLMAIN") - ] - ), + // .target( + // name: "TBBMallocProxy", + // dependencies: [ + // .target(name: "OneTBB"), + // ], + // cxxSettings: [ + // .define("_XOPEN_SOURCE", to: "1", .when(platforms: Arch.OS.apple.platform)), + // .define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])), + // .define("_ALLOW_KEYWORD_MACROS", to: "1", .when(platforms: [.windows])), + // .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), + // .define("TBBPROXY_NO_DLLMAIN") + // ] + // ), + + // .target( + // name: "TBBMalloc", + // dependencies: [ + // .target(name: "OneTBB"), + // .target(name: "TBBMallocProxy"), + // ], + // cxxSettings: [ + // .headerSearchPath("include/TBBMalloc"), + // .define("_XOPEN_SOURCE", to: "1", .when(platforms: Arch.OS.apple.platform)), + // .define("__TBBMALLOC_BUILD", to: "1"), + // .define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])), + // .define("_ALLOW_KEYWORD_MACROS", to: "1", .when(platforms: [.windows])), + // .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), + // .define("TBBMALLOC_NO_DLLMAIN") + // ] + // ), .target( name: "OneTBB", @@ -84,7 +84,14 @@ let package = Package( .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), .define("__TBB_BUILD"), .define("__TBB_NO_IMPLICIT_LINKAGE", to: "1", .when(platforms: [.windows])), - .define("TBB_NO_LIB_LINKAGE") + .define("TBB_NO_LIB_LINKAGE"), + // TBB derives TBB_USE_DEBUG (and, from it, TBB_USE_PROFILING_TOOLS and + // TBB_USE_ASSERT) from _DEBUG, which only MSVC defines. On clang/gcc it's + // absent, so upstream OpenUSD resolves both to 0 in every configuration. + // Pinned explicitly here because SwiftPM's C++ interop can't be relied on + // to resolve the #ifndef chain identically on both sides of the boundary. + .define("TBB_USE_DEBUG", to: "0"), + .define("TBB_USE_PROFILING_TOOLS", to: "0"), ] ), @@ -92,8 +99,8 @@ let package = Package( name: "tbb", dependencies: [ .target(name: "OneTBB"), - .target(name: "TBBMalloc"), - .target(name: "TBBMallocProxy"), + // .target(name: "TBBMalloc"), + // .target(name: "TBBMallocProxy"), ], publicHeadersPath: "include", cxxSettings: [ @@ -104,7 +111,13 @@ let package = Package( .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), .define("__TBB_NO_IMPLICIT_LINKAGE", to: "1", .when(platforms: [.windows])), .define("TBB_NO_LIB_LINKAGE"), - .define("TBB_USE_PROFILING_TOOLS", to: "2"), + // TBB derives TBB_USE_DEBUG (and, from it, TBB_USE_PROFILING_TOOLS and + // TBB_USE_ASSERT) from _DEBUG, which only MSVC defines. On clang/gcc it's + // absent, so upstream OpenUSD resolves both to 0 in every configuration. + // Pinned explicitly here because SwiftPM's C++ interop can't be relied on + // to resolve the #ifndef chain identically on both sides of the boundary. + .define("TBB_USE_DEBUG", to: "0"), + .define("TBB_USE_PROFILING_TOOLS", to: "0"), ] ), @@ -112,17 +125,23 @@ let package = Package( name: "MetaTBB", dependencies: [ .target(name: "OneTBB"), - .target(name: "TBBMalloc"), - .target(name: "TBBMallocProxy"), + // .target(name: "TBBMalloc"), + // .target(name: "TBBMallocProxy"), .target(name: "tbb", condition: .when(platforms: Arch.OS.applewindowsdroid.platform)), ], exclude: [], cxxSettings: [ - .define("_XOPEN_SOURCE"), - .define("TBB_USE_PROFILING_TOOLS", to: "2"), + .define("_XOPEN_SOURCE", to: "1", .when(platforms: Arch.OS.apple.platform)), .define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])), .define("_ALLOW_KEYWORD_MACROS", to: "1", .when(platforms: [.windows])), .define("static_assert(_conditional, ...)", to: "", .when(platforms: [.windows])), + // TBB derives TBB_USE_DEBUG (and, from it, TBB_USE_PROFILING_TOOLS and + // TBB_USE_ASSERT) from _DEBUG, which only MSVC defines. On clang/gcc it's + // absent, so upstream OpenUSD resolves both to 0 in every configuration. + // Pinned explicitly here because SwiftPM's C++ interop can't be relied on + // to resolve the #ifndef chain identically on both sides of the boundary. + .define("TBB_USE_DEBUG", to: "0"), + .define("TBB_USE_PROFILING_TOOLS", to: "0"), ], swiftSettings: [ .interoperabilityMode(.Cxx), @@ -763,10 +782,6 @@ func getConfig(for target: PkgTarget) -> TargetInfo { case .draco: break - case .tbbMallocProxy: - break - case .tbbMalloc: - break case .oneTbb: break case .metaTbb: @@ -1135,14 +1150,14 @@ func getConfig(for target: PkgTarget) -> TargetInfo name: "MetaTBB", targets: ["MetaTBB"] ), - .library( - name: "TBBMalloc", - targets: ["TBBMalloc"] - ), - .library( - name: "TBBMallocProxy", - targets: ["TBBMallocProxy"] - ), + // .library( + // name: "TBBMalloc", + // targets: ["TBBMalloc"] + // ), + // .library( + // name: "TBBMallocProxy", + // targets: ["TBBMallocProxy"] + // ), .library( name: "MicrosoftSTL", targets: ["MicrosoftSTL"] @@ -1313,7 +1328,9 @@ enum Arch case nixnodroid /// everything not android (all - android). case nodroid - + /// everything not wasm (all - wasi). + case nowasm + var platform: [Platform] { switch self @@ -1327,6 +1344,7 @@ enum Arch case .applewindowsdroid: [.macOS, .iOS, .visionOS, .tvOS, .watchOS, .windows, .android] case .nixnodroid: [.macOS, .iOS, .visionOS, .tvOS, .watchOS, .linux, .openbsd] case .nodroid: [.macOS, .iOS, .visionOS, .tvOS, .watchOS, .linux, .openbsd, .windows] + case .nowasm: [.macOS, .iOS, .visionOS, .tvOS, .watchOS, .linux, .android, .openbsd, .windows] } } @@ -1413,7 +1431,13 @@ enum Arch static func ocioDeps() -> [Target.Dependency] { // only add sse2neon on arm arch. - let sse2neon: [Target.Dependency] = Arch.cpuArch.family.contains(.arm) ? [.target(name: "sse2neon")] : [] + let sse2neon: [Target.Dependency] = Arch.cpuArch.family.contains(.arm) + ? [ + .target( + name: "sse2neon", + condition: .when(platforms: Arch.OS.nowasm.platform) + ) + ] : [] #if os(Linux) || os(OpenBSD) || os(FreeBSD) return [ @@ -1564,8 +1588,8 @@ enum Arch enum PkgTarget: String { case draco = "Draco" - case tbbMallocProxy = "TBBMallocProxy" - case tbbMalloc = "TBBMalloc" + // case tbbMallocProxy = "TBBMallocProxy" + // case tbbMalloc = "TBBMalloc" case oneTbb = "OneTBB" case metaTbb = "MetaTBB" case zstd = "ZStandard"