Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Does gvr_buffer_viewport_set_external_surface_id work with normal OpenGL textures? #378

Closed
MortimerGoro opened this issue Mar 13, 2017 · 5 comments

Comments

@MortimerGoro
Copy link

Hello,
I want to use an already rendered OpenGL texture in gvr_frame_submit, without using buffer specs. The texture is a normal GL_TEXTURE_2D (not a GL_TEXTURE_EXTERNAL_OES or a surface from the video stream from Android). Can I use this texture with the external_surface_id API?

I'm using the API like this, but crashes on gvr_frame_submit call.

Create swap chain with empty spec list
gvr_swap_chain_create(ctx, NULL, 0)

Set external texture ids

gvr_buffer_viewport_set_external_surface_id(left_eye_vp, texture_id)
gvr_buffer_viewport_set_external_surface_id(right_eye_vp, texture_id)

Set buffer indices

gvr_buffer_viewport_set_source_buffer_index(left_eye_vp, GVR_BUFFER_INDEX_EXTERNAL_SURFACE);
gvr_buffer_viewport_set_source_buffer_index(right_eye_vp, GVR_BUFFER_INDEX_EXTERNAL_SURFACE);

Submit frame
gvr_frame_submit(frame, .viewport_list, head_matrix)

@ian-wevr
Copy link

I, too, have this question -- I'm working with an engine that assembles and manages its own framebuffer objects, hence using a framebuffer object directly with this engine is impossible without some fairly deep modification. Right now I'm working around this by resolving into GVR's swapchain framebuffer with some hacked in GL calls, but it's a notable performance/heat hit. If I can't use my own textures, can I at least get a GL renderbuffer handle or GL texture handle like in other VR platforms?

@MortimerGoro
Copy link
Author

MortimerGoro commented Mar 13, 2017

Tried those hacks but no luck:

fib = gvr_frame_get_framebuffer_object(frame, 0);
bindFrameBuffer(fid);
glFramebufferTexture2D(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, gl::TEXTURE_2D, texture_id, 0);
gvr_frame_bind_buffer(frame, 0);
glFramebufferTexture2D(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, gl::TEXTURE_2D, texture_id, 0);
gvr_frame_unbind(frame);

I know that I can render with a quad but that requires a lot of work specially in a module based architecture (loading gl symbols, shaders, etc..). It would be great to simply specify a texture_id which exists. For example, the OpenVR API allows to do that easily.

@jdduke
Copy link

jdduke commented Mar 14, 2017

Currently, the gvr_buffer_viewport_set_external_surface_id API is intended solely for use with the video APIs exposed by GvrLayout. See the SDK video guide for sample usage, and the SDK Video Player Sample. We'll be fleshing out this API a bit more in a future release, but note that it is currently restricted to compositing quad layers into eye space, i.e., it doesn't support arbitrary sampling from the external Surface.

Would it be sufficient for the API to create and return a Surface you can provide to your codec (or rendering framework, by way of eglCreateWindowSurface())?

@ian-wevr
Copy link

@jdduke I can't speak for MortimerGoro, but as long as rendering to the surface is as fast as using gvr_frame_bind_buffer is (without the need to copy) and there's no other performance penalty, that would work well in my case.

@MortimerGoro
Copy link
Author

MortimerGoro commented Mar 16, 2017

I got it working attaching the texture to a custom fbo and using BlitFramebuffer ;)

@jdduke In my case I wouldn't use that API because I can't change the surface where the "framework" renders to.

@jdduke jdduke closed this as completed Dec 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants