I am trying to try out the new Metal 3 Apple Sample Code but I get an error in the Rendering reflections in real time using ray tracing Project telling me Unknown type name 'MTLResourceID'
in the AAPLArgumentBufferTypes.h
file, I tried to look into this error and I saw a page on on Apple Developer stating that MTLResource was deprecated so I tried replacing it with the updated code but it did not change anything, this was also a new project so I would not assume that the issue was deprecation, would anybody be able to help me with this?
The Error is on line 101
I am on macOS Ventura Beta 7 and Xcode 14
/*
See LICENSE folder for this sample’s licensing information.
Abstract:
The header that contains the defining types to use in argument buffers.
*/
#ifndef AAPLArgumentBufferTypes_h
#define AAPLArgumentBufferTypes_h
#include "AAPLShaderTypes.h"
typedef enum AAPLArgumentBufferID
{
AAPLArgmentBufferIDGenericsTexcoord,
AAPLArgmentBufferIDGenericsNormal,
AAPLArgmentBufferIDGenericsTangent,
AAPLArgmentBufferIDGenericsBitangent,
AAPLArgmentBufferIDSubmeshIndices,
AAPLArgmentBufferIDSubmeshMaterials,
AAPLArgmentBufferIDMeshPositions,
AAPLArgmentBufferIDMeshGenerics,
AAPLArgmentBufferIDMeshSubmeshes,
AAPLArgmentBufferIDInstanceMesh,
AAPLArgmentBufferIDInstanceTransform,
AAPLArgmentBufferIDSceneInstances,
AAPLArgumentBufferIDSceneMeshes
} AAPLArgumentBufferID;
#if __METAL_VERSION__
#include <metal_stdlib>
using namespace metal;
struct MeshGenerics
{
float2 texcoord [[ id( AAPLArgmentBufferIDGenericsTexcoord ) ]];
half4 normal [[ id( AAPLArgmentBufferIDGenericsNormal ) ]];
half4 tangent [[ id( AAPLArgmentBufferIDGenericsTangent ) ]];
half4 bitangent [[ id( AAPLArgmentBufferIDGenericsBitangent ) ]];
};
struct Submesh
{
// The container mesh stores positions and generic vertex attribute arrays.
// The submesh stores only indices into these vertex arrays.
uint32_t shortIndexType [[id(0)]];
// The indices for the container mesh's position and generics arrays.
constant uint32_t* indices [[ id( AAPLArgmentBufferIDSubmeshIndices ) ]];
// The fixed size array of material textures.
array<texture2d<float>, AAPLMaterialTextureCount> materials [[ id( AAPLArgmentBufferIDSubmeshMaterials ) ]];
};
struct Mesh
{
// The arrays of vertices.
constant packed_float3* positions [[ id( AAPLArgmentBufferIDMeshPositions ) ]];
constant MeshGenerics* generics [[ id( AAPLArgmentBufferIDMeshGenerics ) ]];
// The array of submeshes.
constant Submesh* submeshes [[ id( AAPLArgmentBufferIDMeshSubmeshes ) ]];
};
struct Instance
{
// A reference to a single mesh in the meshes array stored in structure `Scene`.
uint32_t meshIndex [[id(0)]];
//constant Mesh* pMesh [[ id( AAPLArgmentBufferIDInstanceMesh ) ]];
// The location of the mesh for this instance.
float4x4 transform [[id(1)]];
};
struct Scene
{
// The array of instances.
constant Instance* instances [[ id( AAPLArgmentBufferIDSceneInstances ) ]];
constant Mesh* meshes [[ id( AAPLArgumentBufferIDSceneMeshes )]];
};
#else
#include <Metal/Metal.h>
struct Submesh
{
// The container mesh stores positions and generic vertex attribute arrays.
// The submesh stores only indices in these vertex arrays.
uint32_t shortIndexType;
// Indices for the container mesh's position and generics arrays.
uint64_t indices;
// The fixed size array of material textures.
MTLResourceID materials[AAPLMaterialTextureCount];
};
struct Mesh
{
// The arrays of vertices.
uint64_t positions;
uint64_t generics;
// The array of submeshes.
uint64_t submeshes;
};
struct Instance
{
// A reference to a single mesh.
uint32_t meshIndex;
// The location of the mesh for this instance.
matrix_float4x4 transform;
};
struct Scene
{
// The array of instances.
uint64_t instances;
uint64_t meshes;
};
#endif // __METAL_VERSION__
#endif // ArgumentBufferTypes_h
CodePudding user response:
You need to use Xcode 14 Beta downloads, not RC (Release Candidate) downloads. Xcode 14 RC contains only macOS 12 SDK. Beta Xcode 14 contains beta Ventura SDK. You also need to make sure that your deployment target is set to macOS 13/iOS 16. And also check "Metal Language Revision" (MTL_LANGUAGE_REVISION
) setting in the target that builds your .metal
files in Xcode project.