Cleaning
This commit is contained in:
@@ -23,19 +23,27 @@ typedef struct
|
|||||||
int offset;
|
int offset;
|
||||||
int fourcc;
|
int fourcc;
|
||||||
int numplanes;
|
int numplanes;
|
||||||
unsigned long int modifiers;
|
EGLuint64KHR modifiers;
|
||||||
} dma_texture_params;
|
} dma_texture_params;
|
||||||
|
|
||||||
bool lvrcInitSwapChain(struct lvrcInstance * instance, unsigned int width, unsigned int height, GLuint * textures)
|
bool lvrcInitSwapChain(struct lvrcInstance * instance, unsigned int width, unsigned int height, GLuint * textures)
|
||||||
{
|
{
|
||||||
Instance * internalInstance = (Instance*)instance;
|
Instance * internalInstance = (Instance*)instance;
|
||||||
|
|
||||||
if (!internalInstance->user_context)
|
if (!internalInstance->user_context || !internalInstance->vr_context)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
eglMakeCurrent(internalInstance->user_display, internalInstance->user_surface, internalInstance->user_surface, internalInstance->user_context);
|
EGLDisplay old_display = eglGetCurrentDisplay();
|
||||||
|
EGLSurface old_surface_draw = eglGetCurrentSurface(EGL_DRAW);
|
||||||
|
EGLSurface old_surface_read = eglGetCurrentSurface(EGL_READ);
|
||||||
|
EGLContext old_context = eglGetCurrentContext();
|
||||||
|
|
||||||
|
if (old_context != internalInstance->user_context)
|
||||||
|
{
|
||||||
|
eglMakeCurrent(internalInstance->user_display, EGL_NO_SURFACE, EGL_NO_SURFACE, internalInstance->user_context);
|
||||||
|
}
|
||||||
|
|
||||||
EGLint imageAttribs[] =
|
EGLint imageAttribs[] =
|
||||||
{
|
{
|
||||||
@@ -67,6 +75,12 @@ bool lvrcInitSwapChain(struct lvrcInstance * instance, unsigned int width, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dma_texture_params left_texture_params;
|
||||||
|
left_texture_params.width = width;
|
||||||
|
left_texture_params.height = height;
|
||||||
|
eglExportDMABUFImageQuery(internalInstance->user_display, left_image, &left_texture_params.fourcc, &left_texture_params.numplanes, &left_texture_params.modifiers);
|
||||||
|
eglExportDMABUFImage(internalInstance->user_display, left_image, &left_texture_params.fd, &left_texture_params.stride, &left_texture_params.offset);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create and export right image
|
// Create and export right image
|
||||||
//
|
//
|
||||||
@@ -78,6 +92,12 @@ bool lvrcInitSwapChain(struct lvrcInstance * instance, unsigned int width, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dma_texture_params right_texture_params;
|
||||||
|
right_texture_params.width = width;
|
||||||
|
right_texture_params.height = height;
|
||||||
|
eglExportDMABUFImageQuery(internalInstance->user_display, right_image, &right_texture_params.fourcc, &right_texture_params.numplanes, &right_texture_params.modifiers);
|
||||||
|
eglExportDMABUFImage(internalInstance->user_display, right_image, &right_texture_params.fd, &right_texture_params.stride, &right_texture_params.offset);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Import textures in user context
|
// Import textures in user context
|
||||||
//
|
//
|
||||||
@@ -106,23 +126,11 @@ bool lvrcInitSwapChain(struct lvrcInstance * instance, unsigned int width, unsig
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
dma_texture_params left_texture_params;
|
|
||||||
left_texture_params.width = width;
|
|
||||||
left_texture_params.height = height;
|
|
||||||
eglExportDMABUFImageQuery(internalInstance->user_display, left_image, &left_texture_params.fourcc, &left_texture_params.numplanes, &left_texture_params.modifiers);
|
|
||||||
eglExportDMABUFImage(internalInstance->user_display, left_image, &left_texture_params.fd, &left_texture_params.stride, &left_texture_params.offset);
|
|
||||||
|
|
||||||
dma_texture_params right_texture_params;
|
|
||||||
right_texture_params.width = width;
|
|
||||||
right_texture_params.height = height;
|
|
||||||
eglExportDMABUFImageQuery(internalInstance->user_display, right_image, &right_texture_params.fourcc, &right_texture_params.numplanes, &right_texture_params.modifiers);
|
|
||||||
eglExportDMABUFImage(internalInstance->user_display, right_image, &right_texture_params.fd, &right_texture_params.stride, &right_texture_params.offset);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Import textures in VR context
|
// Import textures in VR context
|
||||||
//
|
//
|
||||||
|
|
||||||
eglMakeCurrent(internalInstance->vr_display, internalInstance->vr_surface, internalInstance->vr_surface, internalInstance->vr_context);
|
eglMakeCurrent(internalInstance->vr_display, EGL_NO_SURFACE, EGL_NO_SURFACE, internalInstance->vr_context);
|
||||||
|
|
||||||
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2D_VR = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress ("glEGLImageTargetTexture2DOES");
|
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2D_VR = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress ("glEGLImageTargetTexture2DOES");
|
||||||
|
|
||||||
@@ -186,7 +194,9 @@ bool lvrcInitSwapChain(struct lvrcInstance * instance, unsigned int width, unsig
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
eglMakeCurrent(internalInstance->user_display, internalInstance->user_surface, internalInstance->user_surface, internalInstance->user_context);
|
//
|
||||||
|
// Restore context
|
||||||
|
eglMakeCurrent(old_display, old_surface_draw, old_surface_read, old_context);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user