Commit 931e6d0f authored by Carsten "Tomcat" Book's avatar Carsten "Tomcat" Book
Browse files

Backed out changeset c0b0e54e156e (bug 1290634) for webgl regressions

parent f40d4e17
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -2179,8 +2179,8 @@ ZeroTexImageWithClear(WebGLContext* webgl, GLContext* gl, TexImageTarget target,
}

bool
ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
                TexImageTarget target, uint32_t level,
ZeroTextureData(WebGLContext* webgl, const char* funcName, bool respecifyTexture,
                GLuint tex, TexImageTarget target, uint32_t level,
                const webgl::FormatUsageInfo* usage, uint32_t xOffset, uint32_t yOffset,
                uint32_t zOffset, uint32_t width, uint32_t height, uint32_t depth)
{
@@ -2203,6 +2203,7 @@ ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
    auto compression = usage->format->compression;
    if (compression) {
        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset, "GFX: Can't zero compressed texture with offsets.");
        MOZ_RELEASE_ASSERT(!respecifyTexture, "GFX: respecifyTexture is set to true.");

        auto sizedFormat = usage->format->sizedFormat;
        MOZ_RELEASE_ASSERT(sizedFormat, "GFX: texture sized format not set");
@@ -2250,6 +2251,13 @@ ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
        // While we would like to skip the extra complexity of trying to zero with an FB
        // clear, ANGLE_depth_texture requires this.
        do {
            if (respecifyTexture) {
                const auto error = DoTexImage(gl, target, level, driverUnpackInfo, width,
                                              height, depth, nullptr);
                if (error)
                    break;
            }

            if (ZeroTexImageWithClear(webgl, gl, target, tex, level, usage, width,
                                      height))
            {
@@ -2279,8 +2287,15 @@ ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
    ScopedUnpackReset scopedReset(webgl);
    gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1); // Don't bother with striding it well.

    const auto error = DoTexSubImage(gl, target, level, xOffset, yOffset, zOffset, width,
                                     height, depth, packing, zeros.get());
    GLenum error;
    if (respecifyTexture) {
        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset, "GFX: texture data, offsets, not zeroed.");
        error = DoTexImage(gl, target, level, driverUnpackInfo, width, height, depth,
                           zeros.get());
    } else {
        error = DoTexSubImage(gl, target, level, xOffset, yOffset, zOffset, width, height,
                              depth, packing, zeros.get());
    }
    if (error)
        return false;

+2 −2
Original line number Diff line number Diff line
@@ -1756,8 +1756,8 @@ Intersect(uint32_t srcSize, int32_t dstStartInSrc, uint32_t dstSize,
          uint32_t* const out_intSize);

bool
ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
                TexImageTarget target, uint32_t level,
ZeroTextureData(WebGLContext* webgl, const char* funcName, bool respecifyTexture,
                GLuint tex, TexImageTarget target, uint32_t level,
                const webgl::FormatUsageInfo* usage, uint32_t xOffset, uint32_t yOffset,
                uint32_t zOffset, uint32_t width, uint32_t height, uint32_t depth);

+3 −2
Original line number Diff line number Diff line
@@ -591,13 +591,14 @@ WebGLTexture::InitializeImageData(const char* funcName, TexImageTarget target,
    MOZ_ASSERT(imageInfo.IsDefined());
    MOZ_ASSERT(!imageInfo.IsDataInitialized());

    const bool respecifyTexture = false;
    const auto& usage = imageInfo.mFormat;
    const auto& width = imageInfo.mWidth;
    const auto& height = imageInfo.mHeight;
    const auto& depth = imageInfo.mDepth;

    if (!ZeroTextureData(mContext, funcName, mGLName, target, level, usage, 0, 0, 0,
                         width, height, depth))
    if (!ZeroTextureData(mContext, funcName, respecifyTexture, mGLName, target, level,
                         usage, 0, 0, 0, width, height, depth))
    {
        return false;
    }
+3 −2
Original line number Diff line number Diff line
@@ -2079,9 +2079,10 @@ WebGLTexture::CopyTexImage2D(TexImageTarget target, GLint level, GLenum internal
        // 1. Zero the texture data.
        // 2. CopyTexSubImage the subrect.

        const bool respecifyTexture = true;
        const uint8_t zOffset = 0;
        if (!ZeroTextureData(mContext, funcName, mGLName, target, level, dstUsage, 0, 0,
                             zOffset, width, height, depth))
        if (!ZeroTextureData(mContext, funcName, respecifyTexture, mGLName, target, level,
                             dstUsage, 0, 0, zOffset, width, height, depth))
        {
            mContext->ErrorOutOfMemory("%s: Failed to zero texture data.", funcName);
            MOZ_ASSERT(false, "Failed to zero texture data.");