From 724126317bca5b91beda2828b05c8a3ee53cabba Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 26 Sep 2024 08:38:24 +0200 Subject: [PATCH] Upgrade `metal_irconverter` headers and bindings to `2.0.4` (#18) Depends on #17 This contains all the new bindings added to the public API in [the 2.0 release](https://developer.apple.com/metal/shader-converter/#changelog). Fortunately, as we can now see in the diff thanks to #17, there's no binary diff in the `repr(C)` structures nor used constants. --- Cargo.toml | 2 +- bindings_generator/src/main.rs | 5 + .../vendor/metal_irconverter/LICENSE.txt | 2 +- .../ir_comparison_function.h | 2 +- .../ir_descriptor_range_flags.h | 2 +- .../vendor/metal_irconverter/ir_filter.h | 2 +- .../vendor/metal_irconverter/ir_format.h | 2 +- .../ir_input_classification.h | 2 +- .../metal_irconverter/ir_input_primitive.h | 2 +- .../metal_irconverter/ir_input_topology.h | 2 +- .../ir_root_descriptor_flags.h | 2 +- .../ir_root_signature_flags.h | 2 +- .../metal_irconverter/ir_shader_visibility.h | 2 +- .../metal_irconverter/ir_tessellator_domain.h | 2 +- .../ir_tessellator_output_primitive.h | 2 +- .../ir_tessellator_partitioning.h | 2 +- .../ir_texture_address_mode.h | 2 +- .../vendor/metal_irconverter/ir_version.h | 8 +- .../metal_irconverter/metal_irconverter.h | 141 +++++- .../metal_irconverter_runtime/LICENSE.txt | 2 +- .../metal_irconverter_runtime/ir_raytracing.h | 2 +- .../ir_tessellator_tables.h | 2 +- .../metal_irconverter_runtime.h | 400 +++++++++++++----- runtime/Cargo.toml | 2 +- runtime/src/bindings.rs | 10 + src/bindings.rs | 215 +++++++++- src/lib.rs | 2 + 27 files changed, 660 insertions(+), 161 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 302f79c..f479ab8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "saxaboom" -version = "0.1.0+irconverter-1.1" +version = "0.1.0+irconverter-2.0" authors = ["Traverse Research "] edition = "2021" license = "Apache-2.0" diff --git a/bindings_generator/src/main.rs b/bindings_generator/src/main.rs index c3a0700..f259477 100644 --- a/bindings_generator/src/main.rs +++ b/bindings_generator/src/main.rs @@ -101,6 +101,11 @@ impl ParseCallbacks for RenameCallback { enum_name = String::from("IRRuntimeTessellatorOutput"); } + // For this specific enum, strip off the `Mode` suffix + if enum_name == "IRRayGenerationCompilationMode" { + enum_name = String::from("IRRayGenerationCompilation"); + } + let new_name = original_variant_name .strip_prefix(&enum_name) .unwrap_or(original_variant_name); diff --git a/bindings_generator/vendor/metal_irconverter/LICENSE.txt b/bindings_generator/vendor/metal_irconverter/LICENSE.txt index 6c877ff..97849a6 100644 --- a/bindings_generator/vendor/metal_irconverter/LICENSE.txt +++ b/bindings_generator/vendor/metal_irconverter/LICENSE.txt @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright © 2023 Apple Inc. + Copyright © 2023-2024 Apple Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_comparison_function.h b/bindings_generator/vendor/metal_irconverter/ir_comparison_function.h index ee93dda..34fff6e 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_comparison_function.h +++ b/bindings_generator/vendor/metal_irconverter/ir_comparison_function.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_descriptor_range_flags.h b/bindings_generator/vendor/metal_irconverter/ir_descriptor_range_flags.h index f5d8957..5ee3d73 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_descriptor_range_flags.h +++ b/bindings_generator/vendor/metal_irconverter/ir_descriptor_range_flags.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_filter.h b/bindings_generator/vendor/metal_irconverter/ir_filter.h index 4cc2aab..31ac45d 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_filter.h +++ b/bindings_generator/vendor/metal_irconverter/ir_filter.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_format.h b/bindings_generator/vendor/metal_irconverter/ir_format.h index 307a062..f0b6e17 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_format.h +++ b/bindings_generator/vendor/metal_irconverter/ir_format.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_input_classification.h b/bindings_generator/vendor/metal_irconverter/ir_input_classification.h index cd9ed77..139d68b 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_input_classification.h +++ b/bindings_generator/vendor/metal_irconverter/ir_input_classification.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_input_primitive.h b/bindings_generator/vendor/metal_irconverter/ir_input_primitive.h index 376aa96..55137da 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_input_primitive.h +++ b/bindings_generator/vendor/metal_irconverter/ir_input_primitive.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_input_topology.h b/bindings_generator/vendor/metal_irconverter/ir_input_topology.h index d120c7c..88e400d 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_input_topology.h +++ b/bindings_generator/vendor/metal_irconverter/ir_input_topology.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_root_descriptor_flags.h b/bindings_generator/vendor/metal_irconverter/ir_root_descriptor_flags.h index d4f690b..2fd0474 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_root_descriptor_flags.h +++ b/bindings_generator/vendor/metal_irconverter/ir_root_descriptor_flags.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_root_signature_flags.h b/bindings_generator/vendor/metal_irconverter/ir_root_signature_flags.h index 95acf57..069a8e2 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_root_signature_flags.h +++ b/bindings_generator/vendor/metal_irconverter/ir_root_signature_flags.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_shader_visibility.h b/bindings_generator/vendor/metal_irconverter/ir_shader_visibility.h index e251c92..b275b4b 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_shader_visibility.h +++ b/bindings_generator/vendor/metal_irconverter/ir_shader_visibility.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_tessellator_domain.h b/bindings_generator/vendor/metal_irconverter/ir_tessellator_domain.h index 8ed5d51..c3cac0f 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_tessellator_domain.h +++ b/bindings_generator/vendor/metal_irconverter/ir_tessellator_domain.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_tessellator_output_primitive.h b/bindings_generator/vendor/metal_irconverter/ir_tessellator_output_primitive.h index 261e332..a656a8e 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_tessellator_output_primitive.h +++ b/bindings_generator/vendor/metal_irconverter/ir_tessellator_output_primitive.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_tessellator_partitioning.h b/bindings_generator/vendor/metal_irconverter/ir_tessellator_partitioning.h index e221f18..10216d8 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_tessellator_partitioning.h +++ b/bindings_generator/vendor/metal_irconverter/ir_tessellator_partitioning.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_texture_address_mode.h b/bindings_generator/vendor/metal_irconverter/ir_texture_address_mode.h index d3961b3..5f6f0fa 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_texture_address_mode.h +++ b/bindings_generator/vendor/metal_irconverter/ir_texture_address_mode.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter/ir_version.h b/bindings_generator/vendor/metal_irconverter/ir_version.h index 2c325dc..c0ff83b 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_version.h +++ b/bindings_generator/vendor/metal_irconverter/ir_version.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ #ifndef IRVERSION_H #define IRVERSION_H -#define IR_VERSION_MAJOR 1 -#define IR_VERSION_MINOR 1 -#define IR_VERSION_PATCH 0 +#define IR_VERSION_MAJOR 2 +#define IR_VERSION_MINOR 0 +#define IR_VERSION_PATCH 4 #define IR_SUPPORTS_VERSION(major, minor, patch) \ ((major < IR_VERSION_MAJOR) || \ diff --git a/bindings_generator/vendor/metal_irconverter/metal_irconverter.h b/bindings_generator/vendor/metal_irconverter/metal_irconverter.h index 806cae2..ea8e33f 100644 --- a/bindings_generator/vendor/metal_irconverter/metal_irconverter.h +++ b/bindings_generator/vendor/metal_irconverter/metal_irconverter.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,6 +25,12 @@ #import #endif // __APPLE__ +#ifdef _MSC_VER +#define IR_DEPRECATED(message) __declspec(deprecated(message)) +#else +#define IR_DEPRECATED(message) __attribute__((deprecated(message))) +#endif // _MSC_VER + #ifdef __cplusplus extern "C" { #else @@ -128,7 +134,7 @@ typedef struct IRVertexInputTable { uint32_t NumDescriptorRanges; const IRDescriptorRange* pDescriptorRanges; -} IRVertexInput; +} IRVertexInputTable; typedef struct IRRootConstants { @@ -181,14 +187,15 @@ typedef enum IRStaticBorderColor typedef enum IRCompatibilityFlags { - IRCompatibilityFlagNone = 0, - IRCompatibilityFlagBoundsCheck = (1 << 0), - IRCompatibilityFlagVertexPositionInfToNan = (1 << 1), - IRCompatibilityFlagTextureMinLODClamp = (1 << 2), - IRCompatibilityFlagSamplerLODBias = (1 << 3), - IRCompatibilityFlagPositionInvariance = (1 << 4), - IRCompatibilityFlagSampleNanToZero = (1 << 5), - + IRCompatibilityFlagNone = 0, + IRCompatibilityFlagBoundsCheck = (1 << 0), + IRCompatibilityFlagVertexPositionInfToNan = (1 << 1), + IRCompatibilityFlagTextureMinLODClamp = (1 << 2), + IRCompatibilityFlagSamplerLODBias = (1 << 3), + IRCompatibilityFlagPositionInvariance = (1 << 4), + IRCompatibilityFlagSampleNanToZero = (1 << 5), + IRCompatibilityFlagTexWriteRoundingRTZ = (1 << 6), + IRCompatibilityFlagSuppress2DComputeDerivativeErrors = (1 << 7) } IRCompatibilityFlags; typedef struct IRStaticSamplerDescriptor @@ -284,8 +291,8 @@ typedef struct IRInputElementDescriptor1 IRFormat format; uint32_t inputSlot; uint32_t alignedByteOffset; - IRInputClassification inputSlotClass; uint32_t instanceDataStepRate; + IRInputClassification inputSlotClass; } IRInputElementDescriptor1; @@ -325,6 +332,12 @@ typedef enum IRRaytracingPipelineFlags IRRaytracingPipelineFlagSkipProceduralPrimitives = 0x200 } IRRaytracingPipelineFlags; +typedef enum IRRayGenerationCompilationMode +{ + IRRayGenerationCompilationKernel, + IRRayGenerationCompilationVisibleFunction +} IRRayGenerationCompilationMode; + enum IRErrorCode { IRErrorCodeNoError, @@ -343,6 +356,7 @@ enum IRErrorCode IRErrorCodeUnableToLinkModule, IRErrorCodeUnrecognizedDXILHeader, IRErrorCodeInvalidRaytracingAttribute, + IRErrorCodeNullHullShaderInputOutputMismatch, IRErrorCodeUnknown }; @@ -454,7 +468,7 @@ void IRCompilerDestroy(IRCompiler* compiler); * @param entryPointName optional entry point name to compile when converting a library with multiple entry points. * @param input input IR object. * @param error on return, if the compiler generates any errors, this optional out parameter contains error information. If an error occurs and this parameter is non-NULL, you must free it by calling IRErrorDestroy. - * @return an IR Object containing MetalIR compiled from the input IR, or NULL if an error occurs. You must destroy this object by calling IRObjectDestroy. + * @return an IR Object containing MetalIR compiled and linked from the input IR, or NULL if an error occurs. You must destroy this object by calling IRObjectDestroy. */ IRObject* IRCompilerAllocCompileAndLink(IRCompiler* compiler, const char* entryPointName, const IRObject* input, IRError** error); @@ -546,7 +560,7 @@ void IRCompilerSetHitgroupType(IRCompiler* compiler, IRHitGroupType hitGroupType #define IRIntrinsicMaskClosestHitAll 0x7FFFFFFF #define IRIntrinsicMaskMissShaderAll 0x7FFF -#define IRIntrinsicMaskCallableShaderAll 0x7FFF +#define IRIntrinsicMaskCallableShaderAll 0x703F #define IRIntrinsicMaskAnyHitShaderAll ((uint64_t)-1) #define IRRayTracingUnlimitedRecursionDepth (-1) @@ -570,9 +584,10 @@ uint64_t IRObjectGatherRaytracingIntrinsics(IRObject* input, const char* entryPo * @param anyHit bitwise OR mask of all any hit shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskAnyHitShaderAll`). * @param callableArgs bitwise OR mask of all callable shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskCallableShaderAll`). * @param maxRecursiveDepth stop point for recursion. Pass `IRRayTracingUnlimitedRecursionDepth` for no limit. + * @param rayGenerationCompilationMode set the ray-generation shader compilation mode to compile either as a compute kernel, or as a visible function for a shader binding table. * @warning providing mask values other than the defaults or those returned by `IRObjectGatherRaytracingIntrinsics` may cause subsequent shader compilations to fail. */ -void IRCompilerSetRayTracingPipelineArguments(IRCompiler* compiler, uint32_t maxAttributeSizeInBytes, IRRaytracingPipelineFlags raytracingPipelineFlags, uint64_t chs, uint64_t miss, uint64_t anyHit, uint64_t callableArgs, int maxRecursiveDepth); +void IRCompilerSetRayTracingPipelineArguments(IRCompiler* compiler, uint32_t maxAttributeSizeInBytes, IRRaytracingPipelineFlags raytracingPipelineFlags, uint64_t chs, uint64_t miss, uint64_t anyHit, uint64_t callableArgs, int maxRecursiveDepth, IRRayGenerationCompilationMode rayGenerationCompilationMode); /** * Configure compiler compatibility flags. @@ -695,6 +710,13 @@ void IRCompilerSetMinimumGPUFamily(IRCompiler* compiler, IRGPUFamily family); */ void IRCompilerIgnoreRootSignature(IRCompiler* compiler, bool ignoreEmbeddedRootSignature); +/** + * Set compiler settings to ignore debug information. + * @param compiler compiler for which to set the flags. + * @param ignoreDebugInformation whether dxil debug information should be ignored. Defaults to false. + */ +void IRCompilerIgnoreDebugInformation(IRCompiler* compiler, bool ignoreDebugInformation); + typedef enum IROperatingSystem { IROperatingSystem_macOS, @@ -752,7 +774,7 @@ dispatch_data_t IRMetalLibGetBytecodeData(const IRMetalLibBinary* lib); #endif // __APPLE__ /** - * Serialize an MetalIR object's shader bytecode to disk. + * Serialize a MetalIR object's shader bytecode to disk. * @param outputPath path into which to write the serialized MetalIR. * @param obj IRObject containing the bytecode to serialize. * @param stage shader stage to serialize. @@ -1226,43 +1248,130 @@ void IRRootSignatureGetResourceLocations(const IRRootSignature* rootSignature, I * Serialize reflection information into JSON. * @param reflection reflection object. * @return null-terminated string containing JSON. You need to release this string by calling IRShaderReflectionFreeString. + * @deprecated use IRShaderReflectionCopyJSONString instead. */ +IR_DEPRECATED("use IRShaderReflectionCopyJSONString instead.") const char* IRShaderReflectionAllocStringAndSerialize(IRShaderReflection* reflection); +/** + * Serialize reflection information into JSON. + * @param reflection reflection object. + * @return null-terminated string containing JSON. You need to release this string by calling IRShaderReflectionFreeString. + */ +const char* IRShaderReflectionCopyJSONString(const IRShaderReflection* reflection); + /** * Release a string allocated by IRShaderReflectionAllocStringAndSerialize. * @param serialized string to release. + * @deprecated use IRShaderReflectionReleaseString instead. */ +IR_DEPRECATED("use IRShaderReflectionReleaseString instead.") void IRShaderReflectionFreeString(const char* serialized); +/** + * Release a string allocated by IRShaderReflectionAllocStringAndSerialize. + * @param serialized string to release. + */ +void IRShaderReflectionReleaseString(const char* serialized); + /** * Deserialize a JSON string into a reflection object. * @param blob null-terminated JSON string containing reflection information. * @param reflection reflection object into which to deserialize. + * @deprecated use IRShaderReflectionCreateFromJSON instead. */ +IR_DEPRECATED("use IRShaderReflectionCreateFromJSON instead.") void IRShaderReflectionDeserialize(const char* blob, IRShaderReflection* reflection); +/** + * Deserialize a JSON string into a reflection object. + * @param json null-terminated JSON string containing reflection information. + * @return a newly-allocated shader reflection object that you need to release by calling IRShaderReflectionDestroy, + * or NULL on error. + */ +IRShaderReflection* IRShaderReflectionCreateFromJSON(const char* json); + /** * Serialize a root signature descriptor into a string representation. * @param rootSignatureDescriptor root signature descriptor to serialize. * @return a string representation of the root signature descriptor. You need to release this string by calling IRVersionedRootSignatureDescriptorFreeString. + * @deprecated use IRVersionedRootSignatureDescriptorCopyJSONString instead. */ +IR_DEPRECATED("use IRVersionedRootSignatureDescriptorCopyJSONString instead.") const char* IRVersionedRootSignatureDescriptorAllocStringAndSerialize(IRVersionedRootSignatureDescriptor* rootSignatureDescriptor); +/** + * Serialize a root signature descriptor into a string representation. + * @param rootSignatureDescriptor root signature descriptor to serialize. + * @return a string representation of the root signature descriptor. You need to release this string by calling IRVersionedRootSignatureDescriptorFreeString. + */ +const char* IRVersionedRootSignatureDescriptorCopyJSONString(IRVersionedRootSignatureDescriptor* rootSignatureDescriptor); + /** * Release a string allocated by IRVersionedRootSignatureDescriptorAllocStringAndSerialize. * @param serialized string to release. + * @deprecated use IRVersionedRootSignatureDescriptorReleaseString instead. */ +IR_DEPRECATED("use IRVersionedRootSignatureDescriptorReleaseString instead.") void IRVersionedRootSignatureDescriptorFreeString(const char* serialized); /** - * Deserialized a string representation of a root signature into a root signature object. + * Release a string allocated by IRVersionedRootSignatureDescriptorAllocStringAndSerialize. + * @param serialized string to release. + */ +void IRVersionedRootSignatureDescriptorReleaseString(const char* serialized); + +/** + * Deserialize a string representation of a root signature into a root signature object. * @param serialized a string representation of a root signature. * @param rootSignatureDescriptor root signature object into which to deserialize the root signature. * @return true if deserialization is successful, false otherwise. + * @warning this function may allocate memory, call IRVersionedRootSignatureDescriptorReleaseArrays to deallocate any allocated memory. + * @deprecated use IRVersionedRootSignatureDescriptorCreateFromJSON instead. */ +IR_DEPRECATED("use IRVersionedRootSignatureDescriptorCreateFromJSON instead.") bool IRVersionedRootSignatureDescriptorDeserialize(const char* serialized, IRVersionedRootSignatureDescriptor* rootSignatureDescriptor); +/** + * Deserialize a string representation of a root signature into a root signature object. + * @param serialized a string representation of a root signature. + * @return a newly-allocated root signature object that you need to release, or NULL on error. + */ +IRVersionedRootSignatureDescriptor* IRVersionedRootSignatureDescriptorCreateFromJSON(const char* serialized); + +/** + * Release any arrays allocated by IRVersionedRootSignatureDescriptorDeserialize. + * @param rootSignatureDescriptor root signature descriptor to release. + */ +void IRVersionedRootSignatureDescriptorRelease(IRVersionedRootSignatureDescriptor* rootSignatureDescriptor); + +/** + * Serialize an input layout descriptor version 1 into a string. + * @param inputLayoutDescriptor descriptor to serialize. + * @return a string representation of the input layout descriptor. You need to release this string by calling IRInputLayoutDescriptor1FreeString. + */ +const char* IRInputLayoutDescriptor1CopyJSONString(IRInputLayoutDescriptor1* inputLayoutDescriptor); + +/** + * Release a string allocated by IRInputLayoutDescriptor1CopyJSONString. + * @param serialized string to release. + */ +void IRInputLayoutDescriptor1ReleaseString(const char* serialized); + +/** + * Deserialize a string representation of an input layout descriptor version 1 into an IRInputLayoutDescriptor1 structure. + * @param serialized a string representation of an input layout descriptor version 1. + * @return a newly-allocated input layout descriptor version 1 object that you need to release by calling IRInputLayoutDescriptor1Release, + * NULL if an error occurs. + */ +IRInputLayoutDescriptor1* IRInputLayoutDescriptor1CreateFromJSON(const char* serialized); + +/** + * Release an IRInputDescriptor1 instance allocated by IRInputLayoutDescriptor1CreateFromJSON. + * @param inputLayoutDescriptor input layout descriptor to release. + */ +void IRInputLayoutDescriptor1Release(IRInputLayoutDescriptor1* inputLayoutDescriptor); + #ifdef __cplusplus } #endif diff --git a/bindings_generator/vendor/metal_irconverter_runtime/LICENSE.txt b/bindings_generator/vendor/metal_irconverter_runtime/LICENSE.txt index 6c877ff..97849a6 100644 --- a/bindings_generator/vendor/metal_irconverter_runtime/LICENSE.txt +++ b/bindings_generator/vendor/metal_irconverter_runtime/LICENSE.txt @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright © 2023 Apple Inc. + Copyright © 2023-2024 Apple Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter_runtime/ir_raytracing.h b/bindings_generator/vendor/metal_irconverter_runtime/ir_raytracing.h index f855092..3c70da7 100644 --- a/bindings_generator/vendor/metal_irconverter_runtime/ir_raytracing.h +++ b/bindings_generator/vendor/metal_irconverter_runtime/ir_raytracing.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter_runtime/ir_tessellator_tables.h b/bindings_generator/vendor/metal_irconverter_runtime/ir_tessellator_tables.h index d82b4fc..869c31e 100644 --- a/bindings_generator/vendor/metal_irconverter_runtime/ir_tessellator_tables.h +++ b/bindings_generator/vendor/metal_irconverter_runtime/ir_tessellator_tables.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/bindings_generator/vendor/metal_irconverter_runtime/metal_irconverter_runtime.h b/bindings_generator/vendor/metal_irconverter_runtime/metal_irconverter_runtime.h index ec35832..c4a33c6 100644 --- a/bindings_generator/vendor/metal_irconverter_runtime/metal_irconverter_runtime.h +++ b/bindings_generator/vendor/metal_irconverter_runtime/metal_irconverter_runtime.h @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------------- // -// Copyright 2023 Apple Inc. +// Copyright 2023-2024 Apple Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -240,7 +240,7 @@ typedef struct IRRuntimeDrawParams typedef struct IRRuntimeDrawInfo { // Vertex pipelines only require the index type. - uint16_t indexType; + uint16_t indexType; // set to kIRNonIndexedDraw to indicate a non-indexed draw call // Required by all mesh shader-based pipelines. uint8_t primitiveTopology; @@ -278,16 +278,17 @@ void IRRuntimeCreateAppendBufferView(device_t device, /** * Obtain the count of an append/consume buffer. + * @note the backing MTLBuffer needs to have MTLStorageModeShared storage mode. * @param bufferView buffer view representing the append/consume buffer for which to retrieve the counter. * @return the current count of the append/consume buffer. This function doesn't cause a GPU-CPU sync. */ -uint32_t IRRuntimeGetAppendBufferCount(IRBufferView* bufferView); +uint32_t IRRuntimeGetAppendBufferCount(const IRBufferView* bufferView); /** - * Produce metadata from a buffer view description. + * Obtain encoded metadata from a buffer view description. * @param view the view description to encode into the produced metadata. **/ -uint64_t IRDescriptorTableGetBufferMetadata(IRBufferView* view); +uint64_t IRDescriptorTableGetBufferMetadata(const IRBufferView* view); /** * Encode a buffer into the argument buffer. @@ -303,7 +304,7 @@ void IRDescriptorTableSetBuffer(IRDescriptorTableEntry* entry, uint64_t gpu_va, * @param entry the pointer to the descriptor table entry to encode the buffer reference into. * @param bufferView the buffer view description. **/ -void IRDescriptorTableSetBufferView(IRDescriptorTableEntry* entry, IRBufferView* bufferView); +void IRDescriptorTableSetBufferView(IRDescriptorTableEntry* entry, const IRBufferView* bufferView); /** * Encode a texture into the argument buffer. @@ -411,6 +412,7 @@ void IRRuntimeDrawIndexedPrimitives(renderencoder_t enc, primitivetype_t primiti void IRRuntimeDrawIndexedPrimitives(renderencoder_t enc, primitivetype_t primitiveType, indextype_t indexType, buffer_t indexBuffer, uint64_t indexBufferOffset, buffer_t indirectBuffer, uint64_t indirectBufferOffset ) IR_OVERLOADABLE; /** + * Draw indexed primitives using an emulated geometry pipeline. * You need to bind your vertex arrays and strides before issuing this call. * Bind a buffer with IRRuntimeVertexBuffers at index 0 for the object stage, * You need to manually flag residency for all referenced vertex buffers and for the index buffer. @@ -427,6 +429,21 @@ void IRRuntimeDrawIndexedPrimitivesGeometryEmulation(renderencoder_t enc, uint32_t baseInstance); /** + * Draw non-indexed primitives using an emulated geometry pipeline. + * You need to bind your vertex arrays and strides before issuing this call. + * Bind a buffer with IRRuntimeVertexBuffers at index 0 for the object stage, + * You need to manually flag residency for all referenced vertex buffers. + */ +void IRRuntimeDrawPrimitivesGeometryEmulation(renderencoder_t enc, + IRRuntimePrimitiveType primitiveType, + IRRuntimeGeometryPipelineConfig geometryPipelineConfig, + uint32_t instanceCount, + uint32_t vertexCountPerInstance, + uint32_t baseVertex, + uint32_t baseInstance); + +/** + * * Draw indexed primitives using an emulated geometry/tessellation pipeline. * You need to bind your vertex arrays and strides before issuing this call. * Bind a buffer with IRRuntimeVertexBuffers at index 0 for the object stage, * You need to manually flag residency for all referenced vertex buffers and for the index buffer. @@ -442,6 +459,20 @@ void IRRuntimeDrawIndexedPatchesTessellationEmulation(renderencoder_t enc, int32_t baseVertex, uint32_t startIndex); +/** + * Draw non-indexed primitives using an emulated geometry/tessellation pipeline. + * You need to bind your vertex arrays and strides before issuing this call. + * Bind a buffer with IRRuntimeVertexBuffers at index 0 for the object stage, + * You need to manually flag residency for all referenced vertex buffers. + */ +void IRRuntimeDrawPatchesTessellationEmulation(renderencoder_t enc, + IRRuntimePrimitiveType primitiveTopology, + IRRuntimeTessellationPipelineConfig tessellationPipelineConfig, + uint32_t instanceCount, + uint32_t vertexCountPerInstance, + uint32_t baseInstance, + uint32_t baseVertex); + /** * Validate that the hull domain and tessellation stages are compatible from their reflection data. * @param hsTessellatorOutputPrimitive the tessellator's output primitive which needs to match the geometry stage's input primitive. You can cast this parameter from IRTessellatorOutputPrimitive. @@ -476,6 +507,9 @@ renderpipelinestate_t IRRuntimeNewGeometryEmulationPipeline(device_t device, /** * Create a new mesh pipeline suitable for emulating a render pipeline with a hull stage, a domain stage, and a geometry stage. + * @note You may optionally not provide a geometry shader as part of your tessellation pipeline by setting the decriptor parameter's + * geometryLibrary member to NULL, and providing a geometryFunctionName of kIRTrianglePassthroughGeometryShader, kIRLinePassthroughGeometryShader, + * or kIRPointPassthroughGeometryShader, depending on the primitive topology of draw calls that use the pipeline. * @param device the device to use for creating the new pipeline. * @param descriptor an object describing the origin libraries and function names to create the pipeline. * @param error an output error object containing details about any error encountered during the creation process. @@ -485,23 +519,33 @@ renderpipelinestate_t IRRuntimeNewGeometryTessellationEmulationPipeline(device_t const IRGeometryTessellationEmulationPipelineDescriptor* descriptor, nserror_t* error) API_AVAILABLE(macosx(14), ios(17)); -static const uint64_t kIRArgumentBufferBindPoint = 2; -static const uint64_t kIRArgumentBufferHullDomainBindPoint = 3; -static const uint64_t kIRDescriptorHeapBindPoint = 0; -static const uint64_t kIRSamplerHeapBindPoint = 1; -static const uint64_t kIRArgumentBufferDrawArgumentsBindPoint = 4; -static const uint64_t kIRArgumentBufferUniformsBindPoint = 5; -static const uint64_t kIRVertexBufferBindPoint = 6; -static const uint64_t kIRStageInAttributeStartIndex = 11; -static const char* kIRIndirectTriangleIntersectionFunctionName = "irconverter.wrapper.intersection.function.triangle"; -static const char* kIRIndirectProceduralIntersectionFunctionName = "irconverter.wrapper.intersection.function.procedural"; +const uint64_t kIRArgumentBufferBindPoint = 2; +const uint64_t kIRArgumentBufferHullDomainBindPoint = 3; +const uint64_t kIRDescriptorHeapBindPoint = 0; +const uint64_t kIRSamplerHeapBindPoint = 1; +const uint64_t kIRArgumentBufferDrawArgumentsBindPoint = 4; +const uint64_t kIRArgumentBufferUniformsBindPoint = 5; +const uint64_t kIRVertexBufferBindPoint = 6; +const uint64_t kIRStageInAttributeStartIndex = 11; + +const char* kIRIndirectTriangleIntersectionFunctionName = "irconverter.wrapper.intersection.function.triangle"; +const char* kIRIndirectProceduralIntersectionFunctionName = "irconverter.wrapper.intersection.function.procedural"; + +const char* kIRTrianglePassthroughGeometryShader = "irconverter_domain_shader_triangle_passthrough"; +const char* kIRLinePassthroughGeometryShader = "irconverter_domain_shader_line_passthrough"; +const char* kIRPointPassthroughGeometryShader = "irconverter_domain_shader_point_passthrough"; +const uint16_t kIRNonIndexedDraw = 0; -static const uint64_t kIRBufSizeOffset = 0; -static const uint64_t kIRBufSizeMask = 0xffffffff; -static const uint64_t kIRTexViewOffset = 32; -static const uint64_t kIRTexViewMask = 0xff; -static const uint64_t kIRTypedBufferOffset = 63; +const char* kIRFunctionGroupRayGeneration = "rayGen"; +const char* kIRFunctionGroupClosestHit = "closestHit"; +const char* kIRFunctionGroupMiss = "miss"; + +const uint64_t kIRBufSizeOffset = 0; +const uint64_t kIRBufSizeMask = 0xffffffff; +const uint64_t kIRTexViewOffset = 32; +const uint64_t kIRTexViewMask = 0xff; +const uint64_t kIRTypedBufferOffset = 63; #ifdef IR_PRIVATE_IMPLEMENTATION @@ -573,7 +617,7 @@ void IRRuntimeCreateAppendBufferView(device_t device, buffer_t appendBuffer, uin } IR_INLINE -uint32_t IRRuntimeGetAppendBufferCount(IRBufferView* bufferView) +uint32_t IRRuntimeGetAppendBufferCount(const IRBufferView* bufferView) { uint64_t bufferOffset = bufferView->textureViewOffsetInElements * 4; #ifdef IR_RUNTIME_METALCPP @@ -586,7 +630,7 @@ uint32_t IRRuntimeGetAppendBufferCount(IRBufferView* bufferView) IR_INLINE -uint64_t IRDescriptorTableGetBufferMetadata(IRBufferView* view) +uint64_t IRDescriptorTableGetBufferMetadata(const IRBufferView* view) { uint64_t md = (view->bufferSize & kIRBufSizeMask) << kIRBufSizeOffset; @@ -606,7 +650,7 @@ void IRDescriptorTableSetBuffer(IRDescriptorTableEntry* entry, uint64_t gpu_va, } IR_INLINE -void IRDescriptorTableSetBufferView(IRDescriptorTableEntry* entry, IRBufferView* bufferView) +void IRDescriptorTableSetBufferView(IRDescriptorTableEntry* entry, const IRBufferView* bufferView) { #ifdef IR_RUNTIME_METALCPP entry->gpuVA = bufferView->buffer->gpuAddress() + bufferView->bufferOffset; @@ -646,20 +690,25 @@ void IRDescriptorTableSetSampler(IRDescriptorTableEntry* entry, sampler_t argume entry->metadata = encodedLodBias; } +static IR_INLINE +uint16_t IRMetalIndexToIRIndex(indextype_t indexType) +{ + return (uint16_t)(indexType+1); +} + IR_INLINE void IRRuntimeDrawPrimitives(renderencoder_t enc, primitivetype_t primitiveType, uint64_t vertexStart, uint64_t vertexCount, uint64_t instanceCount, uint64_t baseInstance) IR_OVERLOADABLE { IRRuntimeDrawArgument da = { (uint32_t)vertexCount, (uint32_t)instanceCount, (uint32_t)vertexStart, (uint32_t)baseInstance }; IRRuntimeDrawParams dp = { .draw = da }; - IRRuntimeDrawInfo di = { 0, (uint8_t)primitiveType, 0, 0, 0 }; #ifdef IR_RUNTIME_METALCPP enc->setVertexBytes( &dp, sizeof( IRRuntimeDrawParams ), kIRArgumentBufferDrawArgumentsBindPoint ); - enc->setVertexBytes( &di, sizeof( IRRuntimeDrawInfo ), kIRArgumentBufferUniformsBindPoint ); + enc->setVertexBytes( &kIRNonIndexedDraw, sizeof( uint16_t ), kIRArgumentBufferUniformsBindPoint ); enc->drawPrimitives( primitiveType, vertexStart, vertexCount, instanceCount, baseInstance ); #else [enc setVertexBytes:&dp length:sizeof( IRRuntimeDrawParams ) atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; - [enc setVertexBytes:&di length:sizeof( IRRuntimeDrawInfo ) atIndex:kIRArgumentBufferUniformsBindPoint]; + [enc setVertexBytes:&kIRNonIndexedDraw length:sizeof( uint16_t ) atIndex:kIRArgumentBufferUniformsBindPoint]; [enc drawPrimitives:primitiveType vertexStart:vertexStart vertexCount:vertexCount instanceCount:instanceCount baseInstance:baseInstance]; #endif } @@ -681,9 +730,11 @@ void IRRuntimeDrawPrimitives(renderencoder_t enc, primitivetype_t primitiveType, { #ifdef IR_RUNTIME_METALCPP enc->setVertexBuffer( indirectBuffer, indirectBufferOffset, kIRArgumentBufferDrawArgumentsBindPoint ); + enc->setVertexBytes( &kIRNonIndexedDraw, sizeof( uint16_t ), kIRArgumentBufferUniformsBindPoint ); enc->drawPrimitives( primitiveType, indirectBuffer, indirectBufferOffset ); #else [enc setVertexBuffer:indirectBuffer offset:indirectBufferOffset atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; + [enc setVertexBytes:&kIRNonIndexedDraw length:sizeof( uint16_t ) atIndex:kIRArgumentBufferUniformsBindPoint]; [enc drawPrimitives:primitiveType indirectBuffer:indirectBuffer indirectBufferOffset:indirectBufferOffset]; #endif } @@ -700,15 +751,15 @@ void IRRuntimeDrawIndexedPrimitives(renderencoder_t enc, primitivetype_t primiti }; IRRuntimeDrawParams dp = { .drawIndexed = da }; - IRRuntimeDrawInfo di = { .indexType = (uint8_t)(indexType+1), .primitiveTopology = (uint8_t)primitiveType }; + const uint16_t IRIndexType = IRMetalIndexToIRIndex(indexType); #ifdef IR_RUNTIME_METALCPP enc->setVertexBytes( &dp, sizeof( IRRuntimeDrawParams ), kIRArgumentBufferDrawArgumentsBindPoint ); - enc->setVertexBytes( &di, sizeof( IRRuntimeDrawInfo ), kIRArgumentBufferUniformsBindPoint ); + enc->setVertexBytes( &IRIndexType, sizeof( uint16_t ), kIRArgumentBufferUniformsBindPoint ); enc->drawIndexedPrimitives( primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance ); #else [enc setVertexBytes:&dp length:sizeof( IRRuntimeDrawParams ) atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; - [enc setVertexBytes:&di length:sizeof( IRRuntimeDrawInfo ) atIndex:kIRArgumentBufferUniformsBindPoint]; + [enc setVertexBytes:&IRIndexType length:sizeof( uint16_t ) atIndex:kIRArgumentBufferUniformsBindPoint]; [enc drawIndexedPrimitives:primitiveType indexCount:indexCount indexType:indexType indexBuffer:indexBuffer indexBufferOffset:indexBufferOffset instanceCount:instanceCount baseVertex:baseVertex baseInstance:baseInstance]; #endif } @@ -728,11 +779,15 @@ void IRRuntimeDrawIndexedPrimitives(renderencoder_t enc, primitivetype_t primiti IR_INLINE void IRRuntimeDrawIndexedPrimitives(renderencoder_t enc, primitivetype_t primitiveType, indextype_t indexType, buffer_t indexBuffer, uint64_t indexBufferOffset, buffer_t indirectBuffer, uint64_t indirectBufferOffset ) IR_OVERLOADABLE { + const uint16_t IRIndexType = IRMetalIndexToIRIndex(indexType); + #ifdef IR_RUNTIME_METALCPP enc->setVertexBuffer( indirectBuffer, indirectBufferOffset, kIRArgumentBufferDrawArgumentsBindPoint ); + enc->setVertexBytes( &IRIndexType, sizeof( uint16_t ), kIRArgumentBufferUniformsBindPoint ); enc->drawIndexedPrimitives( primitiveType, indexType, indexBuffer, indexBufferOffset, indirectBuffer, indirectBufferOffset ); #else [enc setVertexBuffer:indirectBuffer offset:indirectBufferOffset atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; + [enc setVertexBytes:&IRIndexType length:sizeof( uint16_t ) atIndex:kIRArgumentBufferUniformsBindPoint]; [enc drawIndexedPrimitives:primitiveType indexType:indexType indexBuffer:indexBuffer indexBufferOffset:indexBufferOffset indirectBuffer:indirectBuffer indirectBufferOffset:indirectBufferOffset]; #endif } @@ -771,23 +826,6 @@ static uint32_t IRRuntimePrimitiveTypeVertexOverlap(IRRuntimePrimitiveType primi return 0; } -IR_INLINE -static uint32_t DXAIRPrimitiveTypeToPrimitiveTopology(IRRuntimePrimitiveType primitiveType) -{ - switch (primitiveType) - { - case IRRuntimePrimitiveTypePoint: return 1; - case IRRuntimePrimitiveTypeLine: return 2; - case IRRuntimePrimitiveTypeLineStrip: return 3; - case IRRuntimePrimitiveTypeTriangle: return 4; - case IRRuntimePrimitiveTypeTriangleStrip: return 5; - case IRRuntimePrimitiveTypeLineWithAdj: return 10; - case IRRuntimePrimitiveTypeTriangleWithAdj: return 12; - default: return 0; - } - return 0; -} - IR_INLINE static IRRuntimeDrawInfo IRRuntimeCalculateDrawInfoForGSEmulation(IRRuntimePrimitiveType primitiveType, indextype_t indexType, uint32_t vertexSizeInBytes, uint32_t maxInputPrimitivesPerMeshThreadgroup, uint32_t instanceCount) { @@ -895,11 +933,11 @@ void IRRuntimeDrawIndexedPrimitivesGeometryEmulation(renderencoder_t enc, IRRuntimeDrawParams drawParams; drawParams.drawIndexed = (IRRuntimeDrawIndexedArgument){ - .startInstanceLocation = baseInstance, + .indexCountPerInstance = indexCountPerInstance, .instanceCount = instanceCount, - .baseVertexLocation = baseVertex, .startIndexLocation = startIndex, - .indexCountPerInstance = indexCountPerInstance + .baseVertexLocation = baseVertex, + .startInstanceLocation = baseInstance }; @@ -930,6 +968,67 @@ void IRRuntimeDrawIndexedPrimitivesGeometryEmulation(renderencoder_t enc, #endif } + +IR_INLINE +void IRRuntimeDrawPrimitivesGeometryEmulation(renderencoder_t enc, + IRRuntimePrimitiveType primitiveType, + IRRuntimeGeometryPipelineConfig geometryPipelineConfig, + uint32_t instanceCount, + uint32_t vertexCountPerInstance, + uint32_t baseVertex, + uint32_t baseInstance) +{ + IRRuntimeDrawInfo drawInfo = IRRuntimeCalculateDrawInfoForGSEmulation(primitiveType, + (indextype_t)-1, + geometryPipelineConfig.gsVertexSizeInBytes, + geometryPipelineConfig.gsMaxInputPrimitivesPerMeshThreadgroup, + instanceCount); + drawInfo.indexType = kIRNonIndexedDraw; + + mtlsize_t objectThreadgroupCount = IRRuntimeCalculateObjectTgCountForTessellationAndGeometryEmulation(vertexCountPerInstance, + drawInfo.objectThreadgroupVertexStride, + primitiveType, + instanceCount); + + uint32_t objectThreadgroupSize,meshThreadgroupSize; + IRRuntimeCalculateThreadgroupSizeForGeometry(primitiveType, + geometryPipelineConfig.gsMaxInputPrimitivesPerMeshThreadgroup, + drawInfo.objectThreadgroupVertexStride, + &objectThreadgroupSize, + &meshThreadgroupSize); + + IRRuntimeDrawParams drawParams; + drawParams.draw = (IRRuntimeDrawArgument){ + .vertexCountPerInstance = vertexCountPerInstance, + .instanceCount = instanceCount, + .startVertexLocation = baseVertex, + .startInstanceLocation = baseInstance + }; + + + #ifdef IR_RUNTIME_METALCPP + + enc->setObjectBytes(&drawInfo, sizeof(IRRuntimeDrawInfo), kIRArgumentBufferUniformsBindPoint); + enc->setMeshBytes(&drawInfo, sizeof(IRRuntimeDrawInfo), kIRArgumentBufferUniformsBindPoint); + enc->setObjectBytes(&drawParams, sizeof(IRRuntimeDrawParams), kIRArgumentBufferDrawArgumentsBindPoint); + enc->setMeshBytes(&drawParams, sizeof(IRRuntimeDrawParams), kIRArgumentBufferDrawArgumentsBindPoint); + + enc->drawMeshThreadgroups(objectThreadgroupCount, MTL::Size::Make(objectThreadgroupSize, 1, 1), MTL::Size::Make(meshThreadgroupSize, 1, 1)); + + #else + + [enc setObjectBytes:&drawInfo length:sizeof(IRRuntimeDrawInfo) atIndex:kIRArgumentBufferUniformsBindPoint]; + [enc setMeshBytes:&drawInfo length:sizeof(IRRuntimeDrawInfo) atIndex:kIRArgumentBufferUniformsBindPoint]; + [enc setObjectBytes:&drawParams length:sizeof(IRRuntimeDrawParams) atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; + [enc setMeshBytes:&drawParams length:sizeof(IRRuntimeDrawParams) atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; + + [enc drawMeshThreadgroups:objectThreadgroupCount + threadsPerObjectThreadgroup:MTLSizeMake(objectThreadgroupSize, 1, 1) + threadsPerMeshThreadgroup:MTLSizeMake(meshThreadgroupSize, 1, 1)]; + + #endif +} + IR_INLINE static uint16_t IRTessellatorThreadgroupVertexOverlap(IRRuntimeTessellatorOutputPrimitive tessellatorOutputPrimitive) { @@ -1009,11 +1108,11 @@ void IRRuntimeDrawIndexedPatchesTessellationEmulation(renderencoder_t enc, IRRuntimeDrawParams drawParams; drawParams.drawIndexed = (IRRuntimeDrawIndexedArgument){ - .startInstanceLocation = baseInstance, + .indexCountPerInstance = indexCountPerInstance, .instanceCount = instanceCount, - .baseVertexLocation = baseVertex, .startIndexLocation = startIndex, - .indexCountPerInstance = indexCountPerInstance + .baseVertexLocation = baseVertex, + .startInstanceLocation = baseInstance }; uint32_t threadgroupMem = 16; @@ -1057,6 +1156,87 @@ void IRRuntimeDrawIndexedPatchesTessellationEmulation(renderencoder_t enc, #endif // IR_RUNTIME_METALCPP } +IR_INLINE +void IRRuntimeDrawPatchesTessellationEmulation(renderencoder_t enc, + IRRuntimePrimitiveType primitiveTopology, + IRRuntimeTessellationPipelineConfig tessellationPipelineConfig, + uint32_t instanceCount, + uint32_t vertexCountPerInstance, + uint32_t baseInstance, + uint32_t baseVertex) +{ + IRRuntimeDrawInfo drawInfo = IRRuntimeCalculateDrawInfoForGSTSEmulation( + /* primitiveType */ primitiveTopology, + /* indexType */ (indextype_t)-1, + /* tessellatorOutputPrimitive */ tessellationPipelineConfig.outputPrimitiveType, + /* gsMaxInputPrimitivesPerMeshThreadgroup */ tessellationPipelineConfig.gsMaxInputPrimitivesPerMeshThreadgroup, + /* hsPatchesPerObjectThreadgroup */ tessellationPipelineConfig.hsMaxPatchesPerObjectThreadgroup, + /* hsInputControlPointsPerPatch */ tessellationPipelineConfig.hsInputControlPointCount, + /* hsObjectThreadsPerPatch */ tessellationPipelineConfig.hsMaxObjectThreadsPerThreadgroup, + /* gsInstanceCount */ tessellationPipelineConfig.gsInstanceCount); + drawInfo.indexType = kIRNonIndexedDraw; + + + mtlsize_t objectThreadgroupCount = IRRuntimeCalculateObjectTgCountForTessellationAndGeometryEmulation(vertexCountPerInstance, + drawInfo.objectThreadgroupVertexStride, + primitiveTopology, + instanceCount); + + uint32_t objectThreadgroupSize, meshThreadgroupSize; + IRRuntimeCalculateThreadgroupSizeForTessellationAndGeometry(tessellationPipelineConfig.hsMaxPatchesPerObjectThreadgroup, + tessellationPipelineConfig.hsMaxObjectThreadsPerThreadgroup, + tessellationPipelineConfig.gsMaxInputPrimitivesPerMeshThreadgroup, + &objectThreadgroupSize, + &meshThreadgroupSize); + + + IRRuntimeDrawParams drawParams; + drawParams.draw = (IRRuntimeDrawArgument){ + .vertexCountPerInstance = vertexCountPerInstance, + .instanceCount = instanceCount, + .startVertexLocation = baseVertex, + .startInstanceLocation = baseInstance + + }; + + uint32_t threadgroupMem = 16; + uint32_t prefixSumMem = 16; + + threadgroupMem = tessellationPipelineConfig.vsOutputSizeInBytes * + tessellationPipelineConfig.hsInputControlPointCount * + tessellationPipelineConfig.hsMaxPatchesPerObjectThreadgroup; + + prefixSumMem = 15360 - (32 * 4); + +#ifdef IR_RUNTIME_METALCPP + + enc->setObjectBytes(&drawInfo, sizeof(IRRuntimeDrawInfo), kIRArgumentBufferUniformsBindPoint); + enc->setMeshBytes(&drawInfo, sizeof(IRRuntimeDrawInfo), kIRArgumentBufferUniformsBindPoint); + enc->setObjectBytes(&drawParams, sizeof(IRRuntimeDrawParams), kIRArgumentBufferDrawArgumentsBindPoint); + enc->setMeshBytes(&drawParams, sizeof(IRRuntimeDrawParams), kIRArgumentBufferDrawArgumentsBindPoint); + + enc->setObjectThreadgroupMemoryLength(threadgroupMem, 0); + enc->setObjectThreadgroupMemoryLength(prefixSumMem, 1); + + enc->drawMeshThreadgroups(objectThreadgroupCount, + MTL::Size::Make(objectThreadgroupSize, 1, 1), + MTL::Size::Make(meshThreadgroupSize, 1, 1)); +#else + + [enc setObjectBytes:&drawInfo length:sizeof(IRRuntimeDrawInfo) atIndex:kIRArgumentBufferUniformsBindPoint]; + [enc setMeshBytes:&drawInfo length:sizeof(IRRuntimeDrawInfo) atIndex:kIRArgumentBufferUniformsBindPoint]; + [enc setObjectBytes:&drawParams length:sizeof(IRRuntimeDrawParams) atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; + [enc setMeshBytes:&drawParams length:sizeof(IRRuntimeDrawParams) atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; + + [enc setObjectThreadgroupMemoryLength:threadgroupMem atIndex:0]; + [enc setObjectThreadgroupMemoryLength:prefixSumMem atIndex:1]; + + [enc drawMeshThreadgroups:objectThreadgroupCount + threadsPerObjectThreadgroup:MTLSizeMake(objectThreadgroupSize, 1, 1) + threadsPerMeshThreadgroup:MTLSizeMake(meshThreadgroupSize, 1, 1)]; +#endif // IR_RUNTIME_METALCPP +} + IR_INLINE bool IRRuntimeValidateTessellationPipeline(IRRuntimeTessellatorOutputPrimitive hsTessellatorOutputPrimitive, IRRuntimePrimitiveType gsInputPrimitive, @@ -1365,31 +1545,37 @@ renderpipelinestate_t IRRuntimeNewGeometryTessellationEmulationPipeline(device_t // Geometry function: { - // Not done here: verify the stage is not just passthrough. - // Configure function: - bool enableTessellationEmulation = true; - bool enableStreamOut = false; - - MTL::FunctionConstantValues* pFunctionConstants = MTL::FunctionConstantValues::alloc()->init(); - - pFunctionConstants->setConstantValue(&enableTessellationEmulation, - MTL::DataTypeBool, MTLSTR("tessellationEnabled")); - - pFunctionConstants->setConstantValue(&enableStreamOut, - MTL::DataTypeBool, MTLSTR("streamOutEnabled")); - - pFunctionConstants->setConstantValue(&(descriptor->pipelineConfig.vsOutputSizeInBytes), - MTL::DataTypeInt, MTLSTR("vertex_shader_output_size_fc")); - - MTL::FunctionDescriptor* pFunctionDesc = MTL::FunctionDescriptor::alloc()->init(); - pFunctionDesc->setConstantValues(pFunctionConstants); - pFunctionDesc->setName( NS::String::string(descriptor->geometryFunctionName, NS::UTF8StringEncoding) ); - - pGeometryFn = descriptor->geometryLibrary->newFunction(pFunctionDesc, error); - - pFunctionDesc->release(); - pFunctionConstants->release(); + if (descriptor->geometryLibrary != nullptr) + { + bool enableTessellationEmulation = true; + bool enableStreamOut = false; + + MTL::FunctionConstantValues* pFunctionConstants = MTL::FunctionConstantValues::alloc()->init(); + + pFunctionConstants->setConstantValue(&enableTessellationEmulation, + MTL::DataTypeBool, MTLSTR("tessellationEnabled")); + + pFunctionConstants->setConstantValue(&enableStreamOut, + MTL::DataTypeBool, MTLSTR("streamOutEnabled")); + + pFunctionConstants->setConstantValue(&(descriptor->pipelineConfig.vsOutputSizeInBytes), + MTL::DataTypeInt, MTLSTR("vertex_shader_output_size_fc")); + + MTL::FunctionDescriptor* pFunctionDesc = MTL::FunctionDescriptor::alloc()->init(); + pFunctionDesc->setConstantValues(pFunctionConstants); + pFunctionDesc->setName( NS::String::string(descriptor->geometryFunctionName, NS::UTF8StringEncoding) ); + + pGeometryFn = descriptor->geometryLibrary->newFunction(pFunctionDesc, error); + + pFunctionDesc->release(); + pFunctionConstants->release(); + } + else + { + NS::String* passthroughName = NS::String::string(descriptor->geometryFunctionName, NS::UTF8StringEncoding); + pGeometryFn = descriptor->domainLibrary->newFunction(passthroughName); + } if (!pGeometryFn) { goto exit_geometry_function_error; @@ -1521,8 +1707,7 @@ renderpipelinestate_t IRRuntimeNewGeometryTessellationEmulationPipeline(device_t MTLFunctionDescriptor* pFunctionDesc = [[MTLFunctionDescriptor alloc] init]; [pFunctionDesc setConstantValues:pFunctionConstants]; - - NSString* functionName = [NSString stringWithFormat:@"%s.dxil_irconverter_object_shader", descriptor->vertexFunctionName]; + pFunctionDesc.name = [NSString stringWithFormat:@"%s.dxil_irconverter_object_shader", descriptor->vertexFunctionName]; pVertexFn = [descriptor->vertexLibrary newFunctionWithDescriptor:pFunctionDesc error:error]; @@ -1573,32 +1758,37 @@ renderpipelinestate_t IRRuntimeNewGeometryTessellationEmulationPipeline(device_t // Geometry function: { - // Not done here: verify the stage is not just passthrough. - - // Configure function: - bool enableTessellationEmulation = true; - bool enableStreamOut = false; - - MTLFunctionConstantValues* pFunctionConstants = [[MTLFunctionConstantValues alloc] init]; - - [pFunctionConstants setConstantValue:&enableTessellationEmulation - type:MTLDataTypeBool - withName:@"tessellationEnabled"]; - - [pFunctionConstants setConstantValue:&enableStreamOut - type:MTLDataTypeBool - withName:@"streamOutEnabled"]; - - [pFunctionConstants setConstantValue:&(descriptor->pipelineConfig.vsOutputSizeInBytes) - type:MTLDataTypeInt - withName:@"vertex_shader_output_size_fc"]; - - MTLFunctionDescriptor* pFunctionDesc = [[MTLFunctionDescriptor alloc] init]; - [pFunctionDesc setConstantValues:pFunctionConstants]; - [pFunctionDesc setName:[NSString stringWithUTF8String:descriptor->geometryFunctionName]]; - - pGeometryFn = [descriptor->geometryLibrary newFunctionWithDescriptor:pFunctionDesc error:error]; - + if (descriptor->geometryLibrary != nil) + { + // Configure function: + bool enableTessellationEmulation = true; + bool enableStreamOut = false; + + MTLFunctionConstantValues* pFunctionConstants = [[MTLFunctionConstantValues alloc] init]; + + [pFunctionConstants setConstantValue:&enableTessellationEmulation + type:MTLDataTypeBool + withName:@"tessellationEnabled"]; + + [pFunctionConstants setConstantValue:&enableStreamOut + type:MTLDataTypeBool + withName:@"streamOutEnabled"]; + + [pFunctionConstants setConstantValue:&(descriptor->pipelineConfig.vsOutputSizeInBytes) + type:MTLDataTypeInt + withName:@"vertex_shader_output_size_fc"]; + + MTLFunctionDescriptor* pFunctionDesc = [[MTLFunctionDescriptor alloc] init]; + [pFunctionDesc setConstantValues:pFunctionConstants]; + [pFunctionDesc setName:[NSString stringWithUTF8String:descriptor->geometryFunctionName]]; + + pGeometryFn = [descriptor->geometryLibrary newFunctionWithDescriptor:pFunctionDesc error:error]; + } + else + { + NSString* passthroughName = [NSString stringWithUTF8String:descriptor->geometryFunctionName]; + pGeometryFn = [descriptor->domainLibrary newFunctionWithName:passthroughName]; + } if (!pGeometryFn) { return nil; diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 01e66ed..28623db 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "saxaboom-runtime" -version = "0.1.0+irconverter-1.1" +version = "0.1.0+irconverter-2.0" authors = ["Traverse Research "] edition = "2021" license = "Apache-2.0" diff --git a/runtime/src/bindings.rs b/runtime/src/bindings.rs index 6b4101f..1ff8773 100644 --- a/runtime/src/bindings.rs +++ b/runtime/src/bindings.rs @@ -475,6 +475,16 @@ pub const kIRIndirectTriangleIntersectionFunctionName: &[u8; 51] = b"irconverter.wrapper.intersection.function.triangle\0"; pub const kIRIndirectProceduralIntersectionFunctionName: &[u8; 53] = b"irconverter.wrapper.intersection.function.procedural\0"; +pub const kIRTrianglePassthroughGeometryShader: &[u8; 47] = + b"irconverter_domain_shader_triangle_passthrough\0"; +pub const kIRLinePassthroughGeometryShader: &[u8; 43] = + b"irconverter_domain_shader_line_passthrough\0"; +pub const kIRPointPassthroughGeometryShader: &[u8; 44] = + b"irconverter_domain_shader_point_passthrough\0"; +pub const kIRNonIndexedDraw: u16 = 0; +pub const kIRFunctionGroupRayGeneration: &[u8; 7] = b"rayGen\0"; +pub const kIRFunctionGroupClosestHit: &[u8; 11] = b"closestHit\0"; +pub const kIRFunctionGroupMiss: &[u8; 5] = b"miss\0"; pub const kIRBufSizeOffset: u64 = 0; pub const kIRBufSizeMask: u64 = 4294967295; pub const kIRTexViewOffset: u64 = 32; diff --git a/src/bindings.rs b/src/bindings.rs index 768aec0..e652ec0 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -1,12 +1,12 @@ /* automatically generated by rust-bindgen 0.70.1 */ -pub const IR_VERSION_MAJOR: u32 = 1; -pub const IR_VERSION_MINOR: u32 = 1; -pub const IR_VERSION_PATCH: u32 = 0; +pub const IR_VERSION_MAJOR: u32 = 2; +pub const IR_VERSION_MINOR: u32 = 0; +pub const IR_VERSION_PATCH: u32 = 4; pub const IRDescriptorRangeOffsetAppend: u32 = 4294967295; pub const IRIntrinsicMaskClosestHitAll: u32 = 2147483647; pub const IRIntrinsicMaskMissShaderAll: u32 = 32767; -pub const IRIntrinsicMaskCallableShaderAll: u32 = 32767; +pub const IRIntrinsicMaskCallableShaderAll: u32 = 28735; pub const IRRayTracingUnlimitedRecursionDepth: i32 = -1; #[repr(u32)] #[non_exhaustive] @@ -559,7 +559,6 @@ pub struct IRVertexInputTable { pub NumDescriptorRanges: u32, pub pDescriptorRanges: *const IRDescriptorRange, } -pub type IRVertexInput = IRVertexInputTable; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct IRRootConstants { @@ -634,6 +633,12 @@ impl IRCompatibilityFlags { impl IRCompatibilityFlags { pub const SampleNanToZero: IRCompatibilityFlags = IRCompatibilityFlags(32); } +impl IRCompatibilityFlags { + pub const TexWriteRoundingRTZ: IRCompatibilityFlags = IRCompatibilityFlags(64); +} +impl IRCompatibilityFlags { + pub const Suppress2DComputeDerivativeErrors: IRCompatibilityFlags = IRCompatibilityFlags(128); +} impl ::std::ops::BitOr for IRCompatibilityFlags { type Output = Self; #[inline] @@ -764,8 +769,8 @@ pub struct IRInputElementDescriptor1 { pub format: IRFormat, pub inputSlot: u32, pub alignedByteOffset: u32, - pub inputSlotClass: IRInputClassification, pub instanceDataStepRate: u32, + pub inputSlotClass: IRInputClassification, } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -839,6 +844,13 @@ pub struct IRRaytracingPipelineFlags(pub ::std::os::raw::c_uint); #[repr(u32)] #[non_exhaustive] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum IRRayGenerationCompilationMode { + Kernel = 0, + VisibleFunction = 1, +} +#[repr(u32)] +#[non_exhaustive] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum IRErrorCode { NoError = 0, ShaderRequiresRootSignature = 1, @@ -856,7 +868,8 @@ pub enum IRErrorCode { UnableToLinkModule = 13, UnrecognizedDXILHeader = 14, InvalidRaytracingAttribute = 15, - Unknown = 16, + NullHullShaderInputOutputMismatch = 16, + Unknown = 17, } #[repr(u32)] #[non_exhaustive] @@ -1271,6 +1284,7 @@ pub struct metal_irconverter { anyHit: u64, callableArgs: u64, maxRecursiveDepth: ::std::os::raw::c_int, + rayGenerationCompilationMode: IRRayGenerationCompilationMode, ), pub IRCompilerSetCompatibilityFlags: unsafe extern "C" fn(compiler: *mut IRCompiler, flags: IRCompatibilityFlags), @@ -1297,6 +1311,8 @@ pub struct metal_irconverter { unsafe extern "C" fn(compiler: *mut IRCompiler, family: IRGPUFamily), pub IRCompilerIgnoreRootSignature: unsafe extern "C" fn(compiler: *mut IRCompiler, ignoreEmbeddedRootSignature: bool), + pub IRCompilerIgnoreDebugInformation: + unsafe extern "C" fn(compiler: *mut IRCompiler, ignoreDebugInformation: bool), pub IRCompilerSetMinimumDeploymentTarget: unsafe extern "C" fn( compiler: *mut IRCompiler, operatingSystem: IROperatingSystem, @@ -1407,22 +1423,54 @@ pub struct metal_irconverter { ), pub IRShaderReflectionAllocStringAndSerialize: unsafe extern "C" fn(reflection: *mut IRShaderReflection) -> *const ::std::os::raw::c_char, + pub IRShaderReflectionCopyJSONString: unsafe extern "C" fn( + reflection: *const IRShaderReflection, + ) + -> *const ::std::os::raw::c_char, pub IRShaderReflectionFreeString: unsafe extern "C" fn(serialized: *const ::std::os::raw::c_char), + pub IRShaderReflectionReleaseString: + unsafe extern "C" fn(serialized: *const ::std::os::raw::c_char), pub IRShaderReflectionDeserialize: unsafe extern "C" fn( blob: *const ::std::os::raw::c_char, reflection: *mut IRShaderReflection, ), + pub IRShaderReflectionCreateFromJSON: + unsafe extern "C" fn(json: *const ::std::os::raw::c_char) -> *mut IRShaderReflection, pub IRVersionedRootSignatureDescriptorAllocStringAndSerialize: unsafe extern "C" fn( rootSignatureDescriptor: *mut IRVersionedRootSignatureDescriptor, ) -> *const ::std::os::raw::c_char, + pub IRVersionedRootSignatureDescriptorCopyJSONString: + unsafe extern "C" fn( + rootSignatureDescriptor: *mut IRVersionedRootSignatureDescriptor, + ) -> *const ::std::os::raw::c_char, pub IRVersionedRootSignatureDescriptorFreeString: unsafe extern "C" fn(serialized: *const ::std::os::raw::c_char), + pub IRVersionedRootSignatureDescriptorReleaseString: + unsafe extern "C" fn(serialized: *const ::std::os::raw::c_char), pub IRVersionedRootSignatureDescriptorDeserialize: unsafe extern "C" fn( serialized: *const ::std::os::raw::c_char, rootSignatureDescriptor: *mut IRVersionedRootSignatureDescriptor, ) -> bool, + pub IRVersionedRootSignatureDescriptorCreateFromJSON: + unsafe extern "C" fn( + serialized: *const ::std::os::raw::c_char, + ) -> *mut IRVersionedRootSignatureDescriptor, + pub IRVersionedRootSignatureDescriptorRelease: + unsafe extern "C" fn(rootSignatureDescriptor: *mut IRVersionedRootSignatureDescriptor), + pub IRInputLayoutDescriptor1CopyJSONString: + unsafe extern "C" fn( + inputLayoutDescriptor: *mut IRInputLayoutDescriptor1, + ) -> *const ::std::os::raw::c_char, + pub IRInputLayoutDescriptor1ReleaseString: + unsafe extern "C" fn(serialized: *const ::std::os::raw::c_char), + pub IRInputLayoutDescriptor1CreateFromJSON: + unsafe extern "C" fn( + serialized: *const ::std::os::raw::c_char, + ) -> *mut IRInputLayoutDescriptor1, + pub IRInputLayoutDescriptor1Release: + unsafe extern "C" fn(inputLayoutDescriptor: *mut IRInputLayoutDescriptor1), } impl metal_irconverter { pub unsafe fn new

(path: P) -> Result @@ -1517,6 +1565,9 @@ impl metal_irconverter { let IRCompilerIgnoreRootSignature = __library .get(b"IRCompilerIgnoreRootSignature\0") .map(|sym| *sym)?; + let IRCompilerIgnoreDebugInformation = __library + .get(b"IRCompilerIgnoreDebugInformation\0") + .map(|sym| *sym)?; let IRCompilerSetMinimumDeploymentTarget = __library .get(b"IRCompilerSetMinimumDeploymentTarget\0") .map(|sym| *sym)?; @@ -1619,21 +1670,54 @@ impl metal_irconverter { let IRShaderReflectionAllocStringAndSerialize = __library .get(b"IRShaderReflectionAllocStringAndSerialize\0") .map(|sym| *sym)?; + let IRShaderReflectionCopyJSONString = __library + .get(b"IRShaderReflectionCopyJSONString\0") + .map(|sym| *sym)?; let IRShaderReflectionFreeString = __library .get(b"IRShaderReflectionFreeString\0") .map(|sym| *sym)?; + let IRShaderReflectionReleaseString = __library + .get(b"IRShaderReflectionReleaseString\0") + .map(|sym| *sym)?; let IRShaderReflectionDeserialize = __library .get(b"IRShaderReflectionDeserialize\0") .map(|sym| *sym)?; + let IRShaderReflectionCreateFromJSON = __library + .get(b"IRShaderReflectionCreateFromJSON\0") + .map(|sym| *sym)?; let IRVersionedRootSignatureDescriptorAllocStringAndSerialize = __library .get(b"IRVersionedRootSignatureDescriptorAllocStringAndSerialize\0") .map(|sym| *sym)?; + let IRVersionedRootSignatureDescriptorCopyJSONString = __library + .get(b"IRVersionedRootSignatureDescriptorCopyJSONString\0") + .map(|sym| *sym)?; let IRVersionedRootSignatureDescriptorFreeString = __library .get(b"IRVersionedRootSignatureDescriptorFreeString\0") .map(|sym| *sym)?; + let IRVersionedRootSignatureDescriptorReleaseString = __library + .get(b"IRVersionedRootSignatureDescriptorReleaseString\0") + .map(|sym| *sym)?; let IRVersionedRootSignatureDescriptorDeserialize = __library .get(b"IRVersionedRootSignatureDescriptorDeserialize\0") .map(|sym| *sym)?; + let IRVersionedRootSignatureDescriptorCreateFromJSON = __library + .get(b"IRVersionedRootSignatureDescriptorCreateFromJSON\0") + .map(|sym| *sym)?; + let IRVersionedRootSignatureDescriptorRelease = __library + .get(b"IRVersionedRootSignatureDescriptorRelease\0") + .map(|sym| *sym)?; + let IRInputLayoutDescriptor1CopyJSONString = __library + .get(b"IRInputLayoutDescriptor1CopyJSONString\0") + .map(|sym| *sym)?; + let IRInputLayoutDescriptor1ReleaseString = __library + .get(b"IRInputLayoutDescriptor1ReleaseString\0") + .map(|sym| *sym)?; + let IRInputLayoutDescriptor1CreateFromJSON = __library + .get(b"IRInputLayoutDescriptor1CreateFromJSON\0") + .map(|sym| *sym)?; + let IRInputLayoutDescriptor1Release = __library + .get(b"IRInputLayoutDescriptor1Release\0") + .map(|sym| *sym)?; Ok(metal_irconverter { __library, IRErrorGetCode, @@ -1670,6 +1754,7 @@ impl metal_irconverter { IRCompilerSetEntryPointName, IRCompilerSetMinimumGPUFamily, IRCompilerIgnoreRootSignature, + IRCompilerIgnoreDebugInformation, IRCompilerSetMinimumDeploymentTarget, IRMetalLibBinaryCreate, IRMetalLibBinaryDestroy, @@ -1706,11 +1791,22 @@ impl metal_irconverter { IRRootSignatureGetResourceCount, IRRootSignatureGetResourceLocations, IRShaderReflectionAllocStringAndSerialize, + IRShaderReflectionCopyJSONString, IRShaderReflectionFreeString, + IRShaderReflectionReleaseString, IRShaderReflectionDeserialize, + IRShaderReflectionCreateFromJSON, IRVersionedRootSignatureDescriptorAllocStringAndSerialize, + IRVersionedRootSignatureDescriptorCopyJSONString, IRVersionedRootSignatureDescriptorFreeString, + IRVersionedRootSignatureDescriptorReleaseString, IRVersionedRootSignatureDescriptorDeserialize, + IRVersionedRootSignatureDescriptorCreateFromJSON, + IRVersionedRootSignatureDescriptorRelease, + IRInputLayoutDescriptor1CopyJSONString, + IRInputLayoutDescriptor1ReleaseString, + IRInputLayoutDescriptor1CreateFromJSON, + IRInputLayoutDescriptor1Release, }) } #[doc = " Obtain the error code of an error.\n @param error error object to query.\n @return error code."] @@ -1774,7 +1870,7 @@ impl metal_irconverter { pub unsafe fn IRCompilerDestroy(&self, compiler: *mut IRCompiler) { (self.IRCompilerDestroy)(compiler) } - #[doc = " Allocate a new object and populate it with the results of compiling and linking IR bytecode.\n @note Prior calls to `IRCompilerSetHitgroupType`, `IRCompilerSetRayTracingPipelineArguments`, `IRCompilerSetGlobalRootSignature`, `IRCompilerSetLocalRootSignature` influence the bytecode this function produces.\n @note you need to call `IRCompilerSetRayTracingPipelineArguments` before compiling ray tracing shaders.\n @param compiler compiler to use for the translation process.\n @param entryPointName optional entry point name to compile when converting a library with multiple entry points.\n @param input input IR object.\n @param error on return, if the compiler generates any errors, this optional out parameter contains error information. If an error occurs and this parameter is non-NULL, you must free it by calling IRErrorDestroy.\n @return an IR Object containing MetalIR compiled from the input IR, or NULL if an error occurs. You must destroy this object by calling IRObjectDestroy."] + #[doc = " Allocate a new object and populate it with the results of compiling and linking IR bytecode.\n @note Prior calls to `IRCompilerSetHitgroupType`, `IRCompilerSetRayTracingPipelineArguments`, `IRCompilerSetGlobalRootSignature`, `IRCompilerSetLocalRootSignature` influence the bytecode this function produces.\n @note you need to call `IRCompilerSetRayTracingPipelineArguments` before compiling ray tracing shaders.\n @param compiler compiler to use for the translation process.\n @param entryPointName optional entry point name to compile when converting a library with multiple entry points.\n @param input input IR object.\n @param error on return, if the compiler generates any errors, this optional out parameter contains error information. If an error occurs and this parameter is non-NULL, you must free it by calling IRErrorDestroy.\n @return an IR Object containing MetalIR compiled and linked from the input IR, or NULL if an error occurs. You must destroy this object by calling IRObjectDestroy."] pub unsafe fn IRCompilerAllocCompileAndLink( &self, compiler: *mut IRCompiler, @@ -1871,7 +1967,7 @@ impl metal_irconverter { ) -> u64 { (self.IRObjectGatherRaytracingIntrinsics)(input, entryPoint) } - #[doc = " Configure a compiler with upfront information to generate an optimal interface between ray tracing functions.\n Calling this function is optional, but when omitted, the compiler needs to assume a worst-case scenario, significantly affecting runtime performance.\n Use function `IRObjectGatherRaytracingIntrinsics` to collect the intrinsic usage mask for all closest hit, any hit, intersection, and callable shaders in the pipeline to build.\n After calling this function, all subsequent shaders compiled need to conform to the masks provided, otherwise undefined behavior occurs.\n Specifying a mask and then adding additional shaders to a pipeline that don't conform to it causes undefined behavior.\n @param compiler compiler to configure\n @param maxAttributeSizeInBytes the maximum number of ray tracing attributes (in bytes) that a pipeline consisting of these shaders uses.\n @param raytracingPipelineFlags flags for the ray tracing pipeline your application builds from these shaders.\n @param chs bitwise OR mask of all closest hit shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskClosestHitAll`).\n @param miss bitwise OR mask of all miss shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskMissShaderAll`).\n @param anyHit bitwise OR mask of all any hit shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskAnyHitShaderAll`).\n @param callableArgs bitwise OR mask of all callable shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskCallableShaderAll`).\n @param maxRecursiveDepth stop point for recursion. Pass `IRRayTracingUnlimitedRecursionDepth` for no limit.\n @warning providing mask values other than the defaults or those returned by `IRObjectGatherRaytracingIntrinsics` may cause subsequent shader compilations to fail."] + #[doc = " Configure a compiler with upfront information to generate an optimal interface between ray tracing functions.\n Calling this function is optional, but when omitted, the compiler needs to assume a worst-case scenario, significantly affecting runtime performance.\n Use function `IRObjectGatherRaytracingIntrinsics` to collect the intrinsic usage mask for all closest hit, any hit, intersection, and callable shaders in the pipeline to build.\n After calling this function, all subsequent shaders compiled need to conform to the masks provided, otherwise undefined behavior occurs.\n Specifying a mask and then adding additional shaders to a pipeline that don't conform to it causes undefined behavior.\n @param compiler compiler to configure\n @param maxAttributeSizeInBytes the maximum number of ray tracing attributes (in bytes) that a pipeline consisting of these shaders uses.\n @param raytracingPipelineFlags flags for the ray tracing pipeline your application builds from these shaders.\n @param chs bitwise OR mask of all closest hit shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskClosestHitAll`).\n @param miss bitwise OR mask of all miss shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskMissShaderAll`).\n @param anyHit bitwise OR mask of all any hit shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskAnyHitShaderAll`).\n @param callableArgs bitwise OR mask of all callable shaders for a ray tracing pipeline your application builds using subsequent converted shaders (defaults to `IRIntrinsicMaskCallableShaderAll`).\n @param maxRecursiveDepth stop point for recursion. Pass `IRRayTracingUnlimitedRecursionDepth` for no limit.\n @param rayGenerationCompilationMode set the ray-generation shader compilation mode to compile either as a compute kernel, or as a visible function for a shader binding table.\n @warning providing mask values other than the defaults or those returned by `IRObjectGatherRaytracingIntrinsics` may cause subsequent shader compilations to fail."] pub unsafe fn IRCompilerSetRayTracingPipelineArguments( &self, compiler: *mut IRCompiler, @@ -1882,6 +1978,7 @@ impl metal_irconverter { anyHit: u64, callableArgs: u64, maxRecursiveDepth: ::std::os::raw::c_int, + rayGenerationCompilationMode: IRRayGenerationCompilationMode, ) { (self.IRCompilerSetRayTracingPipelineArguments)( compiler, @@ -1892,6 +1989,7 @@ impl metal_irconverter { anyHit, callableArgs, maxRecursiveDepth, + rayGenerationCompilationMode, ) } #[doc = " Configure compiler compatibility flags.\n Compatibility flags allow you to tailor code generation to the specific requirements of your shaders.\n You typically enable compatibility flags to support a broader set of features and behaviors (such as out-of-bounds reads) when your shader needs them to operate correctly.\n These flags, however, carry a performance cost.\n Always use the minimum set of compatibility flags your shader needs to attain the highest runtime performance for IR code you compile.\n @param compiler the compiler to configure\n @param flags bitmask of compatibility flags to enable."] @@ -1978,6 +2076,14 @@ impl metal_irconverter { ) { (self.IRCompilerIgnoreRootSignature)(compiler, ignoreEmbeddedRootSignature) } + #[doc = " Set compiler settings to ignore debug information.\n @param compiler compiler for which to set the flags.\n @param ignoreDebugInformation whether dxil debug information should be ignored. Defaults to false."] + pub unsafe fn IRCompilerIgnoreDebugInformation( + &self, + compiler: *mut IRCompiler, + ignoreDebugInformation: bool, + ) { + (self.IRCompilerIgnoreDebugInformation)(compiler, ignoreDebugInformation) + } #[doc = " Set the minimum operating system software version target for Metal IR code generation.\n Targetting a newer software version may enable the compiler to emi MetalIR further optimized for newer macOS and iOS releases, but it may render it incompatible with older operating system versions.\n Setting a minimum deployment target newer than your SDK may produce an `IRErrorCodeUnableToLinkModule` error.\n @param compiler compiler to configure.\n @param operatingSystem operating system name.\n @param version operating system version, such as \"13.0.0\" or \"16.0.0\"."] pub unsafe fn IRCompilerSetMinimumDeploymentTarget( &self, @@ -2007,7 +2113,7 @@ impl metal_irconverter { pub unsafe fn IRMetalLibGetBytecodeSize(&self, lib: *const IRMetalLibBinary) -> usize { (self.IRMetalLibGetBytecodeSize)(lib) } - #[doc = " Serialize an MetalIR object's shader bytecode to disk.\n @param outputPath path into which to write the serialized MetalIR.\n @param obj IRObject containing the bytecode to serialize.\n @param stage shader stage to serialize."] + #[doc = " Serialize a MetalIR object's shader bytecode to disk.\n @param outputPath path into which to write the serialized MetalIR.\n @param obj IRObject containing the bytecode to serialize.\n @param stage shader stage to serialize."] pub unsafe fn IRObjectSerialize( &self, outputPath: *const ::std::os::raw::c_char, @@ -2229,18 +2335,32 @@ impl metal_irconverter { ) { (self.IRRootSignatureGetResourceLocations)(rootSignature, resourceLocations) } - #[doc = " Serialize reflection information into JSON.\n @param reflection reflection object.\n @return null-terminated string containing JSON. You need to release this string by calling IRShaderReflectionFreeString."] + #[doc = " Serialize reflection information into JSON.\n @param reflection reflection object.\n @return null-terminated string containing JSON. You need to release this string by calling IRShaderReflectionFreeString.\n @deprecated use IRShaderReflectionCopyJSONString instead."] pub unsafe fn IRShaderReflectionAllocStringAndSerialize( &self, reflection: *mut IRShaderReflection, ) -> *const ::std::os::raw::c_char { (self.IRShaderReflectionAllocStringAndSerialize)(reflection) } - #[doc = " Release a string allocated by IRShaderReflectionAllocStringAndSerialize.\n @param serialized string to release."] + #[doc = " Serialize reflection information into JSON.\n @param reflection reflection object.\n @return null-terminated string containing JSON. You need to release this string by calling IRShaderReflectionFreeString."] + pub unsafe fn IRShaderReflectionCopyJSONString( + &self, + reflection: *const IRShaderReflection, + ) -> *const ::std::os::raw::c_char { + (self.IRShaderReflectionCopyJSONString)(reflection) + } + #[doc = " Release a string allocated by IRShaderReflectionAllocStringAndSerialize.\n @param serialized string to release.\n @deprecated use IRShaderReflectionReleaseString instead."] pub unsafe fn IRShaderReflectionFreeString(&self, serialized: *const ::std::os::raw::c_char) { (self.IRShaderReflectionFreeString)(serialized) } - #[doc = " Deserialize a JSON string into a reflection object.\n @param blob null-terminated JSON string containing reflection information.\n @param reflection reflection object into which to deserialize."] + #[doc = " Release a string allocated by IRShaderReflectionAllocStringAndSerialize.\n @param serialized string to release."] + pub unsafe fn IRShaderReflectionReleaseString( + &self, + serialized: *const ::std::os::raw::c_char, + ) { + (self.IRShaderReflectionReleaseString)(serialized) + } + #[doc = " Deserialize a JSON string into a reflection object.\n @param blob null-terminated JSON string containing reflection information.\n @param reflection reflection object into which to deserialize.\n @deprecated use IRShaderReflectionCreateFromJSON instead."] pub unsafe fn IRShaderReflectionDeserialize( &self, blob: *const ::std::os::raw::c_char, @@ -2248,21 +2368,42 @@ impl metal_irconverter { ) { (self.IRShaderReflectionDeserialize)(blob, reflection) } - #[doc = " Serialize a root signature descriptor into a string representation.\n @param rootSignatureDescriptor root signature descriptor to serialize.\n @return a string representation of the root signature descriptor. You need to release this string by calling IRVersionedRootSignatureDescriptorFreeString."] + #[doc = " Deserialize a JSON string into a reflection object.\n @param json null-terminated JSON string containing reflection information.\n @return a newly-allocated shader reflection object that you need to release by calling IRShaderReflectionDestroy,\n or NULL on error."] + pub unsafe fn IRShaderReflectionCreateFromJSON( + &self, + json: *const ::std::os::raw::c_char, + ) -> *mut IRShaderReflection { + (self.IRShaderReflectionCreateFromJSON)(json) + } + #[doc = " Serialize a root signature descriptor into a string representation.\n @param rootSignatureDescriptor root signature descriptor to serialize.\n @return a string representation of the root signature descriptor. You need to release this string by calling IRVersionedRootSignatureDescriptorFreeString.\n @deprecated use IRVersionedRootSignatureDescriptorCopyJSONString instead."] pub unsafe fn IRVersionedRootSignatureDescriptorAllocStringAndSerialize( &self, rootSignatureDescriptor: *mut IRVersionedRootSignatureDescriptor, ) -> *const ::std::os::raw::c_char { (self.IRVersionedRootSignatureDescriptorAllocStringAndSerialize)(rootSignatureDescriptor) } - #[doc = " Release a string allocated by IRVersionedRootSignatureDescriptorAllocStringAndSerialize.\n @param serialized string to release."] + #[doc = " Serialize a root signature descriptor into a string representation.\n @param rootSignatureDescriptor root signature descriptor to serialize.\n @return a string representation of the root signature descriptor. You need to release this string by calling IRVersionedRootSignatureDescriptorFreeString."] + pub unsafe fn IRVersionedRootSignatureDescriptorCopyJSONString( + &self, + rootSignatureDescriptor: *mut IRVersionedRootSignatureDescriptor, + ) -> *const ::std::os::raw::c_char { + (self.IRVersionedRootSignatureDescriptorCopyJSONString)(rootSignatureDescriptor) + } + #[doc = " Release a string allocated by IRVersionedRootSignatureDescriptorAllocStringAndSerialize.\n @param serialized string to release.\n @deprecated use IRVersionedRootSignatureDescriptorReleaseString instead."] pub unsafe fn IRVersionedRootSignatureDescriptorFreeString( &self, serialized: *const ::std::os::raw::c_char, ) { (self.IRVersionedRootSignatureDescriptorFreeString)(serialized) } - #[doc = " Deserialized a string representation of a root signature into a root signature object.\n @param serialized a string representation of a root signature.\n @param rootSignatureDescriptor root signature object into which to deserialize the root signature.\n @return true if deserialization is successful, false otherwise."] + #[doc = " Release a string allocated by IRVersionedRootSignatureDescriptorAllocStringAndSerialize.\n @param serialized string to release."] + pub unsafe fn IRVersionedRootSignatureDescriptorReleaseString( + &self, + serialized: *const ::std::os::raw::c_char, + ) { + (self.IRVersionedRootSignatureDescriptorReleaseString)(serialized) + } + #[doc = " Deserialize a string representation of a root signature into a root signature object.\n @param serialized a string representation of a root signature.\n @param rootSignatureDescriptor root signature object into which to deserialize the root signature.\n @return true if deserialization is successful, false otherwise.\n @warning this function may allocate memory, call IRVersionedRootSignatureDescriptorReleaseArrays to deallocate any allocated memory.\n @deprecated use IRVersionedRootSignatureDescriptorCreateFromJSON instead."] pub unsafe fn IRVersionedRootSignatureDescriptorDeserialize( &self, serialized: *const ::std::os::raw::c_char, @@ -2270,4 +2411,46 @@ impl metal_irconverter { ) -> bool { (self.IRVersionedRootSignatureDescriptorDeserialize)(serialized, rootSignatureDescriptor) } + #[doc = " Deserialize a string representation of a root signature into a root signature object.\n @param serialized a string representation of a root signature.\n @return a newly-allocated root signature object that you need to release, or NULL on error."] + pub unsafe fn IRVersionedRootSignatureDescriptorCreateFromJSON( + &self, + serialized: *const ::std::os::raw::c_char, + ) -> *mut IRVersionedRootSignatureDescriptor { + (self.IRVersionedRootSignatureDescriptorCreateFromJSON)(serialized) + } + #[doc = " Release any arrays allocated by IRVersionedRootSignatureDescriptorDeserialize.\n @param rootSignatureDescriptor root signature descriptor to release."] + pub unsafe fn IRVersionedRootSignatureDescriptorRelease( + &self, + rootSignatureDescriptor: *mut IRVersionedRootSignatureDescriptor, + ) { + (self.IRVersionedRootSignatureDescriptorRelease)(rootSignatureDescriptor) + } + #[doc = " Serialize an input layout descriptor version 1 into a string.\n @param inputLayoutDescriptor descriptor to serialize.\n @return a string representation of the input layout descriptor. You need to release this string by calling IRInputLayoutDescriptor1FreeString."] + pub unsafe fn IRInputLayoutDescriptor1CopyJSONString( + &self, + inputLayoutDescriptor: *mut IRInputLayoutDescriptor1, + ) -> *const ::std::os::raw::c_char { + (self.IRInputLayoutDescriptor1CopyJSONString)(inputLayoutDescriptor) + } + #[doc = " Release a string allocated by IRInputLayoutDescriptor1CopyJSONString.\n @param serialized string to release."] + pub unsafe fn IRInputLayoutDescriptor1ReleaseString( + &self, + serialized: *const ::std::os::raw::c_char, + ) { + (self.IRInputLayoutDescriptor1ReleaseString)(serialized) + } + #[doc = " Deserialize a string representation of an input layout descriptor version 1 into an IRInputLayoutDescriptor1 structure.\n @param serialized a string representation of an input layout descriptor version 1.\n @return a newly-allocated input layout descriptor version 1 object that you need to release by calling IRInputLayoutDescriptor1Release,\n NULL if an error occurs."] + pub unsafe fn IRInputLayoutDescriptor1CreateFromJSON( + &self, + serialized: *const ::std::os::raw::c_char, + ) -> *mut IRInputLayoutDescriptor1 { + (self.IRInputLayoutDescriptor1CreateFromJSON)(serialized) + } + #[doc = " Release an IRInputDescriptor1 instance allocated by IRInputLayoutDescriptor1CreateFromJSON.\n @param inputLayoutDescriptor input layout descriptor to release."] + pub unsafe fn IRInputLayoutDescriptor1Release( + &self, + inputLayoutDescriptor: *mut IRInputLayoutDescriptor1, + ) { + (self.IRInputLayoutDescriptor1Release)(inputLayoutDescriptor) + } } diff --git a/src/lib.rs b/src/lib.rs index 0c2ceeb..01683b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -318,6 +318,7 @@ impl IRCompiler { any_hit_intrinsics_mask: u64, callable_args: u64, max_recursive_depth: i32, + ray_generation_compilation_mode: ffi::IRRayGenerationCompilationMode, ) { unsafe { self.funcs.IRCompilerSetRayTracingPipelineArguments( @@ -329,6 +330,7 @@ impl IRCompiler { any_hit_intrinsics_mask, callable_args, max_recursive_depth, + ray_generation_compilation_mode, ) } }