[OpenGL and Vulkan Interoperability on Linux] Part 6: We should be able to reuse a Vulkan pixel buffer from OpenGL but not to overwrite it!

This is another blog post on OpenGL and Vulkan Interoperability. It’s not really a description of a new use case as the Piglit test I am going to describe is quite similar to the previous example we’ve seen where we reused a Vulkan pixel buffer from OpenGL. This Piglit test was written because there’s an interesting issue (Issue 7) in the spec according to which overwriting Vulkan buffers with glBufferSubData is not possible! This is interesting because we can overwrite textures but not buffers. When we attempt to overwrite a buffer using glBufferSubData the driver must return an Invalid Operation Error and this is what we tested with the vk-pix-buf-update-errors test that can be found in tests/spec/ext_external_objects directory like all other tests we’ve seen so far.

So, there isn’t much to describe here. All steps are similar to the ones we’ve seen in Part 5:

we first create a pixel buffer and fill it with a Vulkan image’s data, and then we import it in OpenGL as PIXEL_UNPACK_BUFFER. The difference is that in the previous example we used it to fill the texture, but here we first try to overwrite it using glBufferSubData and then we fill the texture. At the end we validate first that the correct error had been returned to the user, and then that the data remained unchanged.

The new gl_init doesn’t fill the texture anymore:

and the new display performs the checks described above:

The rest of the code has been explained in Part 5.

And that was it! I’ve decided to include this test in the blog posts because it is important to remember that with the EXT_external_objects extensions:

External Vulkan textures can be overwritten from OpenGL but external Vulkan buffers can’t!


What’s coming next:

Next posts will be about reusing vertex buffers and attempting to overwrite them. Stay tuned!

and see you next time!

Leave a Reply

Your email address will not be published. Required fields are marked *