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/ir_version.h b/bindings_generator/vendor/metal_irconverter/ir_version.h index 56afc49..69fe9ac 100644 --- a/bindings_generator/vendor/metal_irconverter/ir_version.h +++ b/bindings_generator/vendor/metal_irconverter/ir_version.h @@ -21,7 +21,7 @@ #define IR_VERSION_MAJOR 2 #define IR_VERSION_MINOR 0 -#define IR_VERSION_PATCH 0 +#define IR_VERSION_PATCH 3 #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 f0a8a60..45cda40 100644 --- a/bindings_generator/vendor/metal_irconverter/metal_irconverter.h +++ b/bindings_generator/vendor/metal_irconverter/metal_irconverter.h @@ -25,6 +25,12 @@ #import #endif // __APPLE__ +#if _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 @@ -325,6 +331,12 @@ typedef enum IRRaytracingPipelineFlags IRRaytracingPipelineFlagSkipProceduralPrimitives = 0x200 } IRRaytracingPipelineFlags; +typedef enum IRRayGenerationCompilationMode +{ + IRRayGenerationCompilationKernel, + IRRayGenerationCompilationVisibleFunction +} IRRayGenerationCompilationMode; + enum IRErrorCode { IRErrorCodeNoError, @@ -571,9 +583,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. @@ -1234,63 +1247,129 @@ 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); +/** + * 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* IRInputLayoutDescriptor1AllocStringAndSerialize(IRInputLayoutDescriptor1* inputLayoutDescriptor); +const char* IRInputLayoutDescriptor1CopyJSONString(IRInputLayoutDescriptor1* inputLayoutDescriptor); /** - * Release a string allocated by IRInputLayoutDescriptor1AllocStringAndSerialize. + * Release a string allocated by IRInputLayoutDescriptor1CopyJSONString. * @param serialized string to release. */ -void IRInputLayoutDescriptor1FreeString(const char* serialized); +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. - * @param inputLayoutDescriptor input layout descriptor version 1 object into which to deserialized the input layout descriptor. - * @return true if deserialization is successful, false otherwise. + * @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. */ -bool IRInputLayoutDescriptor1Deserialize(const char* serialized, IRInputLayoutDescriptor1* inputLayoutDescriptor); +void IRInputLayoutDescriptor1Release(IRInputLayoutDescriptor1* inputLayoutDescriptor); #ifdef __cplusplus } 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 a537132..c3bf54e 100644 --- a/bindings_generator/vendor/metal_irconverter_runtime/metal_irconverter_runtime.h +++ b/bindings_generator/vendor/metal_irconverter_runtime/metal_irconverter_runtime.h @@ -81,8 +81,18 @@ extern const uint64_t kIRArgumentBufferDrawArgumentsBindPoint; extern const uint64_t kIRArgumentBufferUniformsBindPoint; extern const uint64_t kIRVertexBufferBindPoint; extern const uint64_t kIRStageInAttributeStartIndex; + extern const char* kIRIndirectTriangleIntersectionFunctionName; extern const char* kIRIndirectProceduralIntersectionFunctionName; + +extern const char* kIRTrianglePassthroughGeometryShader; +extern const char* kIRLinePassthroughGeometryShader; +extern const char* kIRPointPassthroughGeometryShader; + +extern const char* kIRFunctionGroupRayGeneration; +extern const char* kIRFunctionGroupClosestHit; +extern const char* kIRFunctionGroupMiss; + extern const uint16_t kIRNonIndexedDraw; typedef struct IRDescriptorTableEntry @@ -290,16 +300,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. @@ -315,7 +326,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. @@ -423,6 +434,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. @@ -439,6 +451,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. @@ -454,6 +481,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. @@ -488,6 +529,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. @@ -514,10 +558,19 @@ 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; +const char* kIRFunctionGroupRayGeneration = "rayGen"; +const char* kIRFunctionGroupClosestHit = "closestHit"; +const char* kIRFunctionGroupMiss = "miss"; const uint64_t kIRBufSizeOffset = 0; const uint64_t kIRBufSizeMask = 0xffffffff; @@ -586,7 +639,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 @@ -599,7 +652,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; @@ -619,7 +672,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; @@ -659,20 +712,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 = { kIRNonIndexedDraw, (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 } @@ -692,14 +750,13 @@ void IRRuntimeDrawPrimitives(renderencoder_t enc, primitivetype_t primitiveType, IR_INLINE void IRRuntimeDrawPrimitives(renderencoder_t enc, primitivetype_t primitiveType, buffer_t indirectBuffer, uint64_t indirectBufferOffset) IR_OVERLOADABLE { - IRRuntimeDrawInfo di = { kIRNonIndexedDraw, (uint8_t)primitiveType, 0, 0, 0 }; #ifdef IR_RUNTIME_METALCPP enc->setVertexBuffer( indirectBuffer, indirectBufferOffset, kIRArgumentBufferDrawArgumentsBindPoint ); - enc->setVertexBytes( &di, sizeof( IRRuntimeDrawInfo ), kIRArgumentBufferUniformsBindPoint ); + enc->setVertexBytes( &kIRNonIndexedDraw, sizeof( uint16_t ), kIRArgumentBufferUniformsBindPoint ); enc->drawPrimitives( primitiveType, indirectBuffer, indirectBufferOffset ); #else [enc setVertexBuffer:indirectBuffer offset:indirectBufferOffset atIndex:kIRArgumentBufferDrawArgumentsBindPoint]; - [enc setVertexBytes:&di length:sizeof( IRRuntimeDrawInfo ) atIndex:kIRArgumentBufferUniformsBindPoint]; + [enc setVertexBytes:&kIRNonIndexedDraw length:sizeof( uint16_t ) atIndex:kIRArgumentBufferUniformsBindPoint]; [enc drawPrimitives:primitiveType indirectBuffer:indirectBuffer indirectBufferOffset:indirectBufferOffset]; #endif } @@ -716,15 +773,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 } @@ -744,11 +801,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 } @@ -929,6 +990,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) { @@ -1056,6 +1178,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, @@ -1364,31 +1567,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; @@ -1571,32 +1780,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/src/bindings.rs b/runtime/src/bindings.rs index cdfb200..ab68a64 100644 --- a/runtime/src/bindings.rs +++ b/runtime/src/bindings.rs @@ -117,6 +117,24 @@ extern "C" { extern "C" { pub static mut kIRIndirectProceduralIntersectionFunctionName: *const ::std::os::raw::c_char; } +extern "C" { + pub static mut kIRTrianglePassthroughGeometryShader: *const ::std::os::raw::c_char; +} +extern "C" { + pub static mut kIRLinePassthroughGeometryShader: *const ::std::os::raw::c_char; +} +extern "C" { + pub static mut kIRPointPassthroughGeometryShader: *const ::std::os::raw::c_char; +} +extern "C" { + pub static mut kIRFunctionGroupRayGeneration: *const ::std::os::raw::c_char; +} +extern "C" { + pub static mut kIRFunctionGroupClosestHit: *const ::std::os::raw::c_char; +} +extern "C" { + pub static mut kIRFunctionGroupMiss: *const ::std::os::raw::c_char; +} extern "C" { pub static kIRNonIndexedDraw: u16; } diff --git a/src/bindings.rs b/src/bindings.rs index 15a8018..f45ef6d 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -2,7 +2,7 @@ pub const IR_VERSION_MAJOR: u32 = 2; pub const IR_VERSION_MINOR: u32 = 0; -pub const IR_VERSION_PATCH: u32 = 0; +pub const IR_VERSION_PATCH: u32 = 3; pub const IRDescriptorRangeOffsetAppend: u32 = 4294967295; pub const IRIntrinsicMaskClosestHitAll: u32 = 2147483647; pub const IRIntrinsicMaskMissShaderAll: u32 = 32767; @@ -841,6 +841,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, @@ -1274,6 +1281,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), @@ -1412,32 +1420,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 IRInputLayoutDescriptor1AllocStringAndSerialize: + 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 IRInputLayoutDescriptor1FreeString: + pub IRInputLayoutDescriptor1ReleaseString: unsafe extern "C" fn(serialized: *const ::std::os::raw::c_char), - pub IRInputLayoutDescriptor1Deserialize: unsafe extern "C" fn( - serialized: *const ::std::os::raw::c_char, - inputLayoutDescriptor: *mut IRInputLayoutDescriptor1, - ) -> bool, + 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 @@ -1637,29 +1667,53 @@ 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 IRInputLayoutDescriptor1AllocStringAndSerialize = __library - .get(b"IRInputLayoutDescriptor1AllocStringAndSerialize\0") + 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 IRInputLayoutDescriptor1FreeString = __library - .get(b"IRInputLayoutDescriptor1FreeString\0") + let IRInputLayoutDescriptor1CreateFromJSON = __library + .get(b"IRInputLayoutDescriptor1CreateFromJSON\0") .map(|sym| *sym)?; - let IRInputLayoutDescriptor1Deserialize = __library - .get(b"IRInputLayoutDescriptor1Deserialize\0") + let IRInputLayoutDescriptor1Release = __library + .get(b"IRInputLayoutDescriptor1Release\0") .map(|sym| *sym)?; Ok(metal_irconverter { __library, @@ -1734,14 +1788,22 @@ impl metal_irconverter { IRRootSignatureGetResourceCount, IRRootSignatureGetResourceLocations, IRShaderReflectionAllocStringAndSerialize, + IRShaderReflectionCopyJSONString, IRShaderReflectionFreeString, + IRShaderReflectionReleaseString, IRShaderReflectionDeserialize, + IRShaderReflectionCreateFromJSON, IRVersionedRootSignatureDescriptorAllocStringAndSerialize, + IRVersionedRootSignatureDescriptorCopyJSONString, IRVersionedRootSignatureDescriptorFreeString, + IRVersionedRootSignatureDescriptorReleaseString, IRVersionedRootSignatureDescriptorDeserialize, - IRInputLayoutDescriptor1AllocStringAndSerialize, - IRInputLayoutDescriptor1FreeString, - IRInputLayoutDescriptor1Deserialize, + 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."] @@ -1902,7 +1964,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, @@ -1913,6 +1975,7 @@ impl metal_irconverter { anyHit: u64, callableArgs: u64, maxRecursiveDepth: ::std::os::raw::c_int, + rayGenerationCompilationMode: IRRayGenerationCompilationMode, ) { (self.IRCompilerSetRayTracingPipelineArguments)( compiler, @@ -1923,6 +1986,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."] @@ -2268,18 +2332,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, @@ -2287,21 +2365,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 = " 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."] + #[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, @@ -2309,26 +2408,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 IRInputLayoutDescriptor1AllocStringAndSerialize( + pub unsafe fn IRInputLayoutDescriptor1CopyJSONString( &self, inputLayoutDescriptor: *mut IRInputLayoutDescriptor1, ) -> *const ::std::os::raw::c_char { - (self.IRInputLayoutDescriptor1AllocStringAndSerialize)(inputLayoutDescriptor) + (self.IRInputLayoutDescriptor1CopyJSONString)(inputLayoutDescriptor) } - #[doc = " Release a string allocated by IRInputLayoutDescriptor1AllocStringAndSerialize.\n @param serialized string to release."] - pub unsafe fn IRInputLayoutDescriptor1FreeString( + #[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.IRInputLayoutDescriptor1FreeString)(serialized) + (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 @param inputLayoutDescriptor input layout descriptor version 1 object into which to deserialized the input layout descriptor.\n @return true if deserialization is successful, false otherwise."] - pub unsafe fn IRInputLayoutDescriptor1Deserialize( + #[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, - ) -> bool { - (self.IRInputLayoutDescriptor1Deserialize)(serialized, inputLayoutDescriptor) + ) { + (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, ) } }