Commit a818776e by Austin Kinross Committed by Jamie Madill

Fix warning C4312 (x64) - reinterpret_cast conversion to greater size

Change-Id: I90504b00e8f3af208511ec393ddfb0da267f56bc Reviewed-on: https://chromium-review.googlesource.com/293341Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarAustin Kinross <aukinros@microsoft.com>
parent 66d6313e
...@@ -100,7 +100,7 @@ class ImageTest : public ANGLETest ...@@ -100,7 +100,7 @@ class ImageTest : public ANGLETest
EGLWindow *window = getEGLWindow(); EGLWindow *window = getEGLWindow();
EGLImageKHR image = EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_2D_KHR, eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(source), nullptr); reinterpretHelper<EGLClientBuffer>(source), nullptr);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
...@@ -140,7 +140,7 @@ class ImageTest : public ANGLETest ...@@ -140,7 +140,7 @@ class ImageTest : public ANGLETest
EGLWindow *window = getEGLWindow(); EGLWindow *window = getEGLWindow();
EGLImageKHR image = EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), imageTarget, eglCreateImageKHR(window->getDisplay(), window->getContext(), imageTarget,
reinterpret_cast<EGLClientBuffer>(source), nullptr); reinterpretHelper<EGLClientBuffer>(source), nullptr);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
...@@ -181,7 +181,7 @@ class ImageTest : public ANGLETest ...@@ -181,7 +181,7 @@ class ImageTest : public ANGLETest
}; };
EGLImageKHR image = EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_3D_KHR, eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_3D_KHR,
reinterpret_cast<EGLClientBuffer>(source), attribs); reinterpretHelper<EGLClientBuffer>(source), attribs);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
...@@ -220,7 +220,7 @@ class ImageTest : public ANGLETest ...@@ -220,7 +220,7 @@ class ImageTest : public ANGLETest
EGLWindow *window = getEGLWindow(); EGLWindow *window = getEGLWindow();
EGLImageKHR image = EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_RENDERBUFFER_KHR, eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_RENDERBUFFER_KHR,
reinterpret_cast<EGLClientBuffer>(source), nullptr); reinterpretHelper<EGLClientBuffer>(source), nullptr);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
...@@ -286,6 +286,15 @@ class ImageTest : public ANGLETest ...@@ -286,6 +286,15 @@ class ImageTest : public ANGLETest
glDeleteFramebuffers(1, &framebuffer); glDeleteFramebuffers(1, &framebuffer);
} }
template <typename destType, typename sourcetype>
destType reinterpretHelper(sourcetype source)
{
static_assert(sizeof(destType) == sizeof(size_t),
"destType should be the same size as a size_t");
size_t sourceSizeT = static_cast<size_t>(source);
return reinterpret_cast<destType>(sourceSizeT);
}
GLuint mTextureProgram; GLuint mTextureProgram;
GLint mTextureUniformLocation; GLint mTextureUniformLocation;
...@@ -316,20 +325,20 @@ TEST_P(ImageTest, ValidationImageBase) ...@@ -316,20 +325,20 @@ TEST_P(ImageTest, ValidationImageBase)
EGLContext context = window->getContext(); EGLContext context = window->getContext();
EGLConfig config = window->getConfig(); EGLConfig config = window->getConfig();
EGLImageKHR image = EGL_NO_IMAGE_KHR; EGLImageKHR image = EGL_NO_IMAGE_KHR;
EGLClientBuffer texture2D = reinterpret_cast<EGLClientBuffer>(glTexture2D); EGLClientBuffer texture2D = reinterpretHelper<EGLClientBuffer>(glTexture2D);
// Test validation of eglCreateImageKHR // Test validation of eglCreateImageKHR
// If <dpy> is not the handle of a valid EGLDisplay object, the error EGL_BAD_DISPLAY is // If <dpy> is not the handle of a valid EGLDisplay object, the error EGL_BAD_DISPLAY is
// generated. // generated.
image = eglCreateImageKHR(reinterpret_cast<EGLDisplay>(0xBAADF00D), context, image = eglCreateImageKHR(reinterpretHelper<EGLDisplay>(0xBAADF00D), context,
EGL_GL_TEXTURE_2D_KHR, texture2D, nullptr); EGL_GL_TEXTURE_2D_KHR, texture2D, nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_DISPLAY); EXPECT_EGL_ERROR(EGL_BAD_DISPLAY);
// If <ctx> is neither the handle of a valid EGLContext object on <dpy> nor EGL_NO_CONTEXT, the // If <ctx> is neither the handle of a valid EGLContext object on <dpy> nor EGL_NO_CONTEXT, the
// error EGL_BAD_CONTEXT is generated. // error EGL_BAD_CONTEXT is generated.
image = eglCreateImageKHR(display, reinterpret_cast<EGLContext>(0xBAADF00D), image = eglCreateImageKHR(display, reinterpretHelper<EGLContext>(0xBAADF00D),
EGL_GL_TEXTURE_2D_KHR, texture2D, nullptr); EGL_GL_TEXTURE_2D_KHR, texture2D, nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_CONTEXT); EXPECT_EGL_ERROR(EGL_BAD_CONTEXT);
...@@ -403,13 +412,13 @@ TEST_P(ImageTest, ValidationImageBase) ...@@ -403,13 +412,13 @@ TEST_P(ImageTest, ValidationImageBase)
// If <dpy> is not the handle of a valid EGLDisplay object, the error EGL_BAD_DISPLAY is // If <dpy> is not the handle of a valid EGLDisplay object, the error EGL_BAD_DISPLAY is
// generated. // generated.
result = eglDestroyImageKHR(reinterpret_cast<EGLDisplay>(0xBAADF00D), image); result = eglDestroyImageKHR(reinterpretHelper<EGLDisplay>(0xBAADF00D), image);
EXPECT_EQ(result, static_cast<EGLBoolean>(EGL_FALSE)); EXPECT_EQ(result, static_cast<EGLBoolean>(EGL_FALSE));
EXPECT_EGL_ERROR(EGL_BAD_DISPLAY); EXPECT_EGL_ERROR(EGL_BAD_DISPLAY);
// If <image> is not a valid EGLImageKHR object created with respect to <dpy>, the error // If <image> is not a valid EGLImageKHR object created with respect to <dpy>, the error
// EGL_BAD_PARAMETER is generated. // EGL_BAD_PARAMETER is generated.
result = eglDestroyImageKHR(display, reinterpret_cast<EGLImageKHR>(0xBAADF00D)); result = eglDestroyImageKHR(display, reinterpretHelper<EGLImageKHR>(0xBAADF00D));
EXPECT_EQ(result, static_cast<EGLBoolean>(EGL_FALSE)); EXPECT_EQ(result, static_cast<EGLBoolean>(EGL_FALSE));
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -463,7 +472,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -463,7 +472,7 @@ TEST_P(ImageTest, ValidationGLImage)
} }
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(textureCube), nullptr); reinterpretHelper<EGLClientBuffer>(textureCube), nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -481,7 +490,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -481,7 +490,7 @@ TEST_P(ImageTest, ValidationGLImage)
EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE, EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE,
}; };
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(incompleteTexture), reinterpretHelper<EGLClientBuffer>(incompleteTexture),
level0Attribute); level0Attribute);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -491,7 +500,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -491,7 +500,7 @@ TEST_P(ImageTest, ValidationGLImage)
// mipmap level 0 is not specified, the error EGL_BAD_PARAMETER is generated. // mipmap level 0 is not specified, the error EGL_BAD_PARAMETER is generated.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(incompleteTexture), nullptr); reinterpretHelper<EGLClientBuffer>(incompleteTexture), nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -511,7 +520,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -511,7 +520,7 @@ TEST_P(ImageTest, ValidationGLImage)
EGL_GL_TEXTURE_LEVEL_KHR, 2, EGL_NONE, EGL_GL_TEXTURE_LEVEL_KHR, 2, EGL_NONE,
}; };
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(incompleteTexture), reinterpretHelper<EGLClientBuffer>(incompleteTexture),
level2Attribute); level2Attribute);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -527,7 +536,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -527,7 +536,7 @@ TEST_P(ImageTest, ValidationGLImage)
// If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is // If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is
// generated. // generated.
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(texture2D), nullptr); reinterpretHelper<EGLClientBuffer>(texture2D), nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
} }
...@@ -555,7 +564,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -555,7 +564,7 @@ TEST_P(ImageTest, ValidationGLImage)
EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE, EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE,
}; };
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR,
reinterpret_cast<EGLClientBuffer>(incompleteTextureCube), reinterpretHelper<EGLClientBuffer>(incompleteTextureCube),
level0Attribute); level0Attribute);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -575,7 +584,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -575,7 +584,7 @@ TEST_P(ImageTest, ValidationGLImage)
// If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is // If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is
// generated. // generated.
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR,
reinterpret_cast<EGLClientBuffer>(textureCube), nullptr); reinterpretHelper<EGLClientBuffer>(textureCube), nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
} }
...@@ -595,7 +604,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -595,7 +604,7 @@ TEST_P(ImageTest, ValidationGLImage)
EGL_GL_TEXTURE_ZOFFSET_KHR, 3, EGL_NONE, EGL_GL_TEXTURE_ZOFFSET_KHR, 3, EGL_NONE,
}; };
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_3D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_3D_KHR,
reinterpret_cast<EGLClientBuffer>(texture3D), zOffset3Parameter); reinterpretHelper<EGLClientBuffer>(texture3D), zOffset3Parameter);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -603,7 +612,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -603,7 +612,7 @@ TEST_P(ImageTest, ValidationGLImage)
EGL_GL_TEXTURE_ZOFFSET_KHR, -1, EGL_NONE, EGL_GL_TEXTURE_ZOFFSET_KHR, -1, EGL_NONE,
}; };
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_3D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_3D_KHR,
reinterpret_cast<EGLClientBuffer>(texture3D), reinterpretHelper<EGLClientBuffer>(texture3D),
zOffsetNegative1Parameter); zOffsetNegative1Parameter);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
...@@ -624,7 +633,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -624,7 +633,7 @@ TEST_P(ImageTest, ValidationGLImage)
image = image =
eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR, eglCreateImageKHR(display, context, EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(texture2D), zOffset0Parameter); reinterpretHelper<EGLClientBuffer>(texture2D), zOffset0Parameter);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
} }
...@@ -640,7 +649,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -640,7 +649,7 @@ TEST_P(ImageTest, ValidationGLImage)
// If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is // If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is
// generated. // generated.
image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_3D_KHR, image = eglCreateImageKHR(display, context, EGL_GL_TEXTURE_3D_KHR,
reinterpret_cast<EGLClientBuffer>(texture3D), nullptr); reinterpretHelper<EGLClientBuffer>(texture3D), nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
} }
...@@ -681,7 +690,7 @@ TEST_P(ImageTest, ValidationGLImage) ...@@ -681,7 +690,7 @@ TEST_P(ImageTest, ValidationGLImage)
// If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is // If <target> is not one of the values in Table aaa, the error EGL_BAD_PARAMETER is
// generated. // generated.
image = eglCreateImageKHR(display, context, EGL_GL_RENDERBUFFER_KHR, image = eglCreateImageKHR(display, context, EGL_GL_RENDERBUFFER_KHR,
reinterpret_cast<EGLClientBuffer>(renderbuffer), nullptr); reinterpretHelper<EGLClientBuffer>(renderbuffer), nullptr);
EXPECT_EQ(image, EGL_NO_IMAGE_KHR); EXPECT_EQ(image, EGL_NO_IMAGE_KHR);
EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER);
} }
...@@ -717,7 +726,7 @@ TEST_P(ImageTest, ValidationGLEGLImage) ...@@ -717,7 +726,7 @@ TEST_P(ImageTest, ValidationGLEGLImage)
GLuint texture; GLuint texture;
glGenTextures(1, &texture); glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, reinterpret_cast<GLeglImageOES>(0xBAADF00D)); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, reinterpretHelper<GLeglImageOES>(0xBAADF00D));
EXPECT_GL_ERROR(GL_INVALID_VALUE); EXPECT_GL_ERROR(GL_INVALID_VALUE);
// <target> must be RENDERBUFFER_OES, and <image> must be the handle of a valid EGLImage // <target> must be RENDERBUFFER_OES, and <image> must be the handle of a valid EGLImage
...@@ -733,7 +742,7 @@ TEST_P(ImageTest, ValidationGLEGLImage) ...@@ -733,7 +742,7 @@ TEST_P(ImageTest, ValidationGLEGLImage)
glGenRenderbuffers(1, &renderbuffer); glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER,
reinterpret_cast<GLeglImageOES>(0xBAADF00D)); reinterpretHelper<GLeglImageOES>(0xBAADF00D));
EXPECT_GL_ERROR(GL_INVALID_VALUE); EXPECT_GL_ERROR(GL_INVALID_VALUE);
// Clean up // Clean up
...@@ -1172,7 +1181,7 @@ TEST_P(ImageTest, MipLevels) ...@@ -1172,7 +1181,7 @@ TEST_P(ImageTest, MipLevels)
}; };
EGLImageKHR image = EGLImageKHR image =
eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_2D_KHR, eglCreateImageKHR(window->getDisplay(), window->getContext(), EGL_GL_TEXTURE_2D_KHR,
reinterpret_cast<EGLClientBuffer>(source), attribs); reinterpretHelper<EGLClientBuffer>(source), attribs);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
// Create a texture and renderbuffer target // Create a texture and renderbuffer target
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment