Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using d3d11 shared handle in opengl results with black texture #141

Closed
ChrisTanev opened this issue Feb 23, 2018 · 4 comments
Closed

Using d3d11 shared handle in opengl results with black texture #141

ChrisTanev opened this issue Feb 23, 2018 · 4 comments
Labels

Comments

@ChrisTanev
Copy link

ChrisTanev commented Feb 23, 2018

Just wanna start by saying that i am following your example https://github.com/Microsoft/angle/wiki/Interop-with-other-DirectX-code and i created eglSurface successfully -
surface = eglCreatePbufferFromClientBuffer(egl_display, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, reinterpret_cast<HANDLE>(handle), egl_config, pBufferAttributes);

Gen and bind a texture

    glGenTextures(1, &glTex);
    glBindTexture(GL_TEXTURE_2D, glTex);
    eglBindTexImage(mEglDisplay, surface, EGL_BACK_BUFFER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

Render

glBegin(GL_QUADS);	 

	glTexCoord2d( srcX, srcY ); glVertex3d( -r.width/2, -r.height/2, 0);
	glTexCoord2d( srcW, srcY ); glVertex3d( r.width/2, -r.height/2, 0);
	glTexCoord2d( srcW, srcH); glVertex3d( r.width/2, r.height/2, 0);
	glTexCoord2d( srcX, srcH); glVertex3d( -r.width/2, r.height/2, 0);

glEnd()

The problem is that using shared handle always yields black texture result. Is there anything
that i'm missing ? I checked on your example EGLPresentPathD3D11Test.cpp , but it doesnt show any usage of eglBindTexImage(mEglDisplay, surface, EGL_BACK_BUFFER);

Also im a little confused with step # 4 from https://github.com/Microsoft/angle/wiki/Interop-with-other-DirectX-code - "Write your DirectX code to render onto 'd3dTex', and your GL code to use 'glTex'. " The only thing i need is to use the shared handle from d3d11 device(which has a texture , but doesnt need to render it , just share it) and render into gl with help of eglCreatePbufferFromClientBuffer.

Im not an EGL expert , but the example doesnt show how to do it in existing opengl context?

EDIT : How do i access the EGL_BACK_BUFFER from gl context ?
eglBindTexImage(egl_display, surface, EGL_BACK_BUFFER);

@austinkinross
Copy link
Member

Hi,

The problem is that using shared handle always yields black texture result.

Are you using D3D11 or GL to read back the contents of the texture?

If you want to access the texture (via the shared handle) in D3D11 code after performing GL rendering then you'll need to call glFlush() first. The texture will be uninitialized if you don't do this.

@ChrisTanev
Copy link
Author

Hello @austinkinross and thanks for your response !

I would like to read the content of the share handle(the texture) in GL and use it in the already existing GL content to render it in scene. I create the texture in d3d11 and render to it , then get a shared handle and created l surface successfully - eglCreatePbufferFromClientBuffer(egl_display, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, reinterpret_cast<HANDLE>(handle), egl_config, pBufferAttributes); , but i dont know how to get the pixels from it/render it to GL texture.

@dforsten
Copy link

I am running into the same issue following the example at https://github.com/Microsoft/angle/wiki/Interop-with-other-DirectX-code, the texture stays black on the OpenGL ES side.

@austinkinross
Copy link
Member

Hi everyone, apologies for the delay here. If you are still having problems in this area (or have any other questions) then I suggest asking over on the master ANGLE project's mailing list: https://groups.google.com/forum/#!forum/angleproject

Thanks
Austin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants