Skip to content

Commit

Permalink
Change some error type in eglCreateImageKHR
Browse files Browse the repository at this point in the history
Following the spec, for eglCreateImageKHR, if target is
EGL_LINUX_DMA_BUF_EXT and attribute value is not expected,
then EGL_BAD_ATTRIBUTE should be returned. However, ANGLE would
return EGL_BAD_PARAMETER. Now change these error handlings to
return EGL_BAD_ATTRIBUTE. Also, a end2end test is added.

Bug: angleproject:387892107
Change-Id: I73ecfc3da273c0fb5ac362e451fd186209f1a52b
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6146196
Reviewed-by: Yuly Novikov <[email protected]>
Commit-Queue: Shahbaz Youssefi <[email protected]>
Reviewed-by: Geoff Lang <[email protected]>
  • Loading branch information
yuxiangq7 authored and Angle LUCI CQ committed Jan 10, 2025
1 parent c01fb33 commit 2de256c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libANGLE/validationEGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3693,7 +3693,7 @@ bool ValidateCreateImage(const ValidationContext *val,
break;

default:
val->setError(EGL_BAD_PARAMETER,
val->setError(EGL_BAD_ATTRIBUTE,
"Invalid value for EGL_YUV_COLOR_SPACE_HINT_EXT.");
return false;
}
Expand All @@ -3715,7 +3715,7 @@ bool ValidateCreateImage(const ValidationContext *val,
break;

default:
val->setError(EGL_BAD_PARAMETER,
val->setError(EGL_BAD_ATTRIBUTE,
"Invalid value for EGL_SAMPLE_RANGE_HINT_EXT.");
return false;
}
Expand All @@ -3739,7 +3739,7 @@ bool ValidateCreateImage(const ValidationContext *val,

default:
val->setError(
EGL_BAD_PARAMETER,
EGL_BAD_ATTRIBUTE,
"Invalid value for EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT or "
"EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT.");
return false;
Expand Down
27 changes: 27 additions & 0 deletions src/tests/gl_tests/ImageTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7680,6 +7680,33 @@ TEST_P(ImageTestES3, CreatesRGBImages)
}
}

// Regression test to check that sRGB texture can be used to create image in sRGB colorspace.
// Also check that creating image using sRGB texture in linear colorspace wouldn't fail.
TEST_P(ImageTestES3, DmaBufNegativeValidation)
{
EGLWindow *window = getEGLWindow();
ANGLE_SKIP_TEST_IF(!hasBaseExt());
ANGLE_SKIP_TEST_IF(!IsEGLDisplayExtensionEnabled(getEGLWindow()->getDisplay(),
"EGL_EXT_image_dma_buf_import"));

const EGLint invalidImageAttributeList[][3] = {
{EGL_YUV_COLOR_SPACE_HINT_EXT, EGL_NONE, EGL_NONE},
{EGL_SAMPLE_RANGE_HINT_EXT, EGL_NONE, EGL_NONE},
{EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT, EGL_NONE, EGL_NONE},
{EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT, EGL_NONE, EGL_NONE},
};

EGLImageKHR image;

for (size_t i = 0; i < 4; i++)
{
image = eglCreateImageKHR(window->getDisplay(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL,
invalidImageAttributeList[i]);
ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
ASSERT_EQ(image, EGL_NO_IMAGE_KHR);
}
}

ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(ImageTest);

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ImageTestES3);
Expand Down

0 comments on commit 2de256c

Please sign in to comment.