-1

在以下金属性能着色器代码中:

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;

struct MeshVertex
{
    half3 worldPosition3d;
    half2 cameraPosition2d;
};

kernel void MeshImageblockShader_kernelFunction(
                 imageblock<MeshVertex>                 meshVertex_imageblock,
                 texture2d<float, access::read_write>   trueDepthTexture       [[ texture(0) ]],
        constant float3x3&                              positionInThreadgroup  [[ thread_position_in_threadgroup ]],
                 ushort2                                positionInGrid         [[ threadgroup_position_in_grid ]])
{

    threadgroup_imageblock MeshVertex* meshVertex_threadgroupImageblock = meshVertex_imageblock.data(positionInThreadgroup);
    imageblock_slice<half3> worldPosition3d_slice = meshVertex_imageblock.slice(meshVertex_threadgroupImageblock->worldPosition3d);    
}

我在最后一个代码行收到两个错误:

(!) implicit instantiation of undefined template 'metal::imageblock_slice<half __attribute__((ext_vector_type(3))), metal::imageblock_layout_explicit, void>'
(!) too few template arguments for class template 'imageblock_slice'

我正在尝试遵循https://developer.apple.com/videos/play/tech-talks/603/上“Metal 2 on a!! - Imageblocks”的技术谈话示例 (代码示例在 3 :25 进入视频。)

我无法使用图像块在互联网上找到任何代码示例。

谁能建议一些示例代码,或者告诉我为什么不编译?

4

2 回答 2

0

你错过#include <metal_imageblocks>了顶部。

于 2019-03-26T08:06:05.323 回答
0

imageblock_slice<T>模板与half3.

更改以imageblock_slice<half4>解决此问题。

于 2018-12-07T02:40:33.980 回答