Skip to content

Commit

Permalink
HACK: Make constants available outside of IR_PRIVATE_IMPLEMENTATION
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 authored and Jasper-Bekkers committed Sep 25, 2024
1 parent 40dc6a9 commit 47d0f00
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ void IRRaytracingUpdateInstanceContributions(IRRaytracingAccelerationStructureGP

#ifndef __METAL_VERSION__

extern const char* kIRRayDispatchIndirectionKernelName;
extern const uint64_t kIRRayDispatchArgumentsBindPoint;

/**
* Encode an acceleration structure into the argument buffer.
* @param entry the pointer to the descriptor table entry to encode the acceleration structure reference into.
Expand Down Expand Up @@ -198,11 +195,11 @@ void IRShaderIdentifierInit(IRShaderIdentifier* identifier, uint64_t shaderHandl
*/
void IRShaderIdentifierInitWithCustomIntersection(IRShaderIdentifier* identifier, uint64_t shaderHandle, uint64_t intersectionShaderHandle) IR_OVERLOADABLE;

#ifdef IR_PRIVATE_IMPLEMENTATION

const char* kIRRayDispatchIndirectionKernelName = "RaygenIndirection";
const uint64_t kIRRayDispatchArgumentsBindPoint = 3;

#ifdef IR_PRIVATE_IMPLEMENTATION

IR_INLINE
void IRShaderIdentifierInit(IRShaderIdentifier* identifier, uint64_t shaderHandle) IR_OVERLOADABLE
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ extern "C" {
#include <stdint.h>
#endif // __cplusplus

extern const uint64_t kIRRuntimeTessellatorTablesBindPoint;
extern const uint32_t kIRRuntimeTessellatorTablesCountsAndOffsetLength;
extern const uint32_t kIRRuntimeTessellatorTablesLookupTableLength;
const uint64_t kIRRuntimeTessellatorTablesBindPoint = 7;
const uint32_t kIRRuntimeTessellatorTablesCountsAndOffsetLength = 32768;
const uint32_t kIRRuntimeTessellatorTablesLookupTableLength = 701114;

/**
* Query the size in bytes necessary to store the tessellator tables.
Expand Down Expand Up @@ -4209,10 +4209,6 @@ static const uint8_t kIRTessellatorTablesLookupTable[] = {
0,1,0,0,1,3,1,2,2,3,2,2,3,3,3,2,4,3,4,2,5,3,5,2,6,3,6,2,7,3,7,2,8,3,8,2,9,3,9,2,10,3,10,2,11,3,11,2,12,3,12,2,13,3,13,2,14,3,14,2,15,3,15,2,16,3,16,2,17,3,17,2,18,3,18,2,19,3,19,2,20,3,20,2,21,3,21,2,22,3,22,2,23,3,23,2,24,3,24,2,25,3,25,2,26,3,26,2,27,3,27,2,28,3,28,2,29,3,29,2,30,3,30,2,31,3,31,2,32,3,31,0,33,3,32,2,34,3,33,2,35,3,34,2,36,3,35,2,37,3,36,2,38,3,37,2,39,3,38,2,40,3,39,2,41,3,40,2,42,3,41,2,43,3,42,2,44,3,43,2,45,3,44,2,46,3,45,2,47,3,46,2,48,3,47,2,49,3,48,2,50,3,49,2,51,3,50,2,52,3,51,2,53,3,52,2,54,3,53,2,55,3,54,2,56,3,55,2,57,3,56,2,58,3,57,2,59,3,58,2,60,3,59,2,61,3,60,2,62,3,61,2,63,3,62,2,64,3,// in:64 out:64
};

const uint64_t kIRRuntimeTessellatorTablesBindPoint = 7;
const uint32_t kIRRuntimeTessellatorTablesCountsAndOffsetLength = 32768;
const uint32_t kIRRuntimeTessellatorTablesLookupTableLength = 701114;

IR_INLINE
uint64_t IRRuntimeTessellatorTablesSize(void)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,6 @@ extern "C" {
#define IR_INLINE __attribute__((always_inline))
#define IR_OVERLOADABLE __attribute__((overloadable))

extern const uint64_t kIRArgumentBufferBindPoint;
extern const uint64_t kIRDescriptorHeapBindPoint;
extern const uint64_t kIRSamplerHeapBindPoint;
extern const uint64_t kIRArgumentBufferHullDomainBindPoint;
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
{
uint64_t gpuVA;
Expand Down Expand Up @@ -541,15 +519,6 @@ renderpipelinestate_t IRRuntimeNewGeometryTessellationEmulationPipeline(device_t
const IRGeometryTessellationEmulationPipelineDescriptor* descriptor,
nserror_t* error) API_AVAILABLE(macosx(14), ios(17));

#ifdef IR_PRIVATE_IMPLEMENTATION

#ifndef IR_RUNTIME_METALCPP
#if !__has_feature(objc_arc)
#error The implementation of this file needs to be generated in a module with ARC enabled when in Objective-C mode.
#endif
#endif


const uint64_t kIRArgumentBufferBindPoint = 2;
const uint64_t kIRArgumentBufferHullDomainBindPoint = 3;
const uint64_t kIRDescriptorHeapBindPoint = 0;
Expand Down Expand Up @@ -579,6 +548,15 @@ const uint64_t kIRTexViewMask = 0xff;
const uint64_t kIRTypedBufferOffset = 63;


#ifdef IR_PRIVATE_IMPLEMENTATION

#ifndef IR_RUNTIME_METALCPP
#if !__has_feature(objc_arc)
#error The implementation of this file needs to be generated in a module with ARC enabled when in Objective-C mode.
#endif
#endif


IR_INLINE
void IRRuntimeCreateAppendBufferView(device_t device, buffer_t appendBuffer, uint64_t appendBufferOffset, uint32_t initialCounterValue, IRBufferView* outBufferView)
{
Expand Down
98 changes: 32 additions & 66 deletions runtime/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,73 +87,16 @@ pub struct MTLDispatchThreadgroupsIndirectArguments {
}
pub type resourceid_t = MTLResourceID;
pub type uint = ::std::os::raw::c_uint;
extern "C" {
pub static kIRArgumentBufferBindPoint: u64;
}
extern "C" {
pub static kIRDescriptorHeapBindPoint: u64;
}
extern "C" {
pub static kIRSamplerHeapBindPoint: u64;
}
extern "C" {
pub static kIRArgumentBufferHullDomainBindPoint: u64;
}
extern "C" {
pub static kIRArgumentBufferDrawArgumentsBindPoint: u64;
}
extern "C" {
pub static kIRArgumentBufferUniformsBindPoint: u64;
}
extern "C" {
pub static kIRVertexBufferBindPoint: u64;
}
extern "C" {
pub static kIRStageInAttributeStartIndex: u64;
}
extern "C" {
pub static mut kIRIndirectTriangleIntersectionFunctionName: *const ::std::os::raw::c_char;
}
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;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct IRDescriptorTableEntry {
pub gpuVA: u64,
pub textureViewID: u64,
pub metadata: u64,
}
extern "C" {
pub static kIRRuntimeTessellatorTablesBindPoint: u64;
}
extern "C" {
pub static kIRRuntimeTessellatorTablesCountsAndOffsetLength: u32;
}
extern "C" {
pub static kIRRuntimeTessellatorTablesLookupTableLength: u32;
}
pub const kIRRuntimeTessellatorTablesBindPoint: u64 = 7;
pub const kIRRuntimeTessellatorTablesCountsAndOffsetLength: u32 = 32768;
pub const kIRRuntimeTessellatorTablesLookupTableLength: u32 = 701114;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct IRShaderIdentifier {
Expand Down Expand Up @@ -295,12 +238,8 @@ impl IRRaytracingInstanceDescriptor {
__bindgen_bitfield_unit
}
}
extern "C" {
pub static mut kIRRayDispatchIndirectionKernelName: *const ::std::os::raw::c_char;
}
extern "C" {
pub static kIRRayDispatchArgumentsBindPoint: u64;
}
pub const kIRRayDispatchIndirectionKernelName: &[u8; 18] = b"RaygenIndirection\0";
pub const kIRRayDispatchArgumentsBindPoint: u64 = 3;
#[repr(u32)]
#[non_exhaustive]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -524,3 +463,30 @@ pub struct IRRuntimeDrawInfo {
pub inputControlPointsPerPatch: u16,
pub indexBuffer: u64,
}
pub const kIRArgumentBufferBindPoint: u64 = 2;
pub const kIRArgumentBufferHullDomainBindPoint: u64 = 3;
pub const kIRDescriptorHeapBindPoint: u64 = 0;
pub const kIRSamplerHeapBindPoint: u64 = 1;
pub const kIRArgumentBufferDrawArgumentsBindPoint: u64 = 4;
pub const kIRArgumentBufferUniformsBindPoint: u64 = 5;
pub const kIRVertexBufferBindPoint: u64 = 6;
pub const kIRStageInAttributeStartIndex: u64 = 11;
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;
pub const kIRTexViewMask: u64 = 255;
pub const kIRTypedBufferOffset: u64 = 63;

0 comments on commit 47d0f00

Please sign in to comment.