c++ - cudaMemcpy2DFromArray resulting in cudaErrorInvalidValue -
c++ - cudaMemcpy2DFromArray resulting in cudaErrorInvalidValue -
i having troubles using opengl-cuda-interopt setup following:
i using framebufferobject render texture (this works well) creating way:
void createframebuffer(){ // create texture fbo glgentextures(1, &tex_data); glbindtexture(gl_texture_2d, tex_data); sdk_check_error_gl(); gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_clamp_to_edge); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_clamp_to_edge); gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest); gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_nearest); glteximage2d(gl_texture_2d, 0, gl_rgba16f , window_w, window_h, 0, gl_rgba, gl_float, null); // create framebuffer glgenframebuffersext(1, &fbo); glbindframebufferext(gl_framebuffer_ext, fbo); // register texture cuda checkcudaerrors(cudagraphicsglregisterimage(&res_data, tex_data, gl_texture_2d, cudagraphicsmapflagsreadonly)); sdk_check_error_gl(); // attach images glgenrenderbuffersext(1, &depth_rb); glbindrenderbufferext(gl_renderbuffer_ext, depth_rb); glrenderbufferstorageext(gl_renderbuffer_ext, gl_depth_component24, window_w, window_h); //------------------------- glframebuffertexture2dext(gl_framebuffer_ext, gl_color_attachment0_ext, gl_texture_2d, tex_data, 0); //attach depth buffer fbo glframebufferrenderbufferext(gl_framebuffer_ext, gl_depth_attachment_ext, gl_renderbuffer_ext, depth_rb); //glframebufferrenderbufferext(gl_framebuffer_ext, gl_color_attachment0_ext, gl_renderbuffer_ext, color); //glframebufferrenderbufferext(gl_framebuffer_ext, gl_depth_attachment_ext, gl_renderbuffer_ext, depth); // clean glbindframebufferext(gl_framebuffer_ext, 0); sdk_check_error_gl(); }
currently not having kernel, want convert texture opengl can utilize cuda. here trying conversion:
void processimage(){ cudaarray *cuda_data = 0; checkcudaerrors( cudagraphicsglregisterimage(&res_data, tex_data, gl_texture_2d, cudagraphicsregisterflagsreadonly)); float *ddata; // array holding info std::cout << "cudamalloc " << std::endl; checkcudaerrors( cudamalloc(&ddata, window_w * window_h*4*sizeof(float))); std::cout << "mapping resource" << std::endl; checkcudaerrors( cudagraphicsmapresources(1, &res_data) ); std::cout << "cudagraphicssubresourcegetmappedarray" << std::endl; checkcudaerrors( cudagraphicssubresourcegetmappedarray(&cuda_data, res_data, 0, 0)); std::cout << "cudamemcpy2dfromarray" << std::endl; // re-create texture graphic card checkcudaerrors( cudamemcpy2dfromarray(ddata, window_w*4*sizeof(float), cuda_data ,0 ,0, window_w*4*sizeof(float), window_h, cudamemcpydevicetodevice)); std::cout << "cudagraphicsunmapresources" << std::endl; // unmap resource checkcudaerrors( cudagraphicsunmapresources(1, &res_data)); }
the problem when executing programme cuda throws error:
cuda error @ e:\workspace\master\gradientrenderer\gradientrenderer\source.cpp:175 code=11(cudaerrorinvalidvalue) "cudamemcpy2dfromarray(ddata, window_w*4*sizeof(float), cuda_data ,0 ,0, window_w*4*sizeof(float), window_h, cudamemcpydevicetodevice)"
can tell me doing wrong? part of bigger project using predefined kernel (no way alter kernel) need phone call cudamemcpy2dfromarray texture correctly transferred kernel.
c++ opengl cuda
Comments
Post a Comment