Ошибка шаблона "неявная реализация" при использовании Metal API с Imageblocks - PullRequest
0 голосов
/ 07 декабря 2018

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

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

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

Ответы [ 2 ]

0 голосов
/ 26 марта 2019

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

0 голосов
/ 07 декабря 2018

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

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

...