繁体   English   中英

未知类型名称“MTLResourceID”

[英]Unknown type name 'MTLResourceID'

我正在尝试新的 Metal 3 Apple 示例代码,但我在实时渲染反射中遇到错误,使用光线追踪项目告诉我AAPLArgumentBufferTypes.h文件中的Unknown type name 'MTLResourceID' ,我试图调查这个错误,我在 Apple Developer 上看到一个页面说明 MTLResource 已被弃用,所以我尝试用更新的代码替换它,但它没有改变任何东西,这也是一个新项目,所以我不会认为问题是弃用,有人会吗能帮我解决这个问题吗?

错误在第 101 行

我在 macOS Ventura Beta 7 和 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

您需要使用 Xcode 14 Beta 下载,而不是 RC(Release Candidate)下载。 Xcode 14 RC 仅包含 macOS 12 SDK。 Beta Xcode 14 包含 Beta Ventura SDK。 您还需要确保您的部署目标设置为 macOS 13/iOS 16。并且还要检查在 Xcode 项目中构建您的.metal文件的目标中的“Metal Language Revision”( MTL_LANGUAGE_REVISION )设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM