mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added workarounds for some mobile GPUs which do not support all OpenGL operations when using the BGRA pixel format
This commit is contained in:
parent
8fe027e9ad
commit
27be4007a2
|
@ -462,6 +462,15 @@ void ImageComponent::render(const glm::mat4& parentTrans)
|
||||||
}
|
}
|
||||||
|
|
||||||
mVertices->shaderFlags = mVertices->shaderFlags | Renderer::ShaderFlags::PREMULTIPLIED;
|
mVertices->shaderFlags = mVertices->shaderFlags | Renderer::ShaderFlags::PREMULTIPLIED;
|
||||||
|
|
||||||
|
#if defined(USE_OPENGLES)
|
||||||
|
// This is required as not all mobile GPUs support mipmapping when using the BGRA
|
||||||
|
// pixel format.
|
||||||
|
if (mMipmapping)
|
||||||
|
mVertices->shaderFlags =
|
||||||
|
mVertices->shaderFlags | Renderer::ShaderFlags::CONVERT_PIXEL_FORMAT;
|
||||||
|
#endif
|
||||||
|
|
||||||
mRenderer->drawTriangleStrips(&mVertices[0], 4);
|
mRenderer->drawTriangleStrips(&mVertices[0], 4);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -55,7 +55,8 @@ public:
|
||||||
CLIPPING = 0x00000008,
|
CLIPPING = 0x00000008,
|
||||||
ROTATED = 0x00000010, // Screen rotated 90 or 270 degrees.
|
ROTATED = 0x00000010, // Screen rotated 90 or 270 degrees.
|
||||||
ROUNDED_CORNERS = 0x00000020,
|
ROUNDED_CORNERS = 0x00000020,
|
||||||
ROUNDED_CORNERS_NO_AA = 0x00000040
|
ROUNDED_CORNERS_NO_AA = 0x00000040,
|
||||||
|
CONVERT_PIXEL_FORMAT = 0x00000080
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -439,8 +439,16 @@ unsigned int RendererOpenGL::createTexture(const unsigned int texUnit,
|
||||||
static_cast<GLfloat>(GL_NEAREST)));
|
static_cast<GLfloat>(GL_NEAREST)));
|
||||||
|
|
||||||
#if defined(USE_OPENGLES)
|
#if defined(USE_OPENGLES)
|
||||||
|
if (mipmapping) {
|
||||||
|
// This is required as not all mobile GPUs support mipmapping when using the BGRA
|
||||||
|
// pixel format.
|
||||||
|
GL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE, data));
|
||||||
|
}
|
||||||
|
else {
|
||||||
GL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, textureType, width, height, 0, textureType,
|
GL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, textureType, width, height, 0, textureType,
|
||||||
GL_UNSIGNED_BYTE, data));
|
GL_UNSIGNED_BYTE, data));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
GL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, textureType,
|
GL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, textureType,
|
||||||
GL_UNSIGNED_BYTE, data));
|
GL_UNSIGNED_BYTE, data));
|
||||||
|
@ -644,6 +652,13 @@ void RendererOpenGL::shaderPostprocessing(unsigned int shaders,
|
||||||
vertices->blurStrength = parameters.blurStrength;
|
vertices->blurStrength = parameters.blurStrength;
|
||||||
vertices->shaderFlags = ShaderFlags::POST_PROCESSING | ShaderFlags::PREMULTIPLIED;
|
vertices->shaderFlags = ShaderFlags::POST_PROCESSING | ShaderFlags::PREMULTIPLIED;
|
||||||
|
|
||||||
|
#if defined(USE_OPENGLES)
|
||||||
|
// This is required as not all mobile GPUs support the glReadPixels() function when using
|
||||||
|
// the BGRA pixel format.
|
||||||
|
if (textureRGBA)
|
||||||
|
vertices->shaderFlags |= ShaderFlags::CONVERT_PIXEL_FORMAT;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (screenRotation == 90 || screenRotation == 270)
|
if (screenRotation == 90 || screenRotation == 270)
|
||||||
vertices->shaderFlags |= ShaderFlags::ROTATED;
|
vertices->shaderFlags |= ShaderFlags::ROTATED;
|
||||||
|
|
||||||
|
@ -774,10 +789,10 @@ void RendererOpenGL::shaderPostprocessing(unsigned int shaders,
|
||||||
#if defined(USE_OPENGLES)
|
#if defined(USE_OPENGLES)
|
||||||
if (screenRotation == 0 || screenRotation == 180)
|
if (screenRotation == 0 || screenRotation == 180)
|
||||||
GL_CHECK_ERROR(
|
GL_CHECK_ERROR(
|
||||||
glReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, textureRGBA));
|
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, textureRGBA));
|
||||||
else
|
else
|
||||||
GL_CHECK_ERROR(
|
GL_CHECK_ERROR(
|
||||||
glReadPixels(0, 0, height, width, GL_BGRA_EXT, GL_UNSIGNED_BYTE, textureRGBA));
|
glReadPixels(0, 0, height, width, GL_RGBA, GL_UNSIGNED_BYTE, textureRGBA));
|
||||||
#else
|
#else
|
||||||
if (screenRotation == 0 || screenRotation == 180)
|
if (screenRotation == 0 || screenRotation == 180)
|
||||||
GL_CHECK_ERROR(
|
GL_CHECK_ERROR(
|
||||||
|
|
|
@ -41,6 +41,7 @@ out vec4 FragColor;
|
||||||
// 0x00000010 - Screen rotated 90 or 270 degrees
|
// 0x00000010 - Screen rotated 90 or 270 degrees
|
||||||
// 0x00000020 - Rounded corners
|
// 0x00000020 - Rounded corners
|
||||||
// 0x00000040 - Rounded corners with no anti-aliasing
|
// 0x00000040 - Rounded corners with no anti-aliasing
|
||||||
|
// 0x00000080 - Convert pixel format
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ out vec4 FragColor;
|
||||||
// 0x00000010 - Screen rotated 90 or 270 degrees
|
// 0x00000010 - Screen rotated 90 or 270 degrees
|
||||||
// 0x00000020 - Rounded corners
|
// 0x00000020 - Rounded corners
|
||||||
// 0x00000040 - Rounded corners with no anti-aliasing
|
// 0x00000040 - Rounded corners with no anti-aliasing
|
||||||
|
// 0x00000080 - Convert pixel format
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,6 +59,7 @@ out vec4 FragColor;
|
||||||
// 0x00000010 - Screen rotated 90 or 270 degrees
|
// 0x00000010 - Screen rotated 90 or 270 degrees
|
||||||
// 0x00000020 - Rounded corners
|
// 0x00000020 - Rounded corners
|
||||||
// 0x00000040 - Rounded corners with no anti-aliasing
|
// 0x00000040 - Rounded corners with no anti-aliasing
|
||||||
|
// 0x00000080 - Convert pixel format
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -74,7 +75,14 @@ void main()
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 sampledColor = texture(textureSampler0, texCoord);
|
vec4 sampledColor;
|
||||||
|
|
||||||
|
// Pixel format conversion is sometimes required as not all mobile GPUs support all
|
||||||
|
// OpenGL operations in BGRA format.
|
||||||
|
if (0x0u != (shaderFlags & 0x80u))
|
||||||
|
sampledColor.bgra = texture(textureSampler0, texCoord);
|
||||||
|
else
|
||||||
|
sampledColor = texture(textureSampler0, texCoord);
|
||||||
|
|
||||||
// Rounded corners.
|
// Rounded corners.
|
||||||
if (0x0u != (shaderFlags & 0x20u) || 0x0u != (shaderFlags & 0x40u)) {
|
if (0x0u != (shaderFlags & 0x20u) || 0x0u != (shaderFlags & 0x40u)) {
|
||||||
|
|
|
@ -102,6 +102,7 @@ uniform float OutputGamma;
|
||||||
// 0x00000010 - Screen rotated 90 or 270 degrees
|
// 0x00000010 - Screen rotated 90 or 270 degrees
|
||||||
// 0x00000020 - Rounded corners
|
// 0x00000020 - Rounded corners
|
||||||
// 0x00000040 - Rounded corners with no anti-aliasing
|
// 0x00000040 - Rounded corners with no anti-aliasing
|
||||||
|
// 0x00000080 - Convert pixel format
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue