Ошибка шаблона "неявная реализация" при использовании Metal API с Imageblocks

В следующем металлическом шейдерном коде производительности:

#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'

Я пытаюсь следовать примеру технической беседы для "Metal 2 on a!! - Imageblocks" на https://developer.apple.com/videos/play/tech-talks/603/(Пример кода приведен на 3:25 в видео.)

Я не могу найти какие-либо примеры кода в Интернете, используя imageblocks.

Может кто-нибудь предложить пример кода или сказать, почему это не компилируется?

1 ответ

imageblock_slice<T> шаблон не совместим с half3,

Изменение на imageblock_slice<half4> исправляет это.

Вы пропустили #include <metal_imageblocks> на вершине.

Другие вопросы по тегам