Hash :
e4bd0418
Author :
Date :
2015-10-21T17:00:06
Enable EXT_discard_framebuffer in ANGLE's D3D11 backend. This doesn't seem to cause the video-related WebGL test failures anymore that were previously seen. BUG=497445 Change-Id: I705ae8735823ab7f4b26cf7696cdb746936e4447 Reviewed-on: https://chromium-review.googlesource.com/308001 Tryjob-Request: Kenneth Russell <kbr@chromium.org> Tested-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
//
// Copyright 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.
//
#include "test_utils/ANGLETest.h"
using namespace angle;
class DiscardFramebufferEXTTest : public ANGLETest
{
protected:
DiscardFramebufferEXTTest()
{
setWindowWidth(256);
setWindowHeight(256);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
setConfigStencilBits(8);
}
};
TEST_P(DiscardFramebufferEXTTest, ExtensionEnabled)
{
EGLPlatformParameters platform = GetParam().eglParameters;
if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
EXPECT_TRUE(extensionEnabled("EXT_discard_framebuffer"));
}
else
{
// Other platforms don't currently implement this extension
EXPECT_FALSE(extensionEnabled("EXT_discard_framebuffer"));
}
}
TEST_P(DiscardFramebufferEXTTest, DefaultFramebuffer)
{
if (!extensionEnabled("EXT_discard_framebuffer"))
{
std::cout << "Test skipped because EXT_discard_framebuffer is not available." << std::endl;
return;
}
// These should succeed on the default framebuffer
const GLenum discards1[] = { GL_COLOR_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards1);
EXPECT_GL_NO_ERROR();
const GLenum discards2[] = { GL_DEPTH_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards2);
EXPECT_GL_NO_ERROR();
const GLenum discards3[] = { GL_STENCIL_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards3);
EXPECT_GL_NO_ERROR();
const GLenum discards4[] = { GL_STENCIL_EXT, GL_COLOR_EXT, GL_DEPTH_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, discards4);
EXPECT_GL_NO_ERROR();
// These should fail on the default framebuffer
const GLenum discards5[] = { GL_COLOR_ATTACHMENT0 };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards5);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
const GLenum discards6[] = { GL_DEPTH_ATTACHMENT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards6);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
const GLenum discards7[] = { GL_STENCIL_ATTACHMENT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards7);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
}
TEST_P(DiscardFramebufferEXTTest, NonDefaultFramebuffer)
{
if (!extensionEnabled("EXT_discard_framebuffer"))
{
std::cout << "Test skipped because EXT_discard_framebuffer is not available." << std::endl;
return;
}
GLuint tex2D;
GLuint framebuffer;
// Create a basic off-screen framebuffer
// Don't create a depth/stencil texture, to ensure that also works correctly
glGenTextures(1, &tex2D);
glGenFramebuffers(1, &framebuffer);
glBindTexture(GL_TEXTURE_2D, tex2D);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, getWindowWidth(), getWindowHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
// These should fail on the non-default framebuffer
const GLenum discards1[] = { GL_COLOR_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards1);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
const GLenum discards2[] = { GL_DEPTH_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards2);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
const GLenum discards3[] = { GL_STENCIL_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards3);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
const GLenum discards4[] = { GL_STENCIL_EXT, GL_COLOR_EXT, GL_DEPTH_EXT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, discards4);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
// These should succeed on the non-default framebuffer
const GLenum discards5[] = { GL_COLOR_ATTACHMENT0 };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards5);
EXPECT_GL_NO_ERROR();
const GLenum discards6[] = { GL_DEPTH_ATTACHMENT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards6);
EXPECT_GL_NO_ERROR();
const GLenum discards7[] = { GL_STENCIL_ATTACHMENT };
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards7);
EXPECT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(DiscardFramebufferEXTTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3(), ES2_OPENGL(), ES3_OPENGL());