[vtkusers] How to write into VTK vertex buffer object from an OpenCL kernel

Robert Maynard robert.maynard at kitware.com
Thu Oct 27 15:55:10 EDT 2016


As Ken stated we have the ability to have VBO's be shared between
OpenGL and OpenCL. The key as was mentioned you need to call
GenerateBuffer() on the VBO to get the buffer id, from there you can
copy your data from OpenCL into OpenGL.

As far as I am aware, it is impossible to pass an OpenCL object to
OpenGL. Instead you must allocate in OpenGL and than fill that inside
OpenCL.

On Wed, Oct 26, 2016 at 12:56 PM, David E DeMarle
<dave.demarle at kitware.com> wrote:
> You might be able to scrounge some ideas from Accelerators/Piston.
> Back then we did the direct handoff from cuda to GL via glinterop.
>
> See:
> https://gitlab.kitware.com/vtk/vtk/blob/master/Accelerators/Piston/vtkPistonMapper.cu
>
> Warning that project is long deprecated and won't build with anything
> recent. In particular that was written before Rendering/OpenGL2 existed.
>
> I expect that vtk-m will have an entirely revamped version of the concept
> when it lands in VTK in a couple of months.
>
>
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
> On Wed, Oct 26, 2016 at 12:21 PM, Ken Martin <ken.martin at kitware.com> wrote:
>>
>> The shaders can be updated ala http://www.vtk.org/Wiki/Shader_In_VTK
>>
>> In terms of getting the VBO I believe it has been done, not by me. I think
>> you have to setup your data and render it to get the VBO built. Then you can
>> get it's handle and pass that to cuda or something like that.
>>
>> setup input data with the right size, num points, even if the values are
>> dummy positions
>> polydatamapper->Render()
>> vbo = polydatamapper->GetVBO()
>> handle = vbo->GetHandle()
>>
>> would be nice to have an example.
>>
>>
>> On Wed, Oct 26, 2016 at 10:27 AM, Reza Faieghi <mfaieghi at westerneng.ca>
>> wrote:
>>>
>>> Hello,
>>>
>>>
>>>
>>> My code generates a massive polygonal data through an openCL kernel. For
>>> rendering purposes, this data copies from GPU memory to host memory.
>>> Afterward, there are regular VTK codes to create an unstructured grid,
>>> passing data into the renderer and display them. However, the data transfers
>>> between device and host memories are time-consuming.
>>>
>>>
>>> In order to speed up the code, I want to pass the polygonal data directly
>>> from the openCL kernel to vertex buffer object. I am wondering is there any
>>> way that I can bridge between openCL and openGL part of the VTK renderer?
>>>
>>> I assume that I will need to make few changes in openGL commands like
>>> glDrawArrays. I also need to make a few changes in vertex shader just to
>>> make sure that the renderer works fine with my data. Other than, the rest of
>>> shaders should remain unchanged. Is it possible to access the shaders and
>>> make the above changes?
>>>
>>>
>>> I would really appreciate it if you could help me with this.
>>>
>>>
>>>
>>> Best Regards,
>>>
>>> Reza Faieghi
>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>
>>
>>
>>
>> --
>> Ken Martin PhD
>> Chairman & CFO
>> Kitware Inc.
>> 28 Corporate Drive
>> Clifton Park NY 12065
>> 518 371 3971
>>
>> This communication, including all attachments, contains confidential and
>> legally privileged information, and it is intended only for the use of the
>> addressee.  Access to this email by anyone else is unauthorized. If you are
>> not the intended recipient, any disclosure, copying, distribution or any
>> action taken in reliance on it is prohibited and may be unlawful. If you
>> received this communication in error please notify us immediately and
>> destroy the original message.  Thank you.
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list