getting cuda mipmap arrays to work with cudaMallocMipmappedArray, cudaGetMipmappedArrayLevel and cud

I’m trying to create a mipmapped array in cuda. This is the code:

#include "cuda_runtime.h"
#include <iostream>

void handleCudaError(cudaError_t error) {
    if (error != cudaSuccess) std::cerr << "CUDA error: " << cudaGetErrorString(error) << std::endl;

int main() {
    cudaMipmappedArray* mipArray;
    cudaChannelFormatDesc desc = cudaCreateChannelDesc<uchar4>();
    int mipLevelels = 1;
    cudaExtent size = make_cudaExtent(512, 512, 5);
    handleCudaError(cudaMallocMipmappedArray(&mipArray, &desc, size, mipLevelels, cudaArrayLayered));

    cudaArray* level0;
    handleCudaError(cudaGetMipmappedArrayLevel(&level0, mipArray, 0));

    uchar4* h_data = new uchar4;
    for (int i = 0; i < size.width * size.height * size.depth; i++) h_data[i] = make_uchar4(0, 0, 0, 0);

    cudaMemcpy3DParms copyParams = { 0 };
    copyParams.srcPtr = make_cudaPitchedPtr(h_data, 512 * sizeof(uchar4), 512, 512);
    copyParams.dstArray = level0;
    copyParams.extent = make_cudaExtent(512, 512, 5);
    copyParams.dstPos = make_cudaPos(0, 0, 0);
    copyParams.kind = cudaMemcpyHostToDevice;

    delete h_data;
    return 0;

on line 27 I get the following:

CUDA error: unspecified launch failure

I’ve searched the forum, used google and browsed the samples, but I couldn’t make this code work. I intend to later pass that mipmapped array to cudaBindTextureToMipmappedArray and hope that i’ll be able to use tex2DLayeredLod.

provided compiling code

i do not follow line 10; then again, i am cuda illiterate

is cudaCreateChannelDesc() an api?

cudaCreateChannelDesc (int x, int y, int z, int w,
cudaChannelFormatKind f)

yes, it’s part of the c++ highlevel api: (i hope the link works, found in cuda documentation -> Cuda Runtime API -> Modules -> C++ API Routines -> cudaCreateChannelDesc )

it simply returns a channelDesc fitting the template argument.

check line 19: for (int i = 0; i < size.width * size.height * size.depth; i++) h_data[i] = make_uchar4(0, 0, 0, 0);

when i debug the program, i can not get past it; in fact, i can not even get 1 iteration of the loop when stepping the program

seems that, not only am i cuda illiterate, i also do not know how to use the debugger

safe to argue that this truly messed up my tea-time