Using Texture in Vertex Shader Error

I am trying to sample a texture inside a Metal vertex shader. Receiving the following error: "AGX: AGX: Texture read/write assertion failed: depth > 0"

Setup for rendering:

` MTLSamplerDescriptor *samplerDesc = [MTLSamplerDescriptor new]; samplerDesc.normalizedCoordinates = YES; samplerDesc.rAddressMode = MTLSamplerAddressModeClampToEdge; samplerDesc.sAddressMode = MTLSamplerAddressModeClampToEdge; samplerDesc.tAddressMode = MTLSamplerAddressModeClampToEdge; samplerDesc.minFilter = MTLSamplerMinMagFilterNearest; samplerDesc.magFilter = MTLSamplerMinMagFilterNearest; samplerDesc.mipFilter = MTLSamplerMipFilterNotMipmapped; id ss = [device newSamplerStateWithDescriptor:samplerDesc];

[ commandEncoder setVertexSamplerState : ss atIndex : 0 ];

[ commandEncoder setVertexTexture : l_Texture_Height_Field atIndex : CTI_Gradient ];

Vertex` Shader:

`vertex PVertex vertexShader_mkali ( uint vertexID [ [ vertex_id ] ], constant Vertex3D *vertexArray [ [ buffer ( CVI_Vertices ) ] ], constant vector_uint2 *viewportSizePointer [ [ buffer ( CVI_ViewportSize ) ] ], constant shader_Data_mkali &vertex_Shader_Data [ [ buffer ( CVI_ShaderData ) ] ], texture2d < float > heightTexture [ [ texture ( CTI_Gradient ) ] ], sampler smp [ [ sampler ( 0 ) ] ] )

{ PVertex outVertex; float2 l_Point = vertexArray [ vertexID ].position.xy; l_Point.x = mkali_noxstep( -1.0, 1.0, l_Point.x ); l_Point.y = mkali_noxstep( -1.0, 1.0, l_Point.y ); float4 l_Texture_Heightfield = heightTexture.sample ( smp, l_Point ); outVertex.position = float4 ( vertexArray [ vertexID ].position + float3 ( l_Texture_Heightfield.x, 0.0, 0.0 ), 1.0 ); outVertex.color = float4 ( 1.0, 0.5, 0.0, 1.0 ); outVertex.size = 30;
return outVertex; }`

Anybody have any ideas? thank you, Nikki

How did you create the MTLTexture object? It says that it has a null depth. A 2D texture is expected to have a depth of 1. See https://developer.apple.com/documentation/metal/mtltexturedescriptor/1516298-depth

However I would expect this kind of error to be caught by Metal API Validation, did you disable it? https://developer.apple.com/documentation/metal/diagnosing_metal_programming_issues_early

Using Texture in Vertex Shader Error
 
 
Q