Jump to content
  • Advertisement

Alex Garcin

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Alex Garcin

  • Rank
    Newbie

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. clGLDevice == curDevice_id This assertion is true for both the two platform. Each of the platform support GPU so how to get the one that is used by opengl ?
  2. Hello ! I have two gpu on my computer, one from my cpu and another one from my graphic card. I am trying to use the opengl/opencl interop capabilities. But I am stuck at the creation of the opencl context, I don't know how to identify which platform / device of the two one is used by opengl. In the above code, which fonction should I use in the test "DEVICE MATCHING OPENGL ONE" to test if the device is the one used by OpenGL, or what should I do to test if the platform_id is the good one ? sf::ContextSettings settings; settings.depthBits = 24; settings.stencilBits = 8; settings.antialiasingLevel = 2; sf::Window window(sf::VideoMode(2048, 1024), "GAME", sf::Style::Fullscreen, settings); glewInit(); cl_platform_id platform_ids[16] = { NULL }; cl_device_id device_id = NULL; cl_uint ret_num_devices; cl_uint ret_num_platforms; cl_platform_id platform_id = 0; cl_int ret = clGetPlatformIDs(_countof(platform_ids), platform_ids, &ret_num_platforms); size_t n = 0; cl_context_properties props[] = { CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(), CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(), CL_CONTEXT_PLATFORM, (cl_context_properties) platform_id, 0 }; for (size_t i = 0; i < ret_num_platforms; ++i) { platform_id = platform_ids[i]; cl_device_id curDevices_id[16]; ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, _countof(curDevices_id), curDevices_id, &ret_num_devices); for (cl_uint nDevices = 0; nDevices < ret_num_devices; ++nDevices) { cl_device_id curDevice_id = curDevices_id[nDevices]; clGetGLContextInfoKHR_fn clGetGLContextInfo = reinterpret_cast<clGetGLContextInfoKHR_fn> (clGetExtensionFunctionAddressForPlatform( platform_id, "clGetGLContextInfoKHR")); if (clGetGLContextInfo) { cl_device_id clGLDevice = 0; props[5] = reinterpret_cast<cl_context_properties>(platform_id); clGetGLContextInfo(props, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, sizeof(clGLDevice), &clGLDevice, &n); if (DEVICE MATCHING OPENGL ONE) { device_id = clGLDevice; } } } if (device_id) { break; } } cl_context context = clCreateContext(props, 1, &device_id, NULL, NULL, &ret); Thanks for your future help!
  3. Alex Garcin

    clCreateFromGLBuffer crash

    OK so how should I do to know which of the two contexts is the one used by opengl?
  4. Alex Garcin

    clCreateFromGLBuffer crash

    OK, when I replace sizeof(cl_uint) by sizeof(clGLDevice), I get a context in: clGetGLContextInfo(props, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, sizeof(cl_uint), &clGLDevice, &n); If I don't break on the line clGLDevice == curDevice_id, I get: OpenCL Device Name Intel(R) HD Graphics 530 OpenCL Device Vendor Intel(R) Corporation OpenCL Device Extensions cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_depth_images cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_image2d_from_buffer cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_media_block_io cl_intel_driver_diagnostics cl_intel_device_side_avc_motion_estimation cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_khr_fp64 cl_khr_subgroups cl_khr_il_program cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_intel_planar_yuv cl_intel_packed_yuv cl_intel_motion_estimation cl_intel_advanced_motion_estimation cl_khr_gl_sharing cl_khr_gl_depth_images cl_khr_gl_event cl_khr_gl_msaa_sharing cl_intel_dx9_media_sharing cl_khr_dx9_media_sharing cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_intel_d3d11_nv12_media_sharing cl_intel_simultaneous_sharing OpenCL Supports OpenCL/OpenGL sharing: true OpenCL Device Name GeForce GTX 1080 OpenCL Device Vendor NVIDIA Corporation OpenCL Device Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer OpenCL Supports OpenCL/OpenGL sharing: true For the first device I get the crash, and for the second every things works great, But why does't it works for my cpu gpu, while supportGLSharing says that it is supported ? Is it because opengl used the second device ? If so, how to check which device is used by opengl ? (Wasn't if (clGLDevice == curDevice_id) supposed to do that ? Because it breaks on the first device when it is supposed to break on the second one) By the way, I have tried to replace glut by sfml and it still works, my question is "why are you saying that it's a bad library" ?
  5. Alex Garcin

    clCreateFromGLBuffer crash

    Thanks for your reply,1) wglGetCurrentContext() != NULL ? wglGetCurrentDC() != NULL ?None of them are null.2) Try to create OpenGL Context without SMFL(VERY BAD library) or try to use SDL ))Will try.3) Can you attach your test project ? I can test him.http://garcin.alex.free.fr/partage/test.rar if(clCreateFromGLBuffer == NULL) ... they aren't null How? I can't see it in your code. For simplicity I don't have post it. Try stepping through your program an check if anything looks out of the ordinary. Like I said, unless you've malformed one or more of your calls, the culprit is most likely somewhere else in your program. As I have said, The small code that I have post in this forum reproduce the issue by itself without any other code addition What version is whatever library you use to initialize OpenCL? (update to the latest one) 4.6.0
  6. Alex Garcin

    clCreateFromGLBuffer crash

    Remember OpenCL follows a similar model to OpenGL. In your example you are using GLEW to initialize your OpenGL entry points (function pointers.) What are you using for OpenCL ? Nothing more that what I have written in my code exemple, I have followed all the tutorial I have found on the web...
  7. Alex Garcin

    clCreateFromGLBuffer crash

    @irreversible Is clCreateFromGLBuffer a valid function pointer? Eg have you tested it for null? What do you mean by function pointer ? clCreateFromGLBuffer is not a pointer ?! - the simpler reason has to do with your function arguments. Is the context valid? You're not running any checks at or around clCreateContext (or any other CL API functions, for that matter)? How can you be sure it succeeds? Add an error check after each call (better yet - wrap each call in a checker macro that you can later define to empty) I have allready check all the return statment and opengl errors and everything is ok  - the more complex reason has to do with the rest of your code. Create a test project. Remove any and all outside factors (multi-threading, prior code not related to the call, etc). If it you've checked everything outlined above and it still crashes, then you're looking at a more serious problem. It's allready a "test project", I have put that in a main without any other code and it crash.  Unless you've borked your arguments somewhere, the most likely culprit here is a buffer overflow (eg writing out of bounds) anywhere else in your program, which isn't detected, but thrashes the pointer to clCreateFromGLBuffer. Catching this can be hard. However, for starters, if your IDE supports it, you could try setting a hardware/data breakpoint to clCreateFromGLBuffer after it's been loaded and letting your program run to see if the address is modified. If it is, you'll hopefully know where the problem is. No because of the previous point. @cgrant try swapping the order of our context creation. You mean moving : cl_platform_id platform_id = NULL; cl_device_id device_id = NULL; cl_uint ret_num_devices; cl_uint ret_num_platforms; cl_int ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms); ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices); cl_context_properties props[] = { CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(), CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(), CL_CONTEXT_PLATFORM, (cl_context_properties) platform_id, 0 }; cl_context context = clCreateContext(props, 1, &device_id, NULL, NULL, &ret);  GLuint vboID_m = 0; before : sf::ContextSettings settings; settings.depthBits = 24; settings.stencilBits = 8; settings.antialiasingLevel = 2; sf::Window window(sf::VideoMode(2048, 1024), "GAME", sf::Style::Fullscreen, settings); glewInit(); ? Because when I do that I get a CL_INVALID_CONTEXT error.
  8. Hello every one, When I tried to use my vbo with opencl I get a crash when calling clCreateFromGLBuffer Below a small code that reproduce the issue: initialisation of the opengl context sf::ContextSettings settings; settings.depthBits = 24; settings.stencilBits = 8; settings.antialiasingLevel = 2; sf::Window window(sf::VideoMode(2048, 1024), "GAME", sf::Style::Fullscreen, settings); glewInit(); initialisation of the opencl context cl_platform_id platform_id = NULL; cl_device_id device_id = NULL; cl_uint ret_num_devices; cl_uint ret_num_platforms; cl_int ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms); ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices); cl_context_properties props[] = { CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(), CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(), CL_CONTEXT_PLATFORM, (cl_context_properties) platform_id, 0 }; cl_context context = clCreateContext(props, 1, &device_id, NULL, NULL, &ret); GLuint vboID_m = 0; Creation of the vertex buffer object glGenBuffers(1, &vboID_m); glBindBuffer(GL_ARRAY_BUFFER, vboID_m); { std::vector<float> tmp = { 0., 0., 0., 0., 0., 0., 0., 0., 0. }; glBufferData(GL_ARRAY_BUFFER, (tmp.size()) * sizeof(float), 0, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, tmp.size() * sizeof(float), tmp.data()); } glBindBuffer(GL_ARRAY_BUFFER, 0); glFlush(); Linkage of the opencl buffer with the opengl vertex buffer object cl_int status; clCreateFromGLBuffer(context, CL_MEM_READ_WRITE, vboID_m, &status); return 0; Thanks for your help!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!