Hello all, I am trying to create a protected EGL image but it fails to get created, any help is highly appreciated.
Here is the code:
void createEGLImage2DTextureSource(size_t width,
size_t height,
GLenum format,
GLenum type,
void *data,
EGLDisplay dpy,
EGLContext ctx,
GLuint *outSourceTexture,
EGLImageKHR *outSourceImage)
{
// Create a source 2D texture
GLuint source;
EGLint attribs[] = {
EGL_GL_TEXTURE_LEVEL_KHR, 1, EGL_PROTECTED_CONTENT_EXT, EGL_TRUE,
EGL_NONE};
EGLImageKHR image;
glGenTextures(1, &source);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
glBindTexture(GL_TEXTURE_2D, source);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
glTexImage2D(GL_TEXTURE_2D, 0, format, width,
height, 0, format, type, data);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
// Disable mipmapping
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
// Create an image from the source texture
image =
eglCreateImageKHR(dpy, ctx, EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer) (intptr_t)source, attribs);
if (image == EGL_NO_IMAGE_KHR) {
/* Skip, not fail, because the spec allows the implementation
* to reject image creation.
*/
piglit_loge("failed to create EGLImage");
piglit_report_result(PIGLIT_SKIP);
}
*outSourceTexture = source;
*outSourceImage = image;
}
void test_EGLImage2DTexture(EGLDisplay dpy, EGLContext ctx)
{
GLubyte data[4] = {255, 0, 255, 255};
// Create the Image
GLuint source;
EGLImageKHR image;
createEGLImage2DTextureSource(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data, dpy, ctx, &source, &image);
// Clean up
glDeleteTextures(1, &source);
eglDestroyImageKHR(dpy, image);
}