summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/libANGLE/renderer/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/libANGLE/renderer/gl')
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp274
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/BlitGL.h12
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp10
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/BufferGL.h8
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp7
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/ContextGL.h2
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp15
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/DisplayGL.h7
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp199
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h19
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp10
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h2
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp12
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h6
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp12
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp1
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp36
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/ShaderGL.h4
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp62
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h5
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp7
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h7
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp472
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/TextureGL.h23
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h55
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h3
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm3
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h2
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm5
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h1
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm8
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp4
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp7
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h3
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp9
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h3
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp36
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h10
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp5
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h3
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp105
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h9
-rw-r--r--gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.cpp384
-rw-r--r--gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h86
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp4
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h1
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp50
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h9
48 files changed, 323 insertions, 1694 deletions
diff --git a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp
index b181822ff..0a624dcb1 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.cpp
@@ -30,7 +30,7 @@ gl::Error CheckCompileStatus(const rx::FunctionsGL *functions, GLuint shader)
return gl::Error(GL_OUT_OF_MEMORY, "Failed to compile internal blit shader.");
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error CheckLinkStatus(const rx::FunctionsGL *functions, GLuint program)
@@ -43,7 +43,7 @@ gl::Error CheckLinkStatus(const rx::FunctionsGL *functions, GLuint program)
return gl::Error(GL_OUT_OF_MEMORY, "Failed to link internal blit program.");
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
} // anonymous namespace
@@ -58,9 +58,6 @@ BlitGL::BlitGL(const FunctionsGL *functions,
mWorkarounds(workarounds),
mStateManager(stateManager),
mBlitProgram(0),
- mSourceTextureLocation(-1),
- mScaleLocation(-1),
- mOffsetLocation(-1),
mScratchFBO(0),
mVAO(0)
{
@@ -133,7 +130,11 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture,
const gl::Rectangle &sourceArea,
const gl::Framebuffer *source)
{
- ANGLE_TRY(initializeResources());
+ gl::Error error = initializeResources();
+ if (error.isError())
+ {
+ return error;
+ }
// Blit the framebuffer to the first scratch texture
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);
@@ -145,6 +146,7 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture,
const gl::InternalFormat &internalFormatInfo =
gl::GetInternalFormatInfo(copyTexImageFormat.internalFormat);
+ mStateManager->activeTexture(0);
mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]);
mFunctions->copyTexImage2D(GL_TEXTURE_2D, 0, copyTexImageFormat.internalFormat, sourceArea.x,
sourceArea.y, sourceArea.width, sourceArea.height, 0);
@@ -169,6 +171,7 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture,
mScratchTextures[1], 0);
// Render to the destination texture, sampling from the scratch texture
+ mStateManager->useProgram(mBlitProgram);
mStateManager->setViewport(gl::Rectangle(0, 0, sourceArea.width, sourceArea.height));
mStateManager->setScissorTestEnabled(false);
mStateManager->setDepthRange(0.0f, 1.0f);
@@ -183,192 +186,16 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(GLuint texture,
mStateManager->setRasterizerDiscardEnabled(false);
mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]);
- setScratchTextureParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- setScratchTextureParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- mStateManager->activeTexture(0);
- mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]);
-
- mStateManager->useProgram(mBlitProgram);
- mFunctions->uniform1i(mSourceTextureLocation, 0);
- mFunctions->uniform2f(mScaleLocation, 1.0, 1.0);
- mFunctions->uniform2f(mOffsetLocation, 0.0, 0.0);
-
mStateManager->bindVertexArray(mVAO, 0);
- mFunctions->drawArrays(GL_TRIANGLES, 0, 3);
+ mFunctions->drawArrays(GL_TRIANGLES, 0, 6);
- // Copy the swizzled texture to the destination texture
+ // Finally, copy the swizzled texture to the destination texture
mStateManager->bindTexture(textureType, texture);
mFunctions->copyTexSubImage2D(target, static_cast<GLint>(level), destOffset.x, destOffset.y, 0,
0, sourceArea.width, sourceArea.height);
- // Finally orphan the scratch textures so they can be GCed by the driver.
- orphanScratchTextures();
-
- return gl::NoError();
-}
-
-gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source,
- const gl::Framebuffer *dest,
- const gl::Rectangle &sourceAreaIn,
- const gl::Rectangle &destAreaIn,
- GLenum filter)
-{
- ANGLE_TRY(initializeResources());
-
- // Normalize the destination area to have positive width and height because we will use
- // glViewport to set it, which doesn't allow negative width or height.
- gl::Rectangle sourceArea = sourceAreaIn;
- gl::Rectangle destArea = destAreaIn;
- if (destArea.width < 0)
- {
- destArea.x += destArea.width;
- destArea.width = -destArea.width;
- sourceArea.x += sourceArea.width;
- sourceArea.width = -sourceArea.width;
- }
- if (destArea.height < 0)
- {
- destArea.y += destArea.height;
- destArea.height = -destArea.height;
- sourceArea.y += sourceArea.height;
- sourceArea.height = -sourceArea.height;
- }
-
- const gl::FramebufferAttachment *readAttachment = source->getReadColorbuffer();
- ASSERT(readAttachment->getSamples() <= 1);
-
- // Compute the part of the source that will be sampled.
- gl::Rectangle inBoundsSource;
- {
- gl::Extents sourceSize = readAttachment->getSize();
- gl::Rectangle sourceBounds(0, 0, sourceSize.width, sourceSize.height);
- gl::ClipRectangle(sourceArea, sourceBounds, &inBoundsSource);
-
- // Note that inBoundsSource will have lost the orientation information.
- ASSERT(inBoundsSource.width >= 0 && inBoundsSource.height >= 0);
-
- // Early out when the sampled part is empty as the blit will be a noop,
- // and it prevents a division by zero in later computations.
- if (inBoundsSource.width == 0 || inBoundsSource.height == 0)
- {
- return gl::NoError();
- }
- }
-
- // The blit will be emulated by getting the source of the blit in a texture and sampling it
- // with CLAMP_TO_EDGE. The quad used to draw can trivially compute texture coordinates going
- // from (0, 0) to (1, 1). These texture coordinates will need to be transformed to make two
- // regions match:
- // - The region of the texture representing the source framebuffer region that will be sampled
- // - The region of the drawn quad that corresponds to non-clamped blit, this is the same as the
- // region of the source rectangle that is inside the source attachment.
- //
- // These two regions, T (texture) and D (dest) are defined by their offset in texcoord space
- // in (0, 1)^2 and their size in texcoord space in (-1, 1)^2. The size can be negative to
- // represent the orientation of the blit.
- //
- // Then if P is the quad texcoord, Q the texcoord inside T, and R the texture texcoord:
- // - Q = (P - D.offset) / D.size
- // - Q = (R - T.offset) / T.size
- // Hence R = (P - D.offset) / D.size * T.size - T.offset
- // = P * (T.size / D.size) + (T.offset - D.offset * T.size / D.size)
-
- GLuint textureId;
- gl::Vector2 TOffset;
- gl::Vector2 TSize;
-
- // TODO(cwallez) once texture dirty bits are landed, reuse attached texture instead of using
- // CopyTexImage2D
- {
- textureId = mScratchTextures[0];
- TOffset = gl::Vector2(0.0, 0.0);
- TSize = gl::Vector2(1.0, 1.0);
- if (sourceArea.width < 0)
- {
- TOffset.x = 1.0;
- TSize.x = -1.0;
- }
- if (sourceArea.height < 0)
- {
- TOffset.y = 1.0;
- TSize.y = -1.0;
- }
-
- GLenum format = readAttachment->getFormat().info->internalFormat;
- const FramebufferGL *sourceGL = GetImplAs<FramebufferGL>(source);
- mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceGL->getFramebufferID());
- mStateManager->bindTexture(GL_TEXTURE_2D, textureId);
-
- mFunctions->copyTexImage2D(GL_TEXTURE_2D, 0, format, inBoundsSource.x, inBoundsSource.y,
- inBoundsSource.width, inBoundsSource.height, 0);
- }
-
- // Compute normalized sampled draw quad region
- // It is the same as the region of the source rectangle that is in bounds.
- gl::Vector2 DOffset;
- gl::Vector2 DSize;
- {
- ASSERT(sourceArea.width != 0 && sourceArea.height != 0);
- gl::Rectangle orientedInBounds = inBoundsSource;
- if (sourceArea.width < 0)
- {
- orientedInBounds.x += orientedInBounds.width;
- orientedInBounds.width = -orientedInBounds.width;
- }
- if (sourceArea.height < 0)
- {
- orientedInBounds.y += orientedInBounds.height;
- orientedInBounds.height = -orientedInBounds.height;
- }
-
- DOffset =
- gl::Vector2(static_cast<float>(orientedInBounds.x - sourceArea.x) / sourceArea.width,
- static_cast<float>(orientedInBounds.y - sourceArea.y) / sourceArea.height);
- DSize = gl::Vector2(static_cast<float>(orientedInBounds.width) / sourceArea.width,
- static_cast<float>(orientedInBounds.height) / sourceArea.height);
- }
-
- ASSERT(DSize.x != 0.0 && DSize.y != 0.0);
- gl::Vector2 texCoordScale = gl::Vector2(TSize.x / DSize.x, TSize.y / DSize.y);
- gl::Vector2 texCoordOffset = gl::Vector2(TOffset.x - DOffset.x * texCoordScale.x,
- TOffset.y - DOffset.y * texCoordScale.y);
-
- // Reset all the state except scissor and viewport
- mStateManager->setDepthRange(0.0f, 1.0f);
- mStateManager->setBlendEnabled(false);
- mStateManager->setColorMask(true, true, true, true);
- mStateManager->setSampleAlphaToCoverageEnabled(false);
- mStateManager->setSampleCoverageEnabled(false);
- mStateManager->setDepthTestEnabled(false);
- mStateManager->setStencilTestEnabled(false);
- mStateManager->setCullFaceEnabled(false);
- mStateManager->setPolygonOffsetFillEnabled(false);
- mStateManager->setRasterizerDiscardEnabled(false);
-
- // Use the viewport to draw exactly to the destination rectangle
- mStateManager->setViewport(destArea);
-
- // Set uniforms
- setScratchTextureParameter(GL_TEXTURE_MIN_FILTER, filter);
- setScratchTextureParameter(GL_TEXTURE_MAG_FILTER, filter);
- setScratchTextureParameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- setScratchTextureParameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- mStateManager->activeTexture(0);
- mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[0]);
-
- mStateManager->useProgram(mBlitProgram);
- mFunctions->uniform1i(mSourceTextureLocation, 0);
- mFunctions->uniform2f(mScaleLocation, texCoordScale.x, texCoordScale.y);
- mFunctions->uniform2f(mOffsetLocation, texCoordOffset.x, texCoordOffset.y);
-
- const FramebufferGL *destGL = GetImplAs<FramebufferGL>(dest);
- mStateManager->bindFramebuffer(GL_DRAW_FRAMEBUFFER, destGL->getFramebufferID());
-
- mStateManager->bindVertexArray(mVAO, 0);
- mFunctions->drawArrays(GL_TRIANGLES, 0, 3);
-
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error BlitGL::initializeResources()
@@ -378,38 +205,41 @@ gl::Error BlitGL::initializeResources()
mBlitProgram = mFunctions->createProgram();
// Compile the fragment shader
- // It uses a single, large triangle, to avoid arithmetic precision issues where fragments
- // with the same Y coordinate don't get exactly the same interpolated texcoord Y.
const char *vsSource =
"#version 150\n"
"out vec2 v_texcoord;\n"
- "uniform vec2 u_scale;\n"
- "uniform vec2 u_offset;\n"
"\n"
"void main()\n"
"{\n"
- " const vec2 quad_positions[3] = vec2[3]\n"
+ " const vec2 quad_positions[6] = vec2[6]\n"
" (\n"
- " vec2(-0.5f, 0.0f),\n"
- " vec2( 1.5f, 0.0f),\n"
- " vec2( 0.5f, 2.0f)\n"
+ " vec2(0.0f, 0.0f),\n"
+ " vec2(0.0f, 1.0f),\n"
+ " vec2(1.0f, 0.0f),\n"
+ "\n"
+ " vec2(0.0f, 1.0f),\n"
+ " vec2(1.0f, 0.0f),\n"
+ " vec2(1.0f, 1.0f)\n"
" );\n"
"\n"
" gl_Position = vec4((quad_positions[gl_VertexID] * 2.0) - 1.0, 0.0, 1.0);\n"
- " v_texcoord = quad_positions[gl_VertexID] * u_scale + u_offset;\n"
+ " v_texcoord = quad_positions[gl_VertexID];\n"
"}\n";
GLuint vs = mFunctions->createShader(GL_VERTEX_SHADER);
mFunctions->shaderSource(vs, 1, &vsSource, nullptr);
mFunctions->compileShader(vs);
- ANGLE_TRY(CheckCompileStatus(mFunctions, vs));
+ gl::Error error = CheckCompileStatus(mFunctions, vs);
mFunctions->attachShader(mBlitProgram, vs);
mFunctions->deleteShader(vs);
+ if (error.isError())
+ {
+ return error;
+ }
+
// Compile the vertex shader
- // It discards if the texcoord is outside (0, 1)^2 so the blitframebuffer workaround
- // doesn't write when the point sampled is outside of the source framebuffer.
const char *fsSource =
"#version 150\n"
"uniform sampler2D u_source_texture;\n"
@@ -418,28 +248,32 @@ gl::Error BlitGL::initializeResources()
"\n"
"void main()\n"
"{\n"
- " if (clamp(v_texcoord, vec2(0.0), vec2(1.0)) != v_texcoord)\n"
- " {\n"
- " discard;\n"
- " }\n"
" output_color = texture(u_source_texture, v_texcoord);\n"
"}\n";
GLuint fs = mFunctions->createShader(GL_FRAGMENT_SHADER);
mFunctions->shaderSource(fs, 1, &fsSource, nullptr);
mFunctions->compileShader(fs);
- ANGLE_TRY(CheckCompileStatus(mFunctions, fs));
+ error = CheckCompileStatus(mFunctions, fs);
mFunctions->attachShader(mBlitProgram, fs);
mFunctions->deleteShader(fs);
+ if (error.isError())
+ {
+ return error;
+ }
+
mFunctions->linkProgram(mBlitProgram);
- ANGLE_TRY(CheckLinkStatus(mFunctions, mBlitProgram));
+ error = CheckLinkStatus(mFunctions, mBlitProgram);
+ if (error.isError())
+ {
+ return error;
+ }
- mSourceTextureLocation = mFunctions->getUniformLocation(mBlitProgram, "u_source_texture");
- mScaleLocation = mFunctions->getUniformLocation(mBlitProgram, "u_scale");
- mOffsetLocation = mFunctions->getUniformLocation(mBlitProgram, "u_offset");
+ GLuint textureUniform = mFunctions->getUniformLocation(mBlitProgram, "u_source_texture");
mStateManager->useProgram(mBlitProgram);
+ mFunctions->uniform1i(textureUniform, 0);
}
for (size_t i = 0; i < ArraySize(mScratchTextures); i++)
@@ -447,6 +281,11 @@ gl::Error BlitGL::initializeResources()
if (mScratchTextures[i] == 0)
{
mFunctions->genTextures(1, &mScratchTextures[i]);
+ mStateManager->bindTexture(GL_TEXTURE_2D, mScratchTextures[i]);
+
+ // Use nearest, non-mipmapped sampling with the scratch texture
+ mFunctions->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ mFunctions->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
}
@@ -460,27 +299,6 @@ gl::Error BlitGL::initializeResources()
mFunctions->genVertexArrays(1, &mVAO);
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
-
-void BlitGL::orphanScratchTextures()
-{
- for (auto texture : mScratchTextures)
- {
- mStateManager->bindTexture(GL_TEXTURE_2D, texture);
- mFunctions->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE,
- nullptr);
- }
-}
-
-void BlitGL::setScratchTextureParameter(GLenum param, GLenum value)
-{
- for (auto texture : mScratchTextures)
- {
- mStateManager->bindTexture(GL_TEXTURE_2D, texture);
- mFunctions->texParameteri(GL_TEXTURE_2D, param, value);
- mFunctions->texParameteri(GL_TEXTURE_2D, param, value);
- }
}
-
-} // namespace rx
diff --git a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h
index b306ede29..3ab8319bb 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/BlitGL.h
@@ -52,26 +52,14 @@ class BlitGL : public angle::NonCopyable
const gl::Rectangle &sourceArea,
const gl::Framebuffer *source);
- gl::Error blitColorBufferWithShader(const gl::Framebuffer *source,
- const gl::Framebuffer *dest,
- const gl::Rectangle &sourceArea,
- const gl::Rectangle &destArea,
- GLenum filter);
-
gl::Error initializeResources();
private:
- void orphanScratchTextures();
- void setScratchTextureParameter(GLenum param, GLenum value);
-
const FunctionsGL *mFunctions;
const WorkaroundsGL &mWorkarounds;
StateManagerGL *mStateManager;
GLuint mBlitProgram;
- GLint mSourceTextureLocation;
- GLint mScaleLocation;
- GLint mOffsetLocation;
GLuint mScratchTextures[2];
GLuint mScratchFBO;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp
index a5eda6b30..cd82733d7 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.cpp
@@ -29,10 +29,8 @@ static const GLenum SourceBufferOperationTarget = GL_COPY_READ_BUFFER;
// supported GL versions and doesn't affect any current state when it changes.
static const GLenum DestBufferOperationTarget = GL_ARRAY_BUFFER;
-BufferGL::BufferGL(const gl::BufferState &state,
- const FunctionsGL *functions,
- StateManagerGL *stateManager)
- : BufferImpl(state),
+BufferGL::BufferGL(const FunctionsGL *functions, StateManagerGL *stateManager)
+ : BufferImpl(),
mIsMapped(false),
mMapOffset(0),
mMapSize(0),
@@ -55,7 +53,7 @@ BufferGL::~BufferGL()
mBufferID = 0;
}
-gl::Error BufferGL::setData(GLenum /*target*/, const void *data, size_t size, GLenum usage)
+gl::Error BufferGL::setData(const void* data, size_t size, GLenum usage)
{
mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID);
mFunctions->bufferData(DestBufferOperationTarget, size, data, usage);
@@ -78,7 +76,7 @@ gl::Error BufferGL::setData(GLenum /*target*/, const void *data, size_t size, GL
return gl::Error(GL_NO_ERROR);
}
-gl::Error BufferGL::setSubData(GLenum /*target*/, const void *data, size_t size, size_t offset)
+gl::Error BufferGL::setSubData(const void* data, size_t size, size_t offset)
{
mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID);
mFunctions->bufferSubData(DestBufferOperationTarget, offset, size, data);
diff --git a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h
index d886873fe..e787ec86e 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/BufferGL.h
@@ -21,13 +21,11 @@ class StateManagerGL;
class BufferGL : public BufferImpl
{
public:
- BufferGL(const gl::BufferState &state,
- const FunctionsGL *functions,
- StateManagerGL *stateManager);
+ BufferGL(const FunctionsGL *functions, StateManagerGL *stateManager);
~BufferGL() override;
- gl::Error setData(GLenum target, const void *data, size_t size, GLenum usage) override;
- gl::Error setSubData(GLenum target, const void *data, size_t size, size_t offset) override;
+ gl::Error setData(const void* data, size_t size, GLenum usage) override;
+ gl::Error setSubData(const void* data, size_t size, size_t offset) override;
gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) override;
gl::Error map(GLenum access, GLvoid **mapPtr) override;
gl::Error mapRange(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) override;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp
index 8e378a4be..57dc222b9 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.cpp
@@ -62,8 +62,7 @@ ProgramImpl *ContextGL::createProgram(const gl::ProgramState &data)
FramebufferImpl *ContextGL::createFramebuffer(const gl::FramebufferState &data)
{
- return new FramebufferGL(data, getFunctions(), getStateManager(), getWorkaroundsGL(),
- mRenderer->getBlitter(), false);
+ return new FramebufferGL(data, getFunctions(), getStateManager(), getWorkaroundsGL(), false);
}
TextureImpl *ContextGL::createTexture(const gl::TextureState &state)
@@ -78,9 +77,9 @@ RenderbufferImpl *ContextGL::createRenderbuffer()
getNativeTextureCaps());
}
-BufferImpl *ContextGL::createBuffer(const gl::BufferState &state)
+BufferImpl *ContextGL::createBuffer()
{
- return new BufferGL(state, getFunctions(), getStateManager());
+ return new BufferGL(getFunctions(), getStateManager());
}
VertexArrayImpl *ContextGL::createVertexArray(const gl::VertexArrayState &data)
diff --git a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h
index b3d5e0ee8..798a90436 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/ContextGL.h
@@ -47,7 +47,7 @@ class ContextGL : public ContextImpl
RenderbufferImpl *createRenderbuffer() override;
// Buffer creation
- BufferImpl *createBuffer(const gl::BufferState &state) override;
+ BufferImpl *createBuffer() override;
// Vertex Array creation
VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp
index 30c5c7b4e..e57513326 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.cpp
@@ -22,7 +22,8 @@
namespace rx
{
-DisplayGL::DisplayGL() : mRenderer(nullptr), mCurrentDrawSurface(nullptr)
+DisplayGL::DisplayGL()
+ : mRenderer(nullptr)
{
}
@@ -72,13 +73,6 @@ StreamProducerImpl *DisplayGL::createStreamProducerD3DTextureNV12(
egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context)
{
- // Notify the previous surface (if it still exists) that it is no longer current
- if (mCurrentDrawSurface && mSurfaceSet.find(mCurrentDrawSurface) != mSurfaceSet.end())
- {
- ANGLE_TRY(GetImplAs<SurfaceGL>(mCurrentDrawSurface)->unMakeCurrent());
- }
- mCurrentDrawSurface = nullptr;
-
if (!drawSurface)
{
return egl::Error(EGL_SUCCESS);
@@ -89,10 +83,7 @@ egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface, egl::Surface *readS
glContext->getStateManager()->pauseTransformFeedback(context->getContextState());
SurfaceGL *glDrawSurface = GetImplAs<SurfaceGL>(drawSurface);
- ANGLE_TRY(glDrawSurface->makeCurrent());
- mCurrentDrawSurface = drawSurface;
-
- return egl::Error(EGL_SUCCESS);
+ return glDrawSurface->makeCurrent();
}
gl::Version DisplayGL::getMaxSupportedESVersion() const
diff --git a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h
index a63da6bbc..9f6515886 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/DisplayGL.h
@@ -12,11 +12,6 @@
#include "libANGLE/renderer/DisplayImpl.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
-namespace egl
-{
-class Surface;
-}
-
namespace rx
{
@@ -53,8 +48,6 @@ class DisplayGL : public DisplayImpl
virtual const FunctionsGL *getFunctionsGL() const = 0;
RendererGL *mRenderer;
-
- egl::Surface *mCurrentDrawSurface;
};
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp
index 0a058f8ba..4606114ca 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp
@@ -16,18 +16,14 @@
#include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/ContextImpl.h"
-#include "libANGLE/renderer/gl/BlitGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/RenderbufferGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h"
#include "libANGLE/renderer/gl/TextureGL.h"
#include "libANGLE/renderer/gl/WorkaroundsGL.h"
-#include "libANGLE/renderer/gl/formatutilsgl.h"
-#include "libANGLE/renderer/gl/renderergl_utils.h"
#include "platform/Platform.h"
using namespace gl;
-using angle::CheckedNumeric;
namespace rx
{
@@ -36,13 +32,11 @@ FramebufferGL::FramebufferGL(const FramebufferState &state,
const FunctionsGL *functions,
StateManagerGL *stateManager,
const WorkaroundsGL &workarounds,
- BlitGL *blitter,
bool isDefault)
: FramebufferImpl(state),
mFunctions(functions),
mStateManager(stateManager),
mWorkarounds(workarounds),
- mBlitter(blitter),
mFramebufferID(0),
mIsDefault(isDefault)
{
@@ -56,13 +50,11 @@ FramebufferGL::FramebufferGL(GLuint id,
const FramebufferState &state,
const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
- BlitGL *blitter,
StateManagerGL *stateManager)
: FramebufferImpl(state),
mFunctions(functions),
mStateManager(stateManager),
mWorkarounds(workarounds),
- mBlitter(blitter),
mFramebufferID(id),
mIsDefault(true)
{
@@ -220,14 +212,14 @@ GLenum FramebufferGL::getImplementationColorReadFormat() const
{
const auto *readAttachment = mState.getReadAttachment();
const Format &format = readAttachment->getFormat();
- return format.info->getReadPixelsFormat();
+ return format.info->format;
}
GLenum FramebufferGL::getImplementationColorReadType() const
{
const auto *readAttachment = mState.getReadAttachment();
const Format &format = readAttachment->getFormat();
- return format.info->getReadPixelsType();
+ return format.info->type;
}
Error FramebufferGL::readPixels(ContextImpl *context,
@@ -241,37 +233,10 @@ Error FramebufferGL::readPixels(ContextImpl *context,
const PixelPackState &packState = context->getGLState().getPackState();
mStateManager->setPixelPackState(packState);
- nativegl::ReadPixelsFormat readPixelsFormat =
- nativegl::GetReadPixelsFormat(mFunctions, mWorkarounds, format, type);
- GLenum readFormat = readPixelsFormat.format;
- GLenum readType = readPixelsFormat.type;
-
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, mFramebufferID);
+ mFunctions->readPixels(area.x, area.y, area.width, area.height, format, type, pixels);
- if (mWorkarounds.packOverlappingRowsSeparatelyPackBuffer && packState.pixelBuffer.get() &&
- packState.rowLength != 0 && packState.rowLength < area.width)
- {
- return readPixelsRowByRowWorkaround(area, readFormat, readType, packState, pixels);
- }
-
- if (mWorkarounds.packLastRowSeparatelyForPaddingInclusion)
- {
- gl::Extents size(area.width, area.height, 1);
-
- bool apply;
- ANGLE_TRY_RESULT(ShouldApplyLastRowPaddingWorkaround(size, packState, readFormat, readType,
- false, pixels),
- apply);
-
- if (apply)
- {
- return readPixelsPaddingWorkaround(area, readFormat, readType, packState, pixels);
- }
- }
-
- mFunctions->readPixels(area.x, area.y, area.width, area.height, readFormat, readType, pixels);
-
- return gl::NoError();
+ return Error(GL_NO_ERROR);
}
Error FramebufferGL::blit(ContextImpl *context,
@@ -281,80 +246,15 @@ Error FramebufferGL::blit(ContextImpl *context,
GLenum filter)
{
const Framebuffer *sourceFramebuffer = context->getGLState().getReadFramebuffer();
- const Framebuffer *destFramebuffer = context->getGLState().getDrawFramebuffer();
-
- const FramebufferAttachment *colorReadAttachment = sourceFramebuffer->getReadColorbuffer();
- GLsizei readAttachmentSamples = colorReadAttachment->getSamples();
-
- bool needManualColorBlit = false;
-
- // TODO(cwallez) when the filter is LINEAR and both source and destination are SRGB, we
- // could avoid doing a manual blit.
-
- // Prior to OpenGL 4.4 BlitFramebuffer (section 18.3.1 of GL 4.3 core profile) reads:
- // When values are taken from the read buffer, no linearization is performed, even
- // if the format of the buffer is SRGB.
- // Starting from OpenGL 4.4 (section 18.3.1) it reads:
- // When values are taken from the read buffer, if FRAMEBUFFER_SRGB is enabled and the
- // value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment
- // corresponding to the read buffer is SRGB, the red, green, and blue components are
- // converted from the non-linear sRGB color space according [...].
- {
- bool sourceSRGB = colorReadAttachment != nullptr &&
- colorReadAttachment->getColorEncoding() == GL_SRGB;
- needManualColorBlit =
- needManualColorBlit || (sourceSRGB && mFunctions->isAtMostGL(gl::Version(4, 3)));
- }
-
- // Prior to OpenGL 4.2 BlitFramebuffer (section 4.3.2 of GL 4.1 core profile) reads:
- // Blit operations bypass the fragment pipeline. The only fragment operations which
- // affect a blit are the pixel ownership test and scissor test.
- // Starting from OpenGL 4.2 (section 4.3.2) it reads:
- // When values are written to the draw buffers, blit operations bypass the fragment
- // pipeline. The only fragment operations which affect a blit are the pixel ownership
- // test, the scissor test and sRGB conversion.
- if (!needManualColorBlit)
- {
- bool destSRGB = false;
- for (size_t i = 0; i < destFramebuffer->getDrawbufferStateCount(); ++i)
- {
- const FramebufferAttachment *attachment = destFramebuffer->getDrawBuffer(i);
- if (attachment && attachment->getColorEncoding() == GL_SRGB)
- {
- destSRGB = true;
- break;
- }
- }
-
- needManualColorBlit =
- needManualColorBlit || (destSRGB && mFunctions->isAtMostGL(gl::Version(4, 1)));
- }
-
- // Enable FRAMEBUFFER_SRGB if needed
- mStateManager->setFramebufferSRGBEnabledForFramebuffer(true, this);
-
- GLenum blitMask = mask;
- if (needManualColorBlit && (mask & GL_COLOR_BUFFER_BIT) && readAttachmentSamples <= 1)
- {
- ANGLE_TRY(mBlitter->blitColorBufferWithShader(sourceFramebuffer, destFramebuffer,
- sourceArea, destArea, filter));
- blitMask &= ~GL_COLOR_BUFFER_BIT;
- }
-
- if (blitMask == 0)
- {
- return gl::NoError();
- }
-
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(sourceFramebuffer);
+
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID());
mStateManager->bindFramebuffer(GL_DRAW_FRAMEBUFFER, mFramebufferID);
mFunctions->blitFramebuffer(sourceArea.x, sourceArea.y, sourceArea.x1(), sourceArea.y1(),
- destArea.x, destArea.y, destArea.x1(), destArea.y1(), blitMask,
- filter);
+ destArea.x, destArea.y, destArea.x1(), destArea.y1(), mask, filter);
- return gl::NoError();
+ return Error(GL_NO_ERROR);
}
bool FramebufferGL::checkStatus() const
@@ -420,9 +320,17 @@ GLuint FramebufferGL::getFramebufferID() const
return mFramebufferID;
}
-bool FramebufferGL::isDefault() const
+void FramebufferGL::syncDrawState() const
{
- return mIsDefault;
+ if (mFunctions->standard == STANDARD_GL_DESKTOP)
+ {
+ // Enable SRGB blending for all framebuffers except the default framebuffer on Desktop
+ // OpenGL.
+ // When SRGB blending is enabled, only SRGB capable formats will use it but the default
+ // framebuffer will always use it if it is enabled.
+ // TODO(geofflang): Update this when the framebuffer binding dirty changes, when it exists.
+ mStateManager->setFramebufferSRGBEnabled(!mIsDefault);
+ }
}
void FramebufferGL::syncClearState(GLbitfield mask)
@@ -432,17 +340,17 @@ void FramebufferGL::syncClearState(GLbitfield mask)
if (mWorkarounds.doesSRGBClearsOnLinearFramebufferAttachments &&
(mask & GL_COLOR_BUFFER_BIT) != 0 && !mIsDefault)
{
- bool hasSRGBAttachment = false;
+ bool hasSRBAttachment = false;
for (const auto &attachment : mState.getColorAttachments())
{
if (attachment.isAttached() && attachment.getColorEncoding() == GL_SRGB)
{
- hasSRGBAttachment = true;
+ hasSRBAttachment = true;
break;
}
}
- mStateManager->setFramebufferSRGBEnabled(hasSRGBAttachment);
+ mStateManager->setFramebufferSRGBEnabled(hasSRBAttachment);
}
else
{
@@ -483,71 +391,4 @@ void FramebufferGL::syncClearBufferState(GLenum buffer, GLint drawBuffer)
}
}
}
-gl::Error FramebufferGL::readPixelsRowByRowWorkaround(const gl::Rectangle &area,
- GLenum format,
- GLenum type,
- const gl::PixelPackState &pack,
- GLvoid *pixels) const
-{
- intptr_t offset = reinterpret_cast<intptr_t>(pixels);
-
- const gl::InternalFormat &glFormat =
- gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type));
- GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, pack.alignment, pack.rowLength),
- rowBytes);
- GLuint skipBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes);
-
- gl::PixelPackState directPack;
- directPack.pixelBuffer = pack.pixelBuffer;
- directPack.alignment = 1;
- mStateManager->setPixelPackState(directPack);
- directPack.pixelBuffer.set(nullptr);
-
- offset += skipBytes;
- for (GLint row = 0; row < area.height; ++row)
- {
- mFunctions->readPixels(area.x, row + area.y, area.width, 1, format, type,
- reinterpret_cast<GLvoid *>(offset));
- offset += row * rowBytes;
- }
-
- return gl::NoError();
-}
-
-gl::Error FramebufferGL::readPixelsPaddingWorkaround(const gl::Rectangle &area,
- GLenum format,
- GLenum type,
- const gl::PixelPackState &pack,
- GLvoid *pixels) const
-{
- const gl::InternalFormat &glFormat =
- gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type));
- GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, pack.alignment, pack.rowLength),
- rowBytes);
- GLuint skipBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes);
-
- // Get all by the last row
- if (area.height > 1)
- {
- mFunctions->readPixels(area.x, area.y, area.width, area.height - 1, format, type, pixels);
- }
-
- // Get the last row manually
- gl::PixelPackState directPack;
- directPack.pixelBuffer = pack.pixelBuffer;
- directPack.alignment = 1;
- mStateManager->setPixelPackState(directPack);
- directPack.pixelBuffer.set(nullptr);
-
- intptr_t lastRowOffset =
- reinterpret_cast<intptr_t>(pixels) + skipBytes + (area.height - 1) * rowBytes;
- mFunctions->readPixels(area.x, area.y + area.height - 1, area.width, 1, format, type,
- reinterpret_cast<GLvoid *>(lastRowOffset));
-
- return gl::NoError();
-}
} // namespace rx
diff --git a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h
index a8bcb894c..69d4aef35 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.h
@@ -14,7 +14,6 @@
namespace rx
{
-class BlitGL;
class FunctionsGL;
class StateManagerGL;
struct WorkaroundsGL;
@@ -26,7 +25,6 @@ class FramebufferGL : public FramebufferImpl
const FunctionsGL *functions,
StateManagerGL *stateManager,
const WorkaroundsGL &workarounds,
- BlitGL *blitter,
bool isDefault);
// Constructor called when we need to create a FramebufferGL from an
// existing framebuffer name, for example for the default framebuffer
@@ -35,7 +33,6 @@ class FramebufferGL : public FramebufferImpl
const gl::FramebufferState &data,
const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
- BlitGL *blitter,
StateManagerGL *stateManager);
~FramebufferGL() override;
@@ -80,29 +77,17 @@ class FramebufferGL : public FramebufferImpl
void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) override;
+ void syncDrawState() const;
+
GLuint getFramebufferID() const;
- bool isDefault() const;
private:
void syncClearState(GLbitfield mask);
void syncClearBufferState(GLenum buffer, GLint drawBuffer);
- gl::Error readPixelsRowByRowWorkaround(const gl::Rectangle &area,
- GLenum format,
- GLenum type,
- const gl::PixelPackState &pack,
- GLvoid *pixels) const;
-
- gl::Error readPixelsPaddingWorkaround(const gl::Rectangle &area,
- GLenum format,
- GLenum type,
- const gl::PixelPackState &pack,
- GLvoid *pixels) const;
-
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
const WorkaroundsGL &mWorkarounds;
- BlitGL *mBlitter;
GLuint mFramebufferID;
bool mIsDefault;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp
index fcbf211bc..9c3964e47 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.cpp
@@ -2283,21 +2283,11 @@ bool FunctionsGL::isAtLeastGL(const gl::Version &glVersion) const
return standard == STANDARD_GL_DESKTOP && version >= glVersion;
}
-bool FunctionsGL::isAtMostGL(const gl::Version &glVersion) const
-{
- return standard == STANDARD_GL_DESKTOP && glVersion >= version;
-}
-
bool FunctionsGL::isAtLeastGLES(const gl::Version &glesVersion) const
{
return standard == STANDARD_GL_ES && version >= glesVersion;
}
-bool FunctionsGL::isAtMostGLES(const gl::Version &glesVersion) const
-{
- return standard == STANDARD_GL_ES && glesVersion >= version;
-}
-
bool FunctionsGL::hasExtension(const std::string &ext) const
{
return std::find(extensions.begin(), extensions.end(), ext) != extensions.end();
diff --git a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h
index fa8634e57..e790d96fe 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/FunctionsGL.h
@@ -36,9 +36,7 @@ class FunctionsGL
StandardGL standard;
GLint profile;
bool isAtLeastGL(const gl::Version &glVersion) const;
- bool isAtMostGL(const gl::Version &glVersion) const;
bool isAtLeastGLES(const gl::Version &glesVersion) const;
- bool isAtMostGLES(const gl::Version &glesVersion) const;
// Extensions
std::vector<std::string> extensions;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp
index 88c7df720..2c2c4e7ad 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -62,12 +62,12 @@ LinkResult ProgramGL::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream)
// Verify that the program linked
if (!checkLinkStatus(infoLog))
{
- return false;
+ return LinkResult(false, gl::Error(GL_NO_ERROR));
}
postLink();
- return true;
+ return LinkResult(true, gl::Error(GL_NO_ERROR));
}
gl::Error ProgramGL::save(gl::BinaryOutputStream *stream)
@@ -167,7 +167,7 @@ LinkResult ProgramGL::link(const gl::ContextState &data, gl::InfoLog &infoLog)
// Verify the link
if (!checkLinkStatus(infoLog))
{
- return false;
+ return LinkResult(false, gl::Error(GL_NO_ERROR));
}
if (mWorkarounds.alwaysCallUseProgramAfterLink)
@@ -177,7 +177,7 @@ LinkResult ProgramGL::link(const gl::ContextState &data, gl::InfoLog &infoLog)
postLink();
- return true;
+ return LinkResult(true, gl::Error(GL_NO_ERROR));
}
GLboolean ProgramGL::validate(const gl::Caps & /*caps*/, gl::InfoLog * /*infoLog*/)
@@ -223,7 +223,7 @@ void ProgramGL::setUniform1iv(GLint location, GLsizei count, const GLint *v)
std::vector<GLuint> &boundTextureUnits = mSamplerBindings[samplerIndex].boundTextureUnits;
size_t copyCount =
- std::min<size_t>(count, boundTextureUnits.size() - locationEntry.element);
+ std::max<size_t>(count, boundTextureUnits.size() - locationEntry.element);
std::copy(v, v + copyCount, boundTextureUnits.begin() + locationEntry.element);
}
}
@@ -577,7 +577,7 @@ void ProgramGL::postLink()
for (GLint arrayIndex = 1; arrayIndex < arraySize; ++arrayIndex)
{
PathRenderingFragmentInput arrayElementInput;
- arrayElementInput.name = name + "[" + ToString(arrayIndex) + "]";
+ arrayElementInput.name = name + "[" + std::to_string(arrayIndex) + "]";
arrayElementInput.location = baseLocation + arrayIndex;
mPathRenderingFragmentInputs.push_back(std::move(arrayElementInput));
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h b/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h
index 0ff0faeae..eeb164378 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/RenderbufferGL.h
@@ -38,6 +38,12 @@ class RenderbufferGL : public RenderbufferImpl
GLuint getRenderbufferID() const;
+ gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
+ FramebufferAttachmentRenderTarget **rtOut) override
+ {
+ return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
+ }
+
private:
const FunctionsGL *mFunctions;
const WorkaroundsGL &mWorkarounds;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp
index da1a65687..10c408d93 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/RendererGL.cpp
@@ -122,7 +122,6 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at
#ifndef NDEBUG
if (mHasDebugOutput)
{
- mFunctions->enable(GL_DEBUG_OUTPUT);
mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, nullptr, GL_TRUE);
mFunctions->debugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, nullptr, GL_TRUE);
@@ -138,17 +137,6 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at
{
mSkipDrawCalls = true;
}
-
- if (mWorkarounds.initializeCurrentVertexAttributes)
- {
- GLint maxVertexAttribs = 0;
- mFunctions->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
-
- for (GLint i = 0; i < maxVertexAttribs; ++i)
- {
- mFunctions->vertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 1.0f);
- }
- }
}
RendererGL::~RendererGL()
diff --git a/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp
index 2a6d81583..bffc89ec9 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/SamplerGL.cpp
@@ -62,7 +62,6 @@ void SamplerGL::syncState(const gl::SamplerState &samplerState) const
SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod);
SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode);
SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc);
- SyncSamplerStateMember(mFunctions, mSamplerID, samplerState, mAppliedSamplerState, GL_TEXTURE_SRGB_DECODE_EXT, &gl::SamplerState::sRGBDecode);
// clang-format on
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp
index c9145b00a..400917b35 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.cpp
@@ -36,8 +36,8 @@ ShaderGL::~ShaderGL()
}
}
-ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream,
- std::string * /*sourcePath*/)
+int ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sourceStream,
+ std::string * /*sourcePath*/)
{
// Reset the previous state
if (mShaderID != 0)
@@ -48,43 +48,13 @@ ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sour
*sourceStream << mData.getSource();
- ShCompileOptions options = SH_INIT_GL_POSITION;
+ int options = SH_INIT_GL_POSITION;
if (mWorkarounds.doWhileGLSLCausesGPUHang)
{
options |= SH_REWRITE_DO_WHILE_LOOPS;
}
- if (mWorkarounds.emulateAbsIntFunction)
- {
- options |= SH_EMULATE_ABS_INT_FUNCTION;
- }
-
- if (mWorkarounds.addAndTrueToLoopCondition)
- {
- options |= SH_ADD_AND_TRUE_TO_LOOP_CONDITION;
- }
-
- if (mWorkarounds.emulateIsnanFloat)
- {
- options |= SH_EMULATE_ISNAN_FLOAT_FUNCTION;
- }
-
- if (mWorkarounds.useUnusedBlocksWithStandardOrSharedLayout)
- {
- options |= SH_USE_UNUSED_STANDARD_SHARED_BLOCKS;
- }
-
- if (mWorkarounds.dontRemoveInvariantForFragmentInput)
- {
- options |= SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT;
- }
-
- if (mWorkarounds.removeInvariantAndCentroidForESSL3)
- {
- options |= SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3;
- }
-
return options;
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h
index 0ecd89ce6..f35d2f711 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/ShaderGL.h
@@ -25,8 +25,8 @@ class ShaderGL : public ShaderImpl
~ShaderGL() override;
// ShaderImpl implementation
- ShCompileOptions prepareSourceAndReturnOptions(std::stringstream *sourceStream,
- std::string *sourcePath) override;
+ int prepareSourceAndReturnOptions(std::stringstream *sourceStream,
+ std::string *sourcePath) override;
bool postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) override;
std::string getDebugInfo() const override;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp
index 3a227906f..1cf08b242 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp
@@ -119,7 +119,6 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren
mClearDepth(1.0f),
mClearStencil(0),
mFramebufferSRGBEnabled(false),
- mDitherEnabled(true),
mTextureCubemapSeamlessEnabled(false),
mMultisamplingEnabled(true),
mSampleAlphaToOneEnabled(false),
@@ -743,21 +742,18 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::ContextState &data)
GLenum textureType = samplerUniform.textureType;
for (GLuint textureUnitIndex : samplerUniform.boundTextureUnits)
{
- gl::Texture *texture = state.getSamplerTexture(textureUnitIndex, textureType);
+ const gl::Texture *texture = state.getSamplerTexture(textureUnitIndex, textureType);
if (texture != nullptr)
{
const TextureGL *textureGL = GetImplAs<TextureGL>(texture);
- if (mTextures[textureType][textureUnitIndex] != textureGL->getTextureID() ||
- texture->hasAnyDirtyBit() || textureGL->hasAnyDirtyBit())
+ if (mTextures[textureType][textureUnitIndex] != textureGL->getTextureID())
{
activeTexture(textureUnitIndex);
bindTexture(textureType, textureGL->getTextureID());
-
- // TODO: Call this from the gl:: layer once other backends use dirty bits for
- // texture state.
- texture->syncImplState();
}
+
+ textureGL->syncState(textureUnitIndex);
}
else
{
@@ -785,6 +781,7 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::ContextState &data)
const gl::Framebuffer *framebuffer = state.getDrawFramebuffer();
const FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer);
bindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferGL->getFramebufferID());
+ framebufferGL->syncDrawState();
// Seamless cubemaps are required for ES3 and higher contexts.
setTextureCubemapSeamlessEnabled(data.getClientMajorVersion() >= 3);
@@ -1319,13 +1316,6 @@ void StateManagerGL::setClearStencil(GLint clearStencil)
void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBits &glDirtyBits)
{
- // The the current framebuffer binding sometimes requires resetting the srgb blending
- if (glDirtyBits[gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING] &&
- mFunctions->standard == STANDARD_GL_DESKTOP)
- {
- mLocalDirtyBits.set(gl::State::DIRTY_BIT_FRAMEBUFFER_SRGB);
- }
-
const auto &glAndLocalDirtyBits = (glDirtyBits | mLocalDirtyBits);
if (!glAndLocalDirtyBits.any())
@@ -1523,7 +1513,7 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit
setPixelPackState(state.getPackState());
break;
case gl::State::DIRTY_BIT_DITHER_ENABLED:
- setDitherEnabled(state.isDitherEnabled());
+ // TODO(jmadill): implement this
break;
case gl::State::DIRTY_BIT_GENERATE_MIPMAP_HINT:
// TODO(jmadill): implement this
@@ -1566,11 +1556,6 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit
setPathRenderingStencilState(state.getPathStencilFunc(), state.getPathStencilRef(),
state.getPathStencilMask());
break;
- case gl::State::DIRTY_BIT_FRAMEBUFFER_SRGB:
- setFramebufferSRGBEnabledForFramebuffer(
- state.getFramebufferSRGB(),
- GetImplAs<FramebufferGL>(state.getDrawFramebuffer()));
- break;
default:
{
ASSERT(dirtyBit >= gl::State::DIRTY_BIT_CURRENT_VALUE_0 &&
@@ -1600,41 +1585,6 @@ void StateManagerGL::setFramebufferSRGBEnabled(bool enabled)
{
mFunctions->disable(GL_FRAMEBUFFER_SRGB);
}
- mLocalDirtyBits.set(gl::State::DIRTY_BIT_FRAMEBUFFER_SRGB);
- }
-}
-
-void StateManagerGL::setFramebufferSRGBEnabledForFramebuffer(bool enabled,
- const FramebufferGL *framebuffer)
-{
- if (mFunctions->standard == STANDARD_GL_DESKTOP && framebuffer->isDefault())
- {
- // Obey the framebuffer sRGB state for blending on all framebuffers except the default
- // framebuffer on Desktop OpenGL.
- // When SRGB blending is enabled, only SRGB capable formats will use it but the default
- // framebuffer will always use it if it is enabled.
- // TODO(geofflang): Update this when the framebuffer binding dirty changes, when it exists.
- setFramebufferSRGBEnabled(false);
- }
- else
- {
- setFramebufferSRGBEnabled(enabled);
- }
-}
-
-void StateManagerGL::setDitherEnabled(bool enabled)
-{
- if (mDitherEnabled != enabled)
- {
- mDitherEnabled = enabled;
- if (mDitherEnabled)
- {
- mFunctions->enable(GL_DITHER);
- }
- else
- {
- mFunctions->disable(GL_DITHER);
- }
}
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h
index 3c8c5389f..f7ec64772 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/StateManagerGL.h
@@ -27,7 +27,6 @@ class State;
namespace rx
{
-class FramebufferGL;
class FunctionsGL;
class TransformFeedbackGL;
class QueryGL;
@@ -124,9 +123,6 @@ class StateManagerGL final : angle::NonCopyable
GLuint packBuffer);
void setFramebufferSRGBEnabled(bool enabled);
- void setFramebufferSRGBEnabledForFramebuffer(bool enabled, const FramebufferGL *framebuffer);
-
- void setDitherEnabled(bool enabled);
void setMultisamplingStateEnabled(bool enabled);
void setSampleAlphaToOneStateEnabled(bool enabled);
@@ -268,7 +264,6 @@ class StateManagerGL final : angle::NonCopyable
GLint mClearStencil;
bool mFramebufferSRGBEnabled;
- bool mDitherEnabled;
bool mTextureCubemapSeamlessEnabled;
bool mMultisamplingEnabled;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp
index a1f0abba7..fcdddebe0 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp
@@ -26,11 +26,6 @@ SurfaceGL::~SurfaceGL()
FramebufferImpl *SurfaceGL::createDefaultFramebuffer(const gl::FramebufferState &data)
{
return new FramebufferGL(data, mRenderer->getFunctions(), mRenderer->getStateManager(),
- mRenderer->getWorkarounds(), mRenderer->getBlitter(), true);
-}
-
-egl::Error SurfaceGL::unMakeCurrent()
-{
- return egl::Error(EGL_SUCCESS);
+ mRenderer->getWorkarounds(), true);
}
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h
index 681c365d2..329b562b9 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/SurfaceGL.h
@@ -22,10 +22,15 @@ class SurfaceGL : public SurfaceImpl
SurfaceGL(const egl::SurfaceState &state, RendererGL *renderer);
~SurfaceGL() override;
+ gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
+ FramebufferAttachmentRenderTarget **rtOut) override
+ {
+ return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
+ }
+
FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override;
virtual egl::Error makeCurrent() = 0;
- virtual egl::Error unMakeCurrent();
private:
RendererGL *mRenderer;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp
index 589580505..8b78bdc01 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp
@@ -8,7 +8,6 @@
#include "libANGLE/renderer/gl/TextureGL.h"
-#include "common/BitSetIterator.h"
#include "common/debug.h"
#include "common/utilities.h"
#include "libANGLE/State.h"
@@ -21,27 +20,21 @@
#include "libANGLE/renderer/gl/StateManagerGL.h"
#include "libANGLE/renderer/gl/WorkaroundsGL.h"
#include "libANGLE/renderer/gl/formatutilsgl.h"
-#include "libANGLE/renderer/gl/renderergl_utils.h"
-
-using angle::CheckedNumeric;
namespace rx
{
-namespace
-{
-
-bool UseTexImage2D(GLenum textureType)
+static bool UseTexImage2D(GLenum textureType)
{
return textureType == GL_TEXTURE_2D || textureType == GL_TEXTURE_CUBE_MAP;
}
-bool UseTexImage3D(GLenum textureType)
+static bool UseTexImage3D(GLenum textureType)
{
return textureType == GL_TEXTURE_2D_ARRAY || textureType == GL_TEXTURE_3D;
}
-bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget)
+static bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget)
{
if (textureType != GL_TEXTURE_CUBE_MAP)
{
@@ -53,13 +46,13 @@ bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget)
}
}
-bool IsLUMAFormat(GLenum format)
+static bool IsLUMAFormat(GLenum format)
{
return format == GL_LUMINANCE || format == GL_ALPHA || format == GL_LUMINANCE_ALPHA;
}
-LUMAWorkaroundGL GetLUMAWorkaroundInfo(const gl::InternalFormat &originalFormatInfo,
- GLenum destinationFormat)
+static LUMAWorkaroundGL GetLUMAWorkaroundInfo(const gl::InternalFormat &originalFormatInfo,
+ GLenum destinationFormat)
{
if (IsLUMAFormat(originalFormatInfo.format))
{
@@ -74,35 +67,23 @@ LUMAWorkaroundGL GetLUMAWorkaroundInfo(const gl::InternalFormat &originalFormatI
}
}
-bool IsDepthStencilFormat(GLenum format)
+static bool IsDepthStencilFormat(GLenum format)
{
return format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL;
}
-bool GetDepthStencilWorkaround(const gl::InternalFormat &originalFormatInfo)
+static bool GetDepthStencilWorkaround(const gl::InternalFormat &originalFormatInfo)
{
return IsDepthStencilFormat(originalFormatInfo.format);
}
-LevelInfoGL GetLevelInfo(GLenum originalFormat, GLenum destinationFormat)
+static LevelInfoGL GetLevelInfo(GLenum originalFormat, GLenum destinationFormat)
{
const gl::InternalFormat &originalFormatInfo = gl::GetInternalFormatInfo(originalFormat);
return LevelInfoGL(originalFormat, GetDepthStencilWorkaround(originalFormatInfo),
GetLUMAWorkaroundInfo(originalFormatInfo, destinationFormat));
}
-gl::Texture::DirtyBits GetLevelWorkaroundDirtyBits()
-{
- gl::Texture::DirtyBits bits;
- bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_RED);
- bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_GREEN);
- bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_BLUE);
- bits.set(gl::Texture::DIRTY_BIT_SWIZZLE_ALPHA);
- return bits;
-}
-
-} // anonymous namespace
-
LUMAWorkaroundGL::LUMAWorkaroundGL() : LUMAWorkaroundGL(false, GL_NONE)
{
}
@@ -153,14 +134,8 @@ TextureGL::~TextureGL()
mTextureID = 0;
}
-gl::Error TextureGL::setImage(GLenum target,
- size_t level,
- GLenum internalFormat,
- const gl::Extents &size,
- GLenum format,
- GLenum type,
- const gl::PixelUnpackState &unpack,
- const uint8_t *pixels)
+gl::Error TextureGL::setImage(GLenum target, size_t level, GLenum internalFormat, const gl::Extents &size, GLenum format, GLenum type,
+ const gl::PixelUnpackState &unpack, const uint8_t *pixels)
{
if (mWorkarounds.unpackOverlappingRowsSeparatelyUnpackBuffer && unpack.pixelBuffer.get() &&
unpack.rowLength != 0 && unpack.rowLength < size.width)
@@ -168,41 +143,13 @@ gl::Error TextureGL::setImage(GLenum target,
// The rows overlap in unpack memory. Upload the texture row by row to work around
// driver bug.
reserveTexImageToBeFilled(target, level, internalFormat, size, format, type);
-
- if (size.width == 0 || size.height == 0 || size.depth == 0)
- {
- return gl::NoError();
- }
-
gl::Box area(0, 0, 0, size.width, size.height, size.depth);
- return setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels);
+ ANGLE_TRY(setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels));
}
-
- if (mWorkarounds.unpackLastRowSeparatelyForPaddingInclusion)
+ else
{
- bool apply;
- ANGLE_TRY_RESULT(ShouldApplyLastRowPaddingWorkaround(size, unpack, format, type,
- UseTexImage3D(mState.mTarget), pixels),
- apply);
-
- // The driver will think the pixel buffer doesn't have enough data, work around this bug
- // by uploading the last row (and last level if 3D) separately.
- if (apply)
- {
- reserveTexImageToBeFilled(target, level, internalFormat, size, format, type);
-
- if (size.width == 0 || size.height == 0 || size.depth == 0)
- {
- return gl::NoError();
- }
-
- gl::Box area(0, 0, 0, size.width, size.height, size.depth);
- return setSubImagePaddingWorkaround(target, level, area, format, type, unpack, pixels);
- }
+ setImageHelper(target, level, internalFormat, size, format, type, pixels);
}
-
- setImageHelper(target, level, internalFormat, size, format, type, pixels);
-
return gl::NoError();
}
@@ -214,6 +161,7 @@ void TextureGL::setImageHelper(GLenum target,
GLenum type,
const uint8_t *pixels)
{
+ UNUSED_ASSERTION_VARIABLE(&CompatibleTextureTarget); // Reference this function to avoid warnings.
ASSERT(CompatibleTextureTarget(mState.mTarget, target));
nativegl::TexImageFormat texImageFormat =
@@ -239,7 +187,7 @@ void TextureGL::setImageHelper(GLenum target,
UNREACHABLE();
}
- setLevelInfo(level, 1, GetLevelInfo(internalFormat, texImageFormat.internalFormat));
+ mLevelInfo[level] = GetLevelInfo(internalFormat, texImageFormat.internalFormat);
}
void TextureGL::reserveTexImageToBeFilled(GLenum target,
@@ -264,47 +212,32 @@ gl::Error TextureGL::setSubImage(GLenum target, size_t level, const gl::Box &are
nativegl::TexSubImageFormat texSubImageFormat =
nativegl::GetTexSubImageFormat(mFunctions, mWorkarounds, format, type);
- ASSERT(mLevelInfo[level].lumaWorkaround.enabled ==
- GetLevelInfo(format, texSubImageFormat.format).lumaWorkaround.enabled);
-
mStateManager->bindTexture(mState.mTarget, mTextureID);
if (mWorkarounds.unpackOverlappingRowsSeparatelyUnpackBuffer && unpack.pixelBuffer.get() &&
unpack.rowLength != 0 && unpack.rowLength < area.width)
{
- return setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels);
- }
-
- if (mWorkarounds.unpackLastRowSeparatelyForPaddingInclusion)
- {
- gl::Extents size(area.width, area.height, area.depth);
-
- bool apply;
- ANGLE_TRY_RESULT(ShouldApplyLastRowPaddingWorkaround(size, unpack, format, type,
- UseTexImage3D(mState.mTarget), pixels),
- apply);
-
- // The driver will think the pixel buffer doesn't have enough data, work around this bug
- // by uploading the last row (and last level if 3D) separately.
- if (apply)
- {
- return setSubImagePaddingWorkaround(target, level, area, format, type, unpack, pixels);
- }
+ ANGLE_TRY(setSubImageRowByRowWorkaround(target, level, area, format, type, unpack, pixels));
}
-
- if (UseTexImage2D(mState.mTarget))
+ else if (UseTexImage2D(mState.mTarget))
{
ASSERT(area.z == 0 && area.depth == 1);
mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x, area.y, area.width,
area.height, texSubImageFormat.format, texSubImageFormat.type,
pixels);
}
- else
+ else if (UseTexImage3D(mState.mTarget))
{
- ASSERT(UseTexImage3D(mState.mTarget));
mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y, area.z,
area.width, area.height, area.depth, texSubImageFormat.format,
texSubImageFormat.type, pixels);
}
+ else
+ {
+ UNREACHABLE();
+ }
+
+ ASSERT(mLevelInfo[level].lumaWorkaround.enabled ==
+ GetLevelInfo(format, texSubImageFormat.format).lumaWorkaround.enabled);
return gl::Error(GL_NO_ERROR);
}
@@ -317,24 +250,26 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels)
{
- gl::PixelUnpackState directUnpack;
- directUnpack.pixelBuffer = unpack.pixelBuffer;
- directUnpack.alignment = 1;
- mStateManager->setPixelUnpackState(directUnpack);
- directUnpack.pixelBuffer.set(nullptr);
-
- const gl::InternalFormat &glFormat =
- gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type));
- GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength),
- rowBytes);
+ gl::PixelUnpackState unpackToUse;
+ unpackToUse.pixelBuffer = unpack.pixelBuffer;
+ mStateManager->setPixelUnpackState(unpackToUse);
+ unpackToUse.pixelBuffer.set(nullptr);
+ const gl::Format &glFormat = mState.getImageDesc(mState.mTarget, level).format;
+ GLuint rowBytes = 0;
+ ANGLE_TRY_RESULT(
+ glFormat.info->computeRowPitch(GL_NONE, area.width, unpack.alignment, unpack.rowLength),
+ rowBytes);
GLuint imageBytes = 0;
- ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
- imageBytes);
+ ANGLE_TRY_RESULT(
+ glFormat.info->computeDepthPitch(GL_NONE, area.width, area.height, unpack.alignment,
+ unpack.rowLength, unpack.imageHeight),
+ imageBytes);
bool useTexImage3D = UseTexImage3D(mState.mTarget);
GLuint skipBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D),
- skipBytes);
+ ANGLE_TRY_RESULT(
+ glFormat.info->computeSkipBytes(rowBytes, imageBytes, unpack.skipImages, unpack.skipRows,
+ unpack.skipPixels, useTexImage3D),
+ skipBytes);
const uint8_t *pixelsWithSkip = pixels + skipBytes;
if (useTexImage3D)
@@ -352,9 +287,8 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target,
}
}
}
- else
+ else if (UseTexImage2D(mState.mTarget))
{
- ASSERT(UseTexImage2D(mState.mTarget));
for (GLint row = 0; row < area.height; ++row)
{
GLint byteOffset = row * rowBytes;
@@ -363,89 +297,10 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target,
area.width, 1, format, type, rowPixels);
}
}
- return gl::NoError();
-}
-
-gl::Error TextureGL::setSubImagePaddingWorkaround(GLenum target,
- size_t level,
- const gl::Box &area,
- GLenum format,
- GLenum type,
- const gl::PixelUnpackState &unpack,
- const uint8_t *pixels)
-{
- const gl::InternalFormat &glFormat =
- gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type));
- GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength),
- rowBytes);
- GLuint imageBytes = 0;
- ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
- imageBytes);
- bool useTexImage3D = UseTexImage3D(mState.mTarget);
- GLuint skipBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D),
- skipBytes);
-
- gl::PixelUnpackState directUnpack;
- directUnpack.pixelBuffer = unpack.pixelBuffer;
- directUnpack.alignment = 1;
-
- if (useTexImage3D)
- {
- // Upload all but the last slice
- if (area.depth > 1)
- {
- mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y, area.z,
- area.width, area.height, area.depth - 1, format, type,
- pixels);
- }
-
- // Upload the last slice but its last row
- if (area.height > 1)
- {
- // Do not include skipBytes in the last image pixel start offset as it will be done by
- // the driver
- GLint lastImageOffset = (area.depth - 1) * imageBytes;
- const GLubyte *lastImagePixels = pixels + lastImageOffset;
- mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y,
- area.z + area.depth - 1, area.width, area.height - 1, 1,
- format, type, lastImagePixels);
- }
-
- // Upload the last row of the last slice "manually"
- mStateManager->setPixelUnpackState(directUnpack);
-
- GLint lastRowOffset =
- skipBytes + (area.depth - 1) * imageBytes + (area.height - 1) * rowBytes;
- const GLubyte *lastRowPixels = pixels + lastRowOffset;
- mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x,
- area.y + area.height - 1, area.z + area.depth - 1, area.width, 1,
- 1, format, type, lastRowPixels);
- }
else
{
- ASSERT(UseTexImage2D(mState.mTarget));
-
- // Upload all but the last row
- if (area.height > 1)
- {
- mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x, area.y, area.width,
- area.height - 1, format, type, pixels);
- }
-
- // Upload the last row "manually"
- mStateManager->setPixelUnpackState(directUnpack);
-
- GLint lastRowOffset = skipBytes + (area.height - 1) * rowBytes;
- const GLubyte *lastRowPixels = pixels + lastRowOffset;
- mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x,
- area.y + area.height - 1, area.width, 1, format, type,
- lastRowPixels);
+ UNREACHABLE();
}
-
- directUnpack.pixelBuffer.set(nullptr);
-
return gl::NoError();
}
@@ -476,7 +331,7 @@ gl::Error TextureGL::setCompressedImage(GLenum target, size_t level, GLenum inte
UNREACHABLE();
}
- setLevelInfo(level, 1, GetLevelInfo(internalFormat, compressedTexImageFormat.internalFormat));
+ mLevelInfo[level] = GetLevelInfo(internalFormat, compressedTexImageFormat.internalFormat);
ASSERT(!mLevelInfo[level].lumaWorkaround.enabled);
return gl::Error(GL_NO_ERROR);
@@ -553,7 +408,7 @@ gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle
}
}
- setLevelInfo(level, 1, levelInfo);
+ mLevelInfo[level] = levelInfo;
return gl::Error(GL_NO_ERROR);
}
@@ -639,7 +494,8 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor
if (internalFormatInfo.compressed)
{
GLuint dataSize = 0;
- ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize(levelSize),
+ ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize(
+ GL_UNSIGNED_BYTE, levelSize),
dataSize);
mFunctions->compressedTexImage2D(target, static_cast<GLint>(level),
texStorageFormat.internalFormat,
@@ -662,7 +518,7 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor
{
GLuint dataSize = 0;
ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize(
- levelSize),
+ GL_UNSIGNED_BYTE, levelSize),
dataSize);
mFunctions->compressedTexImage2D(
face, static_cast<GLint>(level), texStorageFormat.internalFormat,
@@ -713,7 +569,7 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor
{
GLuint dataSize = 0;
ANGLE_TRY_RESULT(
- internalFormatInfo.computeCompressedImageSize(levelSize),
+ internalFormatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, levelSize),
dataSize);
mFunctions->compressedTexImage3D(target, i, texStorageFormat.internalFormat,
levelSize.width, levelSize.height,
@@ -735,7 +591,11 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor
UNREACHABLE();
}
- setLevelInfo(0, levels, GetLevelInfo(internalFormat, texStorageFormat.internalFormat));
+ LevelInfoGL levelInfo = GetLevelInfo(internalFormat, texStorageFormat.internalFormat);
+ for (size_t level = 0; level < mLevelInfo.size(); level++)
+ {
+ mLevelInfo[level] = levelInfo;
+ }
return gl::Error(GL_NO_ERROR);
}
@@ -750,6 +610,8 @@ gl::Error TextureGL::setImageExternal(GLenum target,
gl::Error TextureGL::generateMipmap()
{
+ // Need to sync base level and max level to driver before calling GenerateMipmap.
+ syncState(0);
mStateManager->bindTexture(mState.mTarget, mTextureID);
mFunctions->generateMipmap(mState.mTarget);
@@ -758,7 +620,10 @@ gl::Error TextureGL::generateMipmap()
ASSERT(maxLevel < mLevelInfo.size());
- setLevelInfo(effectiveBaseLevel, maxLevel - effectiveBaseLevel, mLevelInfo[effectiveBaseLevel]);
+ for (GLuint level = effectiveBaseLevel; level <= maxLevel; level++)
+ {
+ mLevelInfo[level] = mLevelInfo[effectiveBaseLevel];
+ }
return gl::Error(GL_NO_ERROR);
}
@@ -770,7 +635,7 @@ void TextureGL::bindTexImage(egl::Surface *surface)
// Make sure this texture is bound
mStateManager->bindTexture(mState.mTarget, mTextureID);
- setLevelInfo(0, 1, LevelInfoGL());
+ mLevelInfo[0] = LevelInfoGL();
}
void TextureGL::releaseTexImage()
@@ -796,121 +661,58 @@ gl::Error TextureGL::setEGLImageTarget(GLenum target, egl::Image *image)
return gl::Error(GL_INVALID_OPERATION);
}
-void TextureGL::syncState(const gl::Texture::DirtyBits &dirtyBits)
+template <typename T, typename ApplyTextureFuncType>
+static inline void SyncSamplerStateMember(const FunctionsGL *functions,
+ ApplyTextureFuncType applyTextureFunc,
+ const gl::SamplerState &newState,
+ gl::SamplerState &curState,
+ GLenum textureType,
+ GLenum name,
+ T(gl::SamplerState::*samplerMember))
{
- if (dirtyBits.none() && mLocalDirtyBits.none())
- {
- return;
- }
-
- mStateManager->bindTexture(mState.mTarget, mTextureID);
-
- if (dirtyBits[gl::Texture::DIRTY_BIT_BASE_LEVEL] || dirtyBits[gl::Texture::DIRTY_BIT_MAX_LEVEL])
+ if (curState.*samplerMember != newState.*samplerMember)
{
- // Don't know if the previous base level was using any workarounds, always re-sync the
- // workaround dirty bits
- mLocalDirtyBits |= GetLevelWorkaroundDirtyBits();
+ applyTextureFunc();
+ curState.*samplerMember = newState.*samplerMember;
+ functions->texParameterf(textureType, name, static_cast<GLfloat>(curState.*samplerMember));
}
-
- for (auto dirtyBit : angle::IterateBitSet(dirtyBits | mLocalDirtyBits))
- {
- switch (dirtyBit)
- {
- case gl::Texture::DIRTY_BIT_MIN_FILTER:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MIN_FILTER,
- mState.getSamplerState().minFilter);
- break;
- case gl::Texture::DIRTY_BIT_MAG_FILTER:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MAG_FILTER,
- mState.getSamplerState().magFilter);
- break;
- case gl::Texture::DIRTY_BIT_WRAP_S:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_WRAP_S,
- mState.getSamplerState().wrapS);
- break;
- case gl::Texture::DIRTY_BIT_WRAP_T:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_WRAP_T,
- mState.getSamplerState().wrapT);
- break;
- case gl::Texture::DIRTY_BIT_WRAP_R:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_WRAP_R,
- mState.getSamplerState().wrapR);
- break;
- case gl::Texture::DIRTY_BIT_MAX_ANISOTROPY:
- mFunctions->texParameterf(mState.mTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT,
- mState.getSamplerState().maxAnisotropy);
- break;
- case gl::Texture::DIRTY_BIT_MIN_LOD:
- mFunctions->texParameterf(mState.mTarget, GL_TEXTURE_MIN_LOD,
- mState.getSamplerState().minLod);
- break;
- case gl::Texture::DIRTY_BIT_MAX_LOD:
- mFunctions->texParameterf(mState.mTarget, GL_TEXTURE_MAX_LOD,
- mState.getSamplerState().maxLod);
- break;
- case gl::Texture::DIRTY_BIT_COMPARE_MODE:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_COMPARE_MODE,
- mState.getSamplerState().compareMode);
- break;
- case gl::Texture::DIRTY_BIT_COMPARE_FUNC:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_COMPARE_FUNC,
- mState.getSamplerState().compareFunc);
- break;
- case gl::Texture::DIRTY_BIT_SRGB_DECODE:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_SRGB_DECODE_EXT,
- mState.getSamplerState().sRGBDecode);
- break;
-
- // Texture state
- case gl::Texture::DIRTY_BIT_SWIZZLE_RED:
- syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_R,
- mState.getSwizzleState().swizzleRed);
- break;
- case gl::Texture::DIRTY_BIT_SWIZZLE_GREEN:
- syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_G,
- mState.getSwizzleState().swizzleGreen);
- break;
- case gl::Texture::DIRTY_BIT_SWIZZLE_BLUE:
- syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_B,
- mState.getSwizzleState().swizzleBlue);
- break;
- case gl::Texture::DIRTY_BIT_SWIZZLE_ALPHA:
- syncTextureStateSwizzle(mFunctions, GL_TEXTURE_SWIZZLE_A,
- mState.getSwizzleState().swizzleAlpha);
- break;
- case gl::Texture::DIRTY_BIT_BASE_LEVEL:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_BASE_LEVEL,
- mState.getEffectiveBaseLevel());
- break;
- case gl::Texture::DIRTY_BIT_MAX_LEVEL:
- mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MAX_LEVEL,
- mState.getEffectiveMaxLevel());
- break;
- case gl::Texture::DIRTY_BIT_USAGE:
- break;
-
- default:
- UNREACHABLE();
- }
- }
-
- mLocalDirtyBits.reset();
}
-bool TextureGL::hasAnyDirtyBit() const
+template <typename T, typename ApplyTextureFuncType>
+static inline void SyncTextureStateMember(const FunctionsGL *functions,
+ ApplyTextureFuncType applyTextureFunc,
+ const gl::TextureState &newState,
+ gl::TextureState &curState,
+ GLenum textureType,
+ GLenum name,
+ T(gl::TextureState::*stateMember))
{
- return mLocalDirtyBits.any();
+ if (curState.*stateMember != newState.*stateMember)
+ {
+ applyTextureFunc();
+ curState.*stateMember = newState.*stateMember;
+ functions->texParameterf(textureType, name, static_cast<GLfloat>(curState.*stateMember));
+ }
}
-void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum name, GLenum value)
+template <typename T, typename ApplyTextureFuncType>
+static inline void SyncTextureStateSwizzle(const FunctionsGL *functions,
+ ApplyTextureFuncType applyTextureFunc,
+ const LevelInfoGL &levelInfo,
+ const gl::SwizzleState &newState,
+ gl::SwizzleState &curState,
+ GLenum textureType,
+ GLenum name,
+ T(gl::SwizzleState::*stateMember))
{
- const LevelInfoGL &levelInfo = mLevelInfo[mState.getEffectiveBaseLevel()];
- GLenum resultSwizzle = value;
+ GLenum resultSwizzle = newState.*stateMember;
if (levelInfo.lumaWorkaround.enabled || levelInfo.depthStencilWorkaround)
{
if (levelInfo.lumaWorkaround.enabled)
{
- switch (value)
+ UNUSED_ASSERTION_VARIABLE(levelInfo.lumaWorkaround.workaroundFormat);
+
+ switch (newState.*stateMember)
{
case GL_RED:
case GL_GREEN:
@@ -964,7 +766,7 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam
case GL_ZERO:
case GL_ONE:
// Don't modify the swizzle state when requesting ZERO or ONE.
- resultSwizzle = value;
+ resultSwizzle = newState.*stateMember;
break;
default:
@@ -974,11 +776,11 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam
}
else if (levelInfo.depthStencilWorkaround)
{
- switch (value)
+ switch (newState.*stateMember)
{
case GL_RED:
// Don't modify the swizzle state when requesting the red channel.
- resultSwizzle = value;
+ resultSwizzle = newState.*stateMember;
break;
case GL_GREEN:
@@ -995,7 +797,7 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam
case GL_ZERO:
case GL_ONE:
// Don't modify the swizzle state when requesting ZERO or ONE.
- resultSwizzle = value;
+ resultSwizzle = newState.*stateMember;
break;
default:
@@ -1010,25 +812,65 @@ void TextureGL::syncTextureStateSwizzle(const FunctionsGL *functions, GLenum nam
}
- functions->texParameteri(mState.mTarget, name, resultSwizzle);
+ if (curState.*stateMember != resultSwizzle)
+ {
+ applyTextureFunc();
+ curState.*stateMember = resultSwizzle;
+ functions->texParameterf(textureType, name, static_cast<GLfloat>(resultSwizzle));
+ }
}
-void TextureGL::setLevelInfo(size_t level, size_t levelCount, const LevelInfoGL &levelInfo)
+void TextureGL::syncState(size_t textureUnit) const
{
- ASSERT(levelCount > 0 && level + levelCount < mLevelInfo.size());
+ // Callback lamdba to bind this texture only if needed.
+ bool textureApplied = false;
+ auto applyTextureFunc = [&]()
+ {
+ if (!textureApplied)
+ {
+ mStateManager->activeTexture(textureUnit);
+ mStateManager->bindTexture(mState.mTarget, mTextureID);
+ textureApplied = true;
+ }
+ };
- GLuint baseLevel = mState.getEffectiveBaseLevel();
- bool needsResync = level <= baseLevel && level + levelCount >= baseLevel &&
- (levelInfo.depthStencilWorkaround || levelInfo.lumaWorkaround.enabled);
- if (needsResync)
+ // Sync texture state
+ // Apply the effective base level and max level instead of the base level and max level set from
+ // the API. This can help with buggy drivers.
+ if (mAppliedTextureState.getEffectiveBaseLevel() != mState.getEffectiveBaseLevel())
{
- mLocalDirtyBits |= GetLevelWorkaroundDirtyBits();
+ applyTextureFunc();
+ mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_BASE_LEVEL,
+ mState.getEffectiveBaseLevel());
}
-
- for (size_t i = level; i < level + levelCount; i++)
+ mAppliedTextureState.mBaseLevel = mState.mBaseLevel;
+ if (mAppliedTextureState.getEffectiveMaxLevel() != mState.getEffectiveMaxLevel())
{
- mLevelInfo[i] = levelInfo;
+ applyTextureFunc();
+ mFunctions->texParameteri(mState.mTarget, GL_TEXTURE_MAX_LEVEL,
+ mState.getEffectiveMaxLevel());
}
+ mAppliedTextureState.mMaxLevel = mState.mMaxLevel;
+
+ // clang-format off
+ const LevelInfoGL &levelInfo = mLevelInfo[mState.getEffectiveBaseLevel()];
+ SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_R, &gl::SwizzleState::swizzleRed);
+ SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_G, &gl::SwizzleState::swizzleGreen);
+ SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_B, &gl::SwizzleState::swizzleBlue);
+ SyncTextureStateSwizzle(mFunctions, applyTextureFunc, levelInfo, mState.mSwizzleState, mAppliedTextureState.mSwizzleState, mState.mTarget, GL_TEXTURE_SWIZZLE_A, &gl::SwizzleState::swizzleAlpha);
+
+ // Sync sampler state
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::minFilter);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::magFilter);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_WRAP_S, &gl::SamplerState::wrapS);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_WRAP_T, &gl::SamplerState::wrapT);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_WRAP_R, &gl::SamplerState::wrapR);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::maxAnisotropy);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MIN_LOD, &gl::SamplerState::minLod);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode);
+ SyncSamplerStateMember(mFunctions, applyTextureFunc, mState.mSamplerState, mAppliedTextureState.mSamplerState, mState.mTarget, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc);
+ // clang-format on
}
GLuint TextureGL::getTextureID() const
diff --git a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h
index 068284c5b..540e6c3c6 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.h
@@ -87,12 +87,16 @@ class TextureGL : public TextureImpl
gl::Error setEGLImageTarget(GLenum target, egl::Image *image) override;
+ void syncState(size_t textureUnit) const;
GLuint getTextureID() const;
- void setBaseLevel(GLuint) override {}
+ gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
+ FramebufferAttachmentRenderTarget **rtOut) override
+ {
+ return gl::Error(GL_OUT_OF_MEMORY, "Not supported on OpenGL");
+ }
- void syncState(const gl::Texture::DirtyBits &dirtyBits) override;
- bool hasAnyDirtyBit() const;
+ void setBaseLevel(GLuint) override {}
private:
void setImageHelper(GLenum target,
@@ -116,25 +120,12 @@ class TextureGL : public TextureImpl
const gl::PixelUnpackState &unpack,
const uint8_t *pixels);
- gl::Error setSubImagePaddingWorkaround(GLenum target,
- size_t level,
- const gl::Box &area,
- GLenum format,
- GLenum type,
- const gl::PixelUnpackState &unpack,
- const uint8_t *pixels);
-
- void syncTextureStateSwizzle(const FunctionsGL *functions, GLenum name, GLenum value);
-
- void setLevelInfo(size_t level, size_t levelCount, const LevelInfoGL &levelInfo);
-
const FunctionsGL *mFunctions;
const WorkaroundsGL &mWorkarounds;
StateManagerGL *mStateManager;
BlitGL *mBlitter;
std::vector<LevelInfoGL> mLevelInfo;
- gl::Texture::DirtyBits mLocalDirtyBits;
mutable gl::TextureState mAppliedTextureState;
GLuint mTextureID;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h b/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h
index 105f94089..2549a2c47 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/WorkaroundsGL.h
@@ -21,13 +21,7 @@ struct WorkaroundsGL
doWhileGLSLCausesGPUHang(false),
finishDoesNotCauseQueriesToBeAvailable(false),
alwaysCallUseProgramAfterLink(false),
- unpackOverlappingRowsSeparatelyUnpackBuffer(false),
- emulateAbsIntFunction(false),
- addAndTrueToLoopCondition(false),
- emulateIsnanFloat(false),
- useUnusedBlocksWithStandardOrSharedLayout(false),
- dontRemoveInvariantForFragmentInput(false),
- removeInvariantAndCentroidForESSL3(false)
+ unpackOverlappingRowsSeparatelyUnpackBuffer(false)
{
}
@@ -73,53 +67,6 @@ struct WorkaroundsGL
// In the case of unpacking from a pixel unpack buffer, unpack overlapping rows row by row.
bool unpackOverlappingRowsSeparatelyUnpackBuffer;
- // In the case of packing to a pixel pack buffer, pack overlapping rows row by row.
- bool packOverlappingRowsSeparatelyPackBuffer;
-
- // During initialization, assign the current vertex attributes to the spec-mandated defaults.
- bool initializeCurrentVertexAttributes;
-
- // abs(i) where i is an integer returns unexpected result on Intel Mac.
- // Emulate abs(i) with i * sign(i).
- bool emulateAbsIntFunction;
-
- // On Intel Mac, calculation of loop conditions in for and while loop has bug.
- // Add "&& true" to the end of the condition expression to work around the bug.
- bool addAndTrueToLoopCondition;
-
- // When uploading textures from an unpack buffer, some drivers count an extra row padding when
- // checking if the pixel unpack buffer is big enough. Tracking bug: http://anglebug.com/1512
- // For example considering the pixel buffer below where in memory, each row data (D) of the
- // texture is followed by some unused data (the dots):
- // +-------+--+
- // |DDDDDDD|..|
- // |DDDDDDD|..|
- // |DDDDDDD|..|
- // |DDDDDDD|..|
- // +-------A--B
- // The last pixel read will be A, but the driver will think it is B, causing it to generate an
- // error when the pixel buffer is just big enough.
- bool unpackLastRowSeparatelyForPaddingInclusion;
-
- // Equivalent workaround when uploading data from a pixel pack buffer.
- bool packLastRowSeparatelyForPaddingInclusion;
-
- // On some Intel drivers, using isnan() on highp float will get wrong answer. To work around
- // this bug, we use an expression to emulate function isnan().
- // Tracking bug: http://crbug.com/650547
- bool emulateIsnanFloat;
-
- // On Mac with OpenGL version 4.1, unused std140 or shared uniform blocks will be
- // treated as inactive which is not consistent with WebGL2.0 spec. Reference all members in a
- // unused std140 or shared uniform block at the beginning of main to work around it.
- bool useUnusedBlocksWithStandardOrSharedLayout;
-
- // This flag will keep invariant declaration for input in fragment shader for GLSL >=4.20
- // on AMD.
- bool dontRemoveInvariantForFragmentInput;
-
- // This flag is used to fix spec difference between GLSL 4.1 or lower and ESSL3.
- bool removeInvariantAndCentroidForESSL3;
};
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h
index cc1b17bb7..0ba57b62b 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.h
@@ -35,8 +35,7 @@ class DisplayCGL : public DisplayGL
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm
index f87134c82..b9d5f39b0 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm
+++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm
@@ -128,8 +128,7 @@ SurfaceImpl *DisplayCGL::createPbufferSurface(const egl::SurfaceState &state,
SurfaceImpl *DisplayCGL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h
index 7cbb74da4..1e198bf5a 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h
@@ -53,7 +53,7 @@ class PbufferSurfaceCGL : public SurfaceGL
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
- RendererGL *mRenderer;
+ const WorkaroundsGL &mWorkarounds;
GLuint mFramebuffer;
GLuint mColorRenderbuffer;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm
index c03d3836f..b9689177e 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm
+++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm
@@ -28,7 +28,7 @@ PbufferSurfaceCGL::PbufferSurfaceCGL(const egl::SurfaceState &state,
mHeight(height),
mFunctions(functions),
mStateManager(renderer->getStateManager()),
- mRenderer(renderer),
+ mWorkarounds(renderer->getWorkarounds()),
mFramebuffer(0),
mColorRenderbuffer(0),
mDSRenderbuffer(0)
@@ -136,8 +136,7 @@ EGLint PbufferSurfaceCGL::getSwapBehavior() const
FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state)
{
// TODO(cwallez) assert it happens only once?
- return new FramebufferGL(mFramebuffer, state, mFunctions, mRenderer->getWorkarounds(),
- mRenderer->getBlitter(), mStateManager);
+ return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mStateManager);
}
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h
index 165ab0486..d8f1a14d7 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h
@@ -88,7 +88,6 @@ class WindowSurfaceCGL : public SurfaceGL
CGLContextObj mContext;
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
- RendererGL *mRenderer;
const WorkaroundsGL &mWorkarounds;
GLuint mFramebuffer;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm
index c2ac4dca4..b5375b1f9 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm
+++ b/gfx/angle/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm
@@ -154,12 +154,11 @@
mContext(context),
mFunctions(functions),
mStateManager(renderer->getStateManager()),
- mRenderer(renderer),
mWorkarounds(renderer->getWorkarounds()),
mFramebuffer(0),
mDSRenderbuffer(0)
- {
- pthread_mutex_init(&mSwapState.mutex, nullptr);
+{
+ pthread_mutex_init(&mSwapState.mutex, nullptr);
}
WindowSurfaceCGL::~WindowSurfaceCGL()
@@ -325,8 +324,7 @@ EGLint WindowSurfaceCGL::getSwapBehavior() const
FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::FramebufferState &state)
{
// TODO(cwallez) assert it happens only once?
- return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mRenderer->getBlitter(),
- mStateManager);
+ return new FramebufferGL(mFramebuffer, state, mFunctions, mWorkarounds, mStateManager);
}
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp
index 693b61c9c..388832b2a 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/egl/SurfaceEGL.cpp
@@ -33,6 +33,7 @@ SurfaceEGL::~SurfaceEGL()
if (mSurface != EGL_NO_SURFACE)
{
EGLBoolean success = mEGL->destroySurface(mSurface);
+ UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
}
}
@@ -103,6 +104,7 @@ EGLint SurfaceEGL::getWidth() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_WIDTH, &value);
+ UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
return value;
}
@@ -111,6 +113,7 @@ EGLint SurfaceEGL::getHeight() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_HEIGHT, &value);
+ UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
return value;
}
@@ -125,6 +128,7 @@ EGLint SurfaceEGL::getSwapBehavior() const
{
EGLint value;
EGLBoolean success = mEGL->querySurface(mSurface, EGL_SWAP_BEHAVIOR, &value);
+ UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success == EGL_TRUE);
return value;
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp
index b689578c9..4956c5b3f 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.cpp
@@ -159,6 +159,7 @@ SurfaceImpl *DisplayAndroid::createWindowSurface(const egl::SurfaceState &state,
EGL_NONE};
success = mEGL->chooseConfig(configAttribList, &config, 1, &numConfig);
ASSERT(success && numConfig == 1);
+ UNUSED_ASSERTION_VARIABLE(success);
return new WindowSurfaceEGL(state, mEGL, config, window, attribs.toIntVector(), mContext,
getRenderer());
@@ -176,6 +177,7 @@ SurfaceImpl *DisplayAndroid::createPbufferSurface(const egl::SurfaceState &state
EGL_NONE};
success = mEGL->chooseConfig(configAttribList, &config, 1, &numConfig);
ASSERT(success && numConfig == 1);
+ UNUSED_ASSERTION_VARIABLE(success);
return new PbufferSurfaceEGL(state, mEGL, config, attribs.toIntVector(), mContext,
getRenderer());
@@ -183,8 +185,7 @@ SurfaceImpl *DisplayAndroid::createPbufferSurface(const egl::SurfaceState &state
SurfaceImpl *DisplayAndroid::createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
@@ -214,6 +215,7 @@ void DisplayAndroid::getConfigAttrib(EGLConfig config, EGLint attribute, T *valu
EGLint tmp;
EGLBoolean success = mEGL->getConfigAttrib(config, attribute, &tmp);
ASSERT(success == EGL_TRUE);
+ UNUSED_ASSERTION_VARIABLE(success);
*value = tmp;
}
@@ -231,6 +233,7 @@ egl::ConfigSet DisplayAndroid::generateConfigs()
success =
mEGL->chooseConfig(mConfigAttribList.data(), configs.data(), numConfigs, &numConfigs2);
ASSERT(success == EGL_TRUE && numConfigs2 == numConfigs);
+ UNUSED_ASSERTION_VARIABLE(success);
for (int i = 0; i < numConfigs; i++)
{
diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h
index 0be9bb465..693532fb4 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/egl/android/DisplayAndroid.h
@@ -36,8 +36,7 @@ class DisplayAndroid : public DisplayEGL
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp
index 01549fcfa..6f5321632 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.cpp
@@ -308,9 +308,9 @@ uint32_t DisplayOzone::Buffer::getDRMFB()
FramebufferGL *DisplayOzone::Buffer::framebufferGL(const gl::FramebufferState &state)
{
- return new FramebufferGL(
- mGLFB, state, mDisplay->mFunctionsGL, mDisplay->getRenderer()->getWorkarounds(),
- mDisplay->getRenderer()->getBlitter(), mDisplay->getRenderer()->getStateManager());
+ return new FramebufferGL(mGLFB, state, mDisplay->mFunctionsGL,
+ mDisplay->getRenderer()->getWorkarounds(),
+ mDisplay->getRenderer()->getStateManager());
}
void DisplayOzone::Buffer::present()
@@ -859,8 +859,7 @@ SurfaceImpl *DisplayOzone::createPbufferSurface(const egl::SurfaceState &state,
SurfaceImpl *DisplayOzone::createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
diff --git a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h
index 77c669314..55a188c3e 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/egl/ozone/DisplayOzone.h
@@ -122,8 +122,7 @@ class DisplayOzone final : public DisplayEGL
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
diff --git a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp
index c5219b4b8..1688be116 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp
@@ -438,32 +438,6 @@ static GLenum GetNativeType(const FunctionsGL *functions,
return result;
}
-static GLenum GetNativeReadType(const FunctionsGL *functions,
- const WorkaroundsGL &workarounds,
- GLenum type)
-{
- GLenum result = type;
-
- if (functions->standard == STANDARD_GL_DESKTOP)
- {
- if (type == GL_HALF_FLOAT_OES)
- {
- // The enums differ for the OES half float extensions and desktop GL spec. Update it.
- result = GL_HALF_FLOAT;
- }
- }
-
- return result;
-}
-
-static GLenum GetNativeReadFormat(const FunctionsGL *functions,
- const WorkaroundsGL &workarounds,
- GLenum format)
-{
- GLenum result = format;
- return result;
-}
-
TexImageFormat GetTexImageFormat(const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
GLenum internalFormat,
@@ -538,16 +512,6 @@ RenderbufferFormat GetRenderbufferFormat(const FunctionsGL *functions,
GetNativeInternalFormat(functions, workarounds, internalFormat, internalFormat);
return result;
}
-ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions,
- const WorkaroundsGL &workarounds,
- GLenum format,
- GLenum type)
-{
- ReadPixelsFormat result;
- result.format = GetNativeReadFormat(functions, workarounds, format);
- result.type = GetNativeReadType(functions, workarounds, type);
- return result;
-}
}
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h
index 616f37af2..547d4783e 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/formatutilsgl.h
@@ -112,16 +112,6 @@ struct RenderbufferFormat
RenderbufferFormat GetRenderbufferFormat(const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
GLenum internalFormat);
-
-struct ReadPixelsFormat
-{
- GLenum format;
- GLenum type;
-};
-ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions,
- const WorkaroundsGL &workarounds,
- GLenum format,
- GLenum type);
}
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp
index e98401d0a..0358a428e 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.cpp
@@ -350,7 +350,7 @@ egl::Error DisplayGLX::initialize(egl::Display *display)
bool isOpenGLES =
eglAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE) ==
EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
- if (isOpenGLES && (IsIntel(vendor) || IsNvidia(vendor)))
+ if (isOpenGLES && (vendor == VENDOR_ID_INTEL || vendor == VENDOR_ID_NVIDIA))
{
return egl::Error(EGL_NOT_INITIALIZED, "Intel or NVIDIA OpenGL ES drivers are not supported.");
}
@@ -410,8 +410,7 @@ SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state,
SurfaceImpl *DisplayGLX::createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
diff --git a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h
index 7e870c2f3..79198395d 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/glx/DisplayGLX.h
@@ -53,8 +53,7 @@ class DisplayGLX : public DisplayGL
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
diff --git a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 504a787f8..87fd24a61 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -11,8 +11,6 @@
#include <limits>
-#include "common/mathutil.h"
-#include "libANGLE/Buffer.h"
#include "libANGLE/Caps.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
@@ -22,8 +20,6 @@
#include <algorithm>
#include <sstream>
-using angle::CheckedNumeric;
-
namespace rx
{
VendorID GetVendorID(const FunctionsGL *functions)
@@ -871,81 +867,35 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
functions->isAtLeastGLES(gl::Version(3, 1));
extensions->pathRendering = canEnableGLPathRendering || canEnableESPathRendering;
-
- extensions->textureSRGBDecode = functions->hasGLExtension("GL_EXT_texture_sRGB_decode") ||
- functions->hasGLESExtension("GL_EXT_texture_sRGB_decode");
-
-#if defined(ANGLE_PLATFORM_APPLE)
- VendorID vendor = GetVendorID(functions);
- if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0))
- {
- // Apple Intel/AMD drivers do not correctly use the TEXTURE_SRGB_DECODE property of sampler
- // states. Disable this extension when we would advertise any ES version that has samplers.
- extensions->textureSRGBDecode = false;
- }
-#endif
-
- extensions->sRGBWriteControl = functions->isAtLeastGL(gl::Version(3, 0)) ||
- functions->hasGLExtension("GL_EXT_framebuffer_sRGB") ||
- functions->hasGLExtension("GL_ARB_framebuffer_sRGB") ||
- functions->hasGLESExtension("GL_EXT_sRGB_write_control");
-
-#if defined(ANGLE_PLATFORM_ANDROID)
- // SRGB blending does not appear to work correctly on the Nexus 5. Writing to an SRGB
- // framebuffer with GL_FRAMEBUFFER_SRGB enabled and then reading back returns the same value.
- // Disabling GL_FRAMEBUFFER_SRGB will then convert in the wrong direction.
- extensions->sRGBWriteControl = false;
-#endif
}
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds)
{
VendorID vendor = GetVendorID(functions);
- workarounds->dontRemoveInvariantForFragmentInput =
- functions->standard == STANDARD_GL_DESKTOP && IsAMD(vendor);
-
// Don't use 1-bit alpha formats on desktop GL with AMD or Intel drivers.
workarounds->avoid1BitAlphaTextureFormats =
- functions->standard == STANDARD_GL_DESKTOP && (IsAMD(vendor) || IsIntel(vendor));
+ functions->standard == STANDARD_GL_DESKTOP &&
+ (vendor == VENDOR_ID_AMD || vendor == VENDOR_ID_INTEL);
workarounds->rgba4IsNotSupportedForColorRendering =
- functions->standard == STANDARD_GL_DESKTOP && IsIntel(vendor);
-
- workarounds->emulateAbsIntFunction = IsIntel(vendor);
-
- workarounds->addAndTrueToLoopCondition = IsIntel(vendor);
-
- workarounds->emulateIsnanFloat = IsIntel(vendor);
+ functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_INTEL;
workarounds->doesSRGBClearsOnLinearFramebufferAttachments =
- functions->standard == STANDARD_GL_DESKTOP && (IsIntel(vendor) || IsAMD(vendor));
+ functions->standard == STANDARD_GL_DESKTOP &&
+ (vendor == VENDOR_ID_INTEL || vendor == VENDOR_ID_AMD);
#if defined(ANGLE_PLATFORM_APPLE)
workarounds->doWhileGLSLCausesGPUHang = true;
- workarounds->useUnusedBlocksWithStandardOrSharedLayout = true;
#endif
workarounds->finishDoesNotCauseQueriesToBeAvailable =
- functions->standard == STANDARD_GL_DESKTOP && IsNvidia(vendor);
+ functions->standard == STANDARD_GL_DESKTOP && vendor == VENDOR_ID_NVIDIA;
// TODO(cwallez): Disable this workaround for MacOSX versions 10.9 or later.
workarounds->alwaysCallUseProgramAfterLink = true;
- workarounds->unpackOverlappingRowsSeparatelyUnpackBuffer = IsNvidia(vendor);
- workarounds->packOverlappingRowsSeparatelyPackBuffer = IsNvidia(vendor);
-
- workarounds->initializeCurrentVertexAttributes = IsNvidia(vendor);
-
-#if defined(ANGLE_PLATFORM_APPLE)
- workarounds->unpackLastRowSeparatelyForPaddingInclusion = true;
- workarounds->packLastRowSeparatelyForPaddingInclusion = true;
-#else
- workarounds->unpackLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor);
- workarounds->packLastRowSeparatelyForPaddingInclusion = IsNvidia(vendor);
-#endif
-
- workarounds->removeInvariantAndCentroidForESSL3 = functions->isAtMostGL(gl::Version(4, 1));
+ workarounds->unpackOverlappingRowsSeparatelyUnpackBuffer = vendor == VENDOR_ID_NVIDIA;
}
}
@@ -1001,45 +951,4 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
return nullptr;
}
}
-
-gl::ErrorOrResult<bool> ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
- const gl::PixelStoreStateBase &state,
- GLenum format,
- GLenum type,
- bool is3D,
- const void *pixels)
-{
- if (state.pixelBuffer.get() == nullptr)
- {
- return false;
- }
-
- // We are using an pack or unpack buffer, compute what the driver thinks is going to be the
- // last byte read or written. If it is past the end of the buffer, we will need to use the
- // workaround otherwise the driver will generate INVALID_OPERATION and not do the operation.
- CheckedNumeric<size_t> checkedEndByte;
- CheckedNumeric<size_t> pixelBytes;
- size_t rowPitch;
-
- const gl::InternalFormat &glFormat =
- gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type));
- ANGLE_TRY_RESULT(glFormat.computePackUnpackEndByte(size, state, is3D), checkedEndByte);
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(size.width, state.alignment, state.rowLength),
- rowPitch);
- pixelBytes = glFormat.pixelBytes;
-
- checkedEndByte += reinterpret_cast<intptr_t>(pixels);
-
- // At this point checkedEndByte is the actual last byte read.
- // The driver adds an extra row padding (if any), mimic it.
- ANGLE_TRY_CHECKED_MATH(pixelBytes);
- if (pixelBytes.ValueOrDie() * size.width < rowPitch)
- {
- checkedEndByte += rowPitch - pixelBytes * size.width;
- }
-
- ANGLE_TRY_CHECKED_MATH(checkedEndByte);
-
- return checkedEndByte.ValueOrDie() > static_cast<size_t>(state.pixelBuffer->getSize());
-}
}
diff --git a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h
index 1e9338fb5..3b0cab27e 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.h
@@ -11,8 +11,6 @@
#define LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
#include "libANGLE/angletypes.h"
-#include "libANGLE/Error.h"
-#include "libANGLE/renderer/driver_utils.h"
#include "libANGLE/renderer/gl/functionsgl_typedefs.h"
#include <string>
@@ -49,13 +47,6 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
size_t offset,
size_t length,
GLbitfield access);
-
-gl::ErrorOrResult<bool> ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
- const gl::PixelStoreStateBase &state,
- GLenum format,
- GLenum type,
- bool is3D,
- const void *pixels);
}
#endif // LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.cpp
deleted file mode 100644
index f19e8fdf3..000000000
--- a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// D3DTextureSurfaceWGL.cpp: WGL implementation of egl::Surface for D3D texture interop.
-
-#include "libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h"
-
-#include "libANGLE/renderer/gl/FramebufferGL.h"
-#include "libANGLE/renderer/gl/TextureGL.h"
-#include "libANGLE/renderer/gl/RendererGL.h"
-#include "libANGLE/renderer/gl/StateManagerGL.h"
-#include "libANGLE/renderer/gl/wgl/DisplayWGL.h"
-#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
-
-namespace rx
-{
-
-namespace
-{
-
-egl::Error GetD3DTextureInfo(EGLClientBuffer clientBuffer,
- size_t *width,
- size_t *height,
- IUnknown **object,
- IUnknown **device)
-{
- IUnknown *buffer = static_cast<IUnknown *>(clientBuffer);
-
- IDirect3DTexture9 *texture9 = nullptr;
- ID3D11Texture2D *texture11 = nullptr;
- if (SUCCEEDED(buffer->QueryInterface<ID3D11Texture2D>(&texture11)))
- {
- D3D11_TEXTURE2D_DESC textureDesc;
- texture11->GetDesc(&textureDesc);
-
- // From table egl.restrictions in EGL_ANGLE_d3d_texture_client_buffer.
- switch (textureDesc.Format)
- {
- case DXGI_FORMAT_R8G8B8A8_UNORM:
- case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
- case DXGI_FORMAT_B8G8R8A8_UNORM:
- case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
- case DXGI_FORMAT_R16G16B16A16_FLOAT:
- case DXGI_FORMAT_R32G32B32A32_FLOAT:
- break;
-
- default:
- SafeRelease(texture11);
- return egl::Error(EGL_BAD_PARAMETER, "Unknown client buffer texture format: %u.",
- textureDesc.Format);
- }
-
- ID3D11Device *d3d11Device = nullptr;
- texture11->GetDevice(&d3d11Device);
- if (d3d11Device == nullptr)
- {
- SafeRelease(texture11);
- return egl::Error(EGL_BAD_PARAMETER,
- "Could not query the D3D11 device from the client buffer.");
- }
-
- if (width)
- {
- *width = textureDesc.Width;
- }
- if (height)
- {
- *height = textureDesc.Height;
- }
-
- if (device)
- {
- *device = d3d11Device;
- }
- else
- {
- SafeRelease(d3d11Device);
- }
-
- if (object)
- {
- *object = texture11;
- }
- else
- {
- SafeRelease(texture11);
- }
-
- return egl::Error(EGL_SUCCESS);
- }
- else if (SUCCEEDED(buffer->QueryInterface<IDirect3DTexture9>(&texture9)))
- {
- D3DSURFACE_DESC surfaceDesc;
- if (FAILED(texture9->GetLevelDesc(0, &surfaceDesc)))
- {
- SafeRelease(texture9);
- return egl::Error(EGL_BAD_PARAMETER,
- "Could not query description of the D3D9 surface.");
- }
-
- // From table egl.restrictions in EGL_ANGLE_d3d_texture_client_buffer.
- switch (surfaceDesc.Format)
- {
- case D3DFMT_R8G8B8:
- case D3DFMT_A8R8G8B8:
- case D3DFMT_A16B16G16R16F:
- case D3DFMT_A32B32G32R32F:
- break;
-
- default:
- SafeRelease(texture9);
- return egl::Error(EGL_BAD_PARAMETER, "Unknown client buffer texture format: %u.",
- surfaceDesc.Format);
- }
-
- if (width)
- {
- *width = surfaceDesc.Width;
- }
- if (height)
- {
- *height = surfaceDesc.Height;
- }
-
- IDirect3DDevice9 *d3d9Device = nullptr;
- HRESULT result = texture9->GetDevice(&d3d9Device);
- if (FAILED(result))
- {
- SafeRelease(texture9);
- return egl::Error(EGL_BAD_PARAMETER,
- "Could not query the D3D9 device from the client buffer.");
- }
-
- if (device)
- {
- *device = d3d9Device;
- }
- else
- {
- SafeRelease(d3d9Device);
- }
-
- if (object)
- {
- *object = texture9;
- }
- else
- {
- SafeRelease(texture9);
- }
-
- return egl::Error(EGL_SUCCESS);
- }
- else
- {
- return egl::Error(EGL_BAD_PARAMETER,
- "Provided buffer is not a IDirect3DTexture9 or ID3D11Texture2D.");
- }
-}
-
-} // anonymous namespace
-
-D3DTextureSurfaceWGL::D3DTextureSurfaceWGL(const egl::SurfaceState &state,
- RendererGL *renderer,
- EGLClientBuffer clientBuffer,
- DisplayWGL *display,
- HGLRC wglContext,
- HDC deviceContext,
- const FunctionsGL *functionsGL,
- const FunctionsWGL *functionsWGL)
- : SurfaceGL(state, renderer),
- mClientBuffer(clientBuffer),
- mRenderer(renderer),
- mDisplay(display),
- mStateManager(renderer->getStateManager()),
- mWorkarounds(renderer->getWorkarounds()),
- mFunctionsGL(functionsGL),
- mFunctionsWGL(functionsWGL),
- mWGLContext(wglContext),
- mDeviceContext(deviceContext),
- mWidth(0),
- mHeight(0),
- mDeviceHandle(nullptr),
- mObject(nullptr),
- mBoundObjectTextureHandle(nullptr),
- mBoundObjectRenderbufferHandle(nullptr),
- mRenderbufferID(0),
- mFramebufferID(0)
-{
-}
-
-D3DTextureSurfaceWGL::~D3DTextureSurfaceWGL()
-{
- ASSERT(mBoundObjectTextureHandle == nullptr);
-
- SafeRelease(mObject);
-
- if (mDeviceHandle)
- {
- if (mBoundObjectRenderbufferHandle)
- {
- mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mBoundObjectRenderbufferHandle);
- mBoundObjectRenderbufferHandle = nullptr;
- }
- mStateManager->deleteRenderbuffer(mRenderbufferID);
-
- if (mBoundObjectTextureHandle)
- {
- mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mBoundObjectTextureHandle);
- mBoundObjectTextureHandle = nullptr;
- }
-
- // GL framebuffer is deleted by the default framebuffer object
- mFramebufferID = 0;
-
- mDisplay->releaseD3DDevice(mDeviceHandle);
- mDeviceHandle = nullptr;
- }
-}
-
-egl::Error D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(EGLClientBuffer clientBuffer)
-{
- return GetD3DTextureInfo(clientBuffer, nullptr, nullptr, nullptr, nullptr);
-}
-
-egl::Error D3DTextureSurfaceWGL::initialize()
-{
- IUnknown *device = nullptr;
- ANGLE_TRY(GetD3DTextureInfo(mClientBuffer, &mWidth, &mHeight, &mObject, &device));
-
- ASSERT(device != nullptr);
- egl::Error error = mDisplay->registerD3DDevice(device, &mDeviceHandle);
- SafeRelease(device);
- if (error.isError())
- {
- return error;
- }
-
- mFunctionsGL->genRenderbuffers(1, &mRenderbufferID);
- mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID);
- mBoundObjectRenderbufferHandle = mFunctionsWGL->dxRegisterObjectNV(
- mDeviceHandle, mObject, mRenderbufferID, GL_RENDERBUFFER, WGL_ACCESS_READ_WRITE_NV);
- if (mBoundObjectRenderbufferHandle == nullptr)
- {
- return egl::Error(EGL_BAD_ALLOC, "Failed to register D3D object, error: 0x%08x.",
- HRESULT_CODE(GetLastError()));
- }
-
- mFunctionsGL->genFramebuffers(1, &mFramebufferID);
- mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
- mFunctionsGL->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
- mRenderbufferID);
-
- return egl::Error(EGL_SUCCESS);
-}
-
-egl::Error D3DTextureSurfaceWGL::makeCurrent()
-{
- if (!mFunctionsWGL->makeCurrent(mDeviceContext, mWGLContext))
- {
- // TODO(geofflang): What error type here?
- return egl::Error(EGL_CONTEXT_LOST, "Failed to make the WGL context current.");
- }
-
- if (!mFunctionsWGL->dxLockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle))
- {
- DWORD error = GetLastError();
- return egl::Error(EGL_BAD_ALLOC, "Failed to lock object, error: 0x%08x.",
- HRESULT_CODE(error));
- }
-
- return egl::Error(EGL_SUCCESS);
-}
-
-egl::Error D3DTextureSurfaceWGL::unMakeCurrent()
-{
- if (!mFunctionsWGL->dxUnlockObjectsNV(mDeviceHandle, 1, &mBoundObjectRenderbufferHandle))
- {
- DWORD error = GetLastError();
- return egl::Error(EGL_BAD_ALLOC, "Failed to unlock object, error: 0x%08x.",
- HRESULT_CODE(error));
- }
-
- return egl::Error(EGL_SUCCESS);
-}
-
-egl::Error D3DTextureSurfaceWGL::swap()
-{
- return egl::Error(EGL_SUCCESS);
-}
-
-egl::Error D3DTextureSurfaceWGL::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
-{
- UNIMPLEMENTED();
- return egl::Error(EGL_SUCCESS);
-}
-
-egl::Error D3DTextureSurfaceWGL::querySurfacePointerANGLE(EGLint attribute, void **value)
-{
- UNIMPLEMENTED();
- return egl::Error(EGL_SUCCESS);
-}
-
-egl::Error D3DTextureSurfaceWGL::bindTexImage(gl::Texture *texture, EGLint buffer)
-{
- ASSERT(mBoundObjectTextureHandle == nullptr);
-
- const TextureGL *textureGL = GetImplAs<TextureGL>(texture);
- GLuint textureID = textureGL->getTextureID();
-
- mBoundObjectTextureHandle = mFunctionsWGL->dxRegisterObjectNV(
- mDeviceHandle, mObject, textureID, GL_TEXTURE_2D, WGL_ACCESS_READ_WRITE_NV);
- if (mBoundObjectTextureHandle == nullptr)
- {
- DWORD error = GetLastError();
- return egl::Error(EGL_BAD_ALLOC, "Failed to register D3D object, error: 0x%08x.",
- HRESULT_CODE(error));
- }
-
- if (!mFunctionsWGL->dxLockObjectsNV(mDeviceHandle, 1, &mBoundObjectTextureHandle))
- {
- DWORD error = GetLastError();
- return egl::Error(EGL_BAD_ALLOC, "Failed to lock object, error: 0x%08x.",
- HRESULT_CODE(error));
- }
-
- return egl::Error(EGL_SUCCESS);
-}
-
-egl::Error D3DTextureSurfaceWGL::releaseTexImage(EGLint buffer)
-{
- ASSERT(mBoundObjectTextureHandle != nullptr);
- if (!mFunctionsWGL->dxUnlockObjectsNV(mDeviceHandle, 1, &mBoundObjectTextureHandle))
- {
- DWORD error = GetLastError();
- return egl::Error(EGL_BAD_ALLOC, "Failed to unlock object, error: 0x%08x.",
- HRESULT_CODE(error));
- }
-
- if (!mFunctionsWGL->dxUnregisterObjectNV(mDeviceHandle, mBoundObjectTextureHandle))
- {
- DWORD error = GetLastError();
- return egl::Error(EGL_BAD_ALLOC, "Failed to unregister D3D object, error: 0x%08x.",
- HRESULT_CODE(error));
- }
- mBoundObjectTextureHandle = nullptr;
-
- return egl::Error(EGL_SUCCESS);
-}
-
-void D3DTextureSurfaceWGL::setSwapInterval(EGLint interval)
-{
- UNIMPLEMENTED();
-}
-
-EGLint D3DTextureSurfaceWGL::getWidth() const
-{
- return static_cast<EGLint>(mWidth);
-}
-
-EGLint D3DTextureSurfaceWGL::getHeight() const
-{
- return static_cast<EGLint>(mHeight);
-}
-
-EGLint D3DTextureSurfaceWGL::isPostSubBufferSupported() const
-{
- return EGL_FALSE;
-}
-
-EGLint D3DTextureSurfaceWGL::getSwapBehavior() const
-{
- return EGL_BUFFER_PRESERVED;
-}
-
-FramebufferImpl *D3DTextureSurfaceWGL::createDefaultFramebuffer(const gl::FramebufferState &data)
-{
- return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds,
- mRenderer->getBlitter(), mStateManager);
-}
-} // namespace rx
diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h b/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h
deleted file mode 100644
index 8fb1d4003..000000000
--- a/gfx/angle/src/libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h
+++ /dev/null
@@ -1,86 +0,0 @@
-
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// D3DTextureSurfaceWGL.h: WGL implementation of egl::Surface for D3D texture interop.
-
-#ifndef LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_
-#define LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_
-
-#include "libANGLE/renderer/gl/SurfaceGL.h"
-
-#include <GL/wglext.h>
-
-namespace rx
-{
-
-class FunctionsGL;
-class FunctionsWGL;
-class DisplayWGL;
-class StateManagerGL;
-struct WorkaroundsGL;
-
-class D3DTextureSurfaceWGL : public SurfaceGL
-{
- public:
- D3DTextureSurfaceWGL(const egl::SurfaceState &state,
- RendererGL *renderer,
- EGLClientBuffer clientBuffer,
- DisplayWGL *display,
- HGLRC wglContext,
- HDC deviceContext,
- const FunctionsGL *functionsGL,
- const FunctionsWGL *functionsWGL);
- ~D3DTextureSurfaceWGL() override;
-
- static egl::Error ValidateD3DTextureClientBuffer(EGLClientBuffer clientBuffer);
-
- egl::Error initialize() override;
- egl::Error makeCurrent() override;
- egl::Error unMakeCurrent() override;
-
- egl::Error swap() override;
- egl::Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) override;
- egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
- egl::Error bindTexImage(gl::Texture *texture, EGLint buffer) override;
- egl::Error releaseTexImage(EGLint buffer) override;
- void setSwapInterval(EGLint interval) override;
-
- EGLint getWidth() const override;
- EGLint getHeight() const override;
-
- EGLint isPostSubBufferSupported() const override;
- EGLint getSwapBehavior() const override;
-
- FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &data) override;
-
- private:
- EGLClientBuffer mClientBuffer;
-
- RendererGL *mRenderer;
-
- DisplayWGL *mDisplay;
- StateManagerGL *mStateManager;
- const WorkaroundsGL &mWorkarounds;
- const FunctionsGL *mFunctionsGL;
- const FunctionsWGL *mFunctionsWGL;
-
- HGLRC mWGLContext;
- HDC mDeviceContext;
-
- size_t mWidth;
- size_t mHeight;
-
- HANDLE mDeviceHandle;
- IUnknown *mObject;
- HANDLE mBoundObjectTextureHandle;
- HANDLE mBoundObjectRenderbufferHandle;
-
- GLuint mRenderbufferID;
- GLuint mFramebufferID;
-};
-} // namespace rx
-
-#endif // LIBANGLE_RENDERER_GL_WGL_D3DTEXTIRESURFACEWGL_H_
diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp
index 7c5214e82..e07457d10 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.cpp
@@ -36,7 +36,6 @@ DXGISwapChainWindowSurfaceWGL::DXGISwapChainWindowSurfaceWGL(const egl::SurfaceS
mWindow(window),
mStateManager(renderer->getStateManager()),
mWorkarounds(renderer->getWorkarounds()),
- mRenderer(renderer),
mFunctionsGL(functionsGL),
mFunctionsWGL(functionsWGL),
mDevice(device),
@@ -293,8 +292,7 @@ EGLint DXGISwapChainWindowSurfaceWGL::getSwapBehavior() const
FramebufferImpl *DXGISwapChainWindowSurfaceWGL::createDefaultFramebuffer(
const gl::FramebufferState &data)
{
- return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds,
- mRenderer->getBlitter(), mStateManager);
+ return new FramebufferGL(mFramebufferID, data, mFunctionsGL, mWorkarounds, mStateManager);
}
egl::Error DXGISwapChainWindowSurfaceWGL::setObjectsLocked(bool locked)
diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h
index f516239c9..66444da9b 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h
@@ -66,7 +66,6 @@ class DXGISwapChainWindowSurfaceWGL : public SurfaceGL
StateManagerGL *mStateManager;
const WorkaroundsGL &mWorkarounds;
- RendererGL *mRenderer;
const FunctionsGL *mFunctionsGL;
const FunctionsWGL *mFunctionsWGL;
diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp
index 188321115..4647fe589 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp
@@ -14,15 +14,12 @@
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
-#include "libANGLE/renderer/gl/wgl/D3DTextureSurfaceWGL.h"
#include "libANGLE/renderer/gl/wgl/DXGISwapChainWindowSurfaceWGL.h"
#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
#include "libANGLE/renderer/gl/wgl/PbufferSurfaceWGL.h"
#include "libANGLE/renderer/gl/wgl/WindowSurfaceWGL.h"
#include "libANGLE/renderer/gl/wgl/wgl_utils.h"
-#include "platform/Platform.h"
-
#include <EGL/eglext.h>
#include <string>
#include <sstream>
@@ -63,7 +60,7 @@ DisplayWGL::DisplayWGL()
mOpenGLModule(nullptr),
mFunctionsWGL(nullptr),
mFunctionsGL(nullptr),
- mHasRobustness(false),
+ mHasARBCreateContextRobustness(false),
mWindowClass(0),
mWindow(nullptr),
mDeviceContext(nullptr),
@@ -178,7 +175,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
// Reinitialize the wgl functions to grab the extensions
mFunctionsWGL->initialize(mOpenGLModule, dummyDeviceContext);
- bool hasWGLCreateContextRobustness =
+ mHasARBCreateContextRobustness =
mFunctionsWGL->hasExtension("WGL_ARB_create_context_robustness");
// Destroy the dummy window and context
@@ -267,7 +264,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
std::vector<int> contextCreationAttributes;
- if (hasWGLCreateContextRobustness)
+ if (mHasARBCreateContextRobustness)
{
contextCreationAttributes.push_back(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB);
contextCreationAttributes.push_back(WGL_LOSE_CONTEXT_ON_RESET_ARB);
@@ -343,17 +340,9 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
mFunctionsGL = new FunctionsGLWindows(mOpenGLModule, mFunctionsWGL->getProcAddress);
mFunctionsGL->initialize();
- mHasRobustness = mFunctionsGL->getGraphicsResetStatus != nullptr;
- if (hasWGLCreateContextRobustness != mHasRobustness)
- {
- ANGLEPlatformCurrent()->logWarning(
- "WGL_ARB_create_context_robustness exists but unable to OpenGL context with "
- "robustness.");
- }
-
// Intel OpenGL ES drivers are not currently supported due to bugs in the driver and ANGLE
VendorID vendor = GetVendorID(mFunctionsGL);
- if (requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE && IsIntel(vendor))
+ if (requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE && vendor == VENDOR_ID_INTEL)
{
return egl::Error(EGL_NOT_INITIALIZED, "Intel OpenGL ES drivers are not supported.");
}
@@ -369,7 +358,7 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
GetWindowThreadProcessId(nativeWindow, &windowProcessId);
// AMD drivers advertise the WGL_NV_DX_interop and WGL_NV_DX_interop2 extensions but fail
- mUseDXGISwapChains = !IsAMD(vendor) && (currentProcessId != windowProcessId);
+ mUseDXGISwapChains = vendor != VENDOR_ID_AMD && (currentProcessId != windowProcessId);
}
else
{
@@ -465,13 +454,11 @@ SurfaceImpl *DisplayWGL::createPbufferSurface(const egl::SurfaceState &state,
SurfaceImpl *DisplayWGL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs)
{
- ASSERT(buftype == EGL_D3D_TEXTURE_ANGLE);
- return new D3DTextureSurfaceWGL(state, getRenderer(), clientBuffer, this, mWGLContext,
- mDeviceContext, mFunctionsGL, mFunctionsWGL);
+ UNIMPLEMENTED();
+ return nullptr;
}
SurfaceImpl *DisplayWGL::createPixmapSurface(const egl::SurfaceState &state,
@@ -566,7 +553,7 @@ egl::ConfigSet DisplayWGL::generateConfigs()
bool DisplayWGL::testDeviceLost()
{
- if (mHasRobustness)
+ if (mHasARBCreateContextRobustness)
{
return getRenderer()->getResetStatus() != GL_NO_ERROR;
}
@@ -584,21 +571,6 @@ bool DisplayWGL::isValidNativeWindow(EGLNativeWindowType window) const
return (IsWindow(window) == TRUE);
}
-egl::Error DisplayWGL::validateClientBuffer(const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
- const egl::AttributeMap &attribs) const
-{
- switch (buftype)
- {
- case EGL_D3D_TEXTURE_ANGLE:
- return D3DTextureSurfaceWGL::ValidateD3DTextureClientBuffer(clientBuffer);
-
- default:
- return DisplayGL::validateClientBuffer(configuration, buftype, clientBuffer, attribs);
- }
-}
-
std::string DisplayWGL::getVendorString() const
{
//UNIMPLEMENTED();
@@ -661,9 +633,7 @@ void DisplayWGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->postSubBuffer = mUseDXGISwapChains;
outExtensions->surfaceOrientation = mUseDXGISwapChains;
- outExtensions->createContextRobustness = mHasRobustness;
-
- outExtensions->d3dTextureClientBuffer = mFunctionsWGL->hasExtension("WGL_NV_DX_interop2");
+ outExtensions->createContextRobustness = mHasARBCreateContextRobustness;
}
void DisplayWGL::generateCaps(egl::Caps *outCaps) const
diff --git a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h
index 509ea9b39..3f56ecf4f 100755
--- a/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h
+++ b/gfx/angle/src/libANGLE/renderer/gl/wgl/DisplayWGL.h
@@ -37,8 +37,7 @@ class DisplayWGL : public DisplayGL
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
+ EGLClientBuffer shareHandle,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
const egl::Config *configuration,
@@ -51,10 +50,6 @@ class DisplayWGL : public DisplayGL
egl::Error restoreLostDevice() override;
bool isValidNativeWindow(EGLNativeWindowType window) const override;
- egl::Error validateClientBuffer(const egl::Config *configuration,
- EGLenum buftype,
- EGLClientBuffer clientBuffer,
- const egl::AttributeMap &attribs) const override;
egl::Error getDevice(DeviceImpl **device) override;
@@ -83,7 +78,7 @@ class DisplayWGL : public DisplayGL
FunctionsWGL *mFunctionsWGL;
FunctionsGL *mFunctionsGL;
- bool mHasRobustness;
+ bool mHasARBCreateContextRobustness;
ATOM mWindowClass;
HWND mWindow;