blob: 8ca37bc06ba914a36a54bb04ebb24700a6860266 [file] [log] [blame]
Austin Kinross08332632015-05-05 13:35:47 -07001//
2// Copyright 2015 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7#include "test_utils/ANGLETest.h"
8
9using namespace angle;
10
11class DiscardFramebufferEXTTest : public ANGLETest
12{
13protected:
14 DiscardFramebufferEXTTest()
15 {
16 setWindowWidth(256);
17 setWindowHeight(256);
18 setConfigRedBits(8);
19 setConfigGreenBits(8);
20 setConfigBlueBits(8);
21 setConfigAlphaBits(8);
22 setConfigDepthBits(24);
23 setConfigStencilBits(8);
24 }
25};
26
27TEST_P(DiscardFramebufferEXTTest, ExtensionEnabled)
28{
29 EGLPlatformParameters platform = GetParam().mEGLPlatformParameters;
30
31 if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
32 {
33 // EXPECT_TRUE(extensionEnabled("EXT_discard_framebuffer"));
34
35 // EXT_discard_framebuffer is disabled in D3D11 ANGLE due to Chromium BUG:497445
36 // Enabling this extension (even as a no-op) causes WebGL video failures in Chromium
37 // Once this bug is fixed, we can reenable the extension.
38 EXPECT_FALSE(extensionEnabled("EXT_discard_framebuffer"));
39 }
40 else
41 {
42 // Other platforms don't currently implement this extension
43 EXPECT_FALSE(extensionEnabled("EXT_discard_framebuffer"));
44 }
45}
46
47TEST_P(DiscardFramebufferEXTTest, DefaultFramebuffer)
48{
49 if (!extensionEnabled("EXT_discard_framebuffer"))
50 {
51 std::cout << "Test skipped because EXT_discard_framebuffer is not available." << std::endl;
52 return;
53 }
54
55 // These should succeed on the default framebuffer
56 const GLenum discards1[] = { GL_COLOR_EXT };
57 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards1);
58 EXPECT_GL_NO_ERROR();
59
60 const GLenum discards2[] = { GL_DEPTH_EXT };
61 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards2);
62 EXPECT_GL_NO_ERROR();
63
64 const GLenum discards3[] = { GL_STENCIL_EXT };
65 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards3);
66 EXPECT_GL_NO_ERROR();
67
68 const GLenum discards4[] = { GL_STENCIL_EXT, GL_COLOR_EXT, GL_DEPTH_EXT };
69 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, discards4);
70 EXPECT_GL_NO_ERROR();
71
72 // These should fail on the default framebuffer
73 const GLenum discards5[] = { GL_COLOR_ATTACHMENT0 };
74 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards5);
75 EXPECT_GL_ERROR(GL_INVALID_ENUM);
76
77 const GLenum discards6[] = { GL_DEPTH_ATTACHMENT };
78 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards6);
79 EXPECT_GL_ERROR(GL_INVALID_ENUM);
80
81 const GLenum discards7[] = { GL_STENCIL_ATTACHMENT };
82 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards7);
83 EXPECT_GL_ERROR(GL_INVALID_ENUM);
84}
85
86TEST_P(DiscardFramebufferEXTTest, NonDefaultFramebuffer)
87{
88 if (!extensionEnabled("EXT_discard_framebuffer"))
89 {
90 std::cout << "Test skipped because EXT_discard_framebuffer is not available." << std::endl;
91 return;
92 }
93
94 GLuint tex2D;
95 GLuint framebuffer;
96
97 // Create a basic off-screen framebuffer
98 // Don't create a depth/stencil texture, to ensure that also works correctly
99 glGenTextures(1, &tex2D);
100 glGenFramebuffers(1, &framebuffer);
101 glBindTexture(GL_TEXTURE_2D, tex2D);
102 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
103 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, getWindowWidth(), getWindowHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
104 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
105 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
106 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 0);
107 ASSERT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE);
108
109 // These should fail on the non-default framebuffer
110 const GLenum discards1[] = { GL_COLOR_EXT };
111 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards1);
112 EXPECT_GL_ERROR(GL_INVALID_ENUM);
113
114 const GLenum discards2[] = { GL_DEPTH_EXT };
115 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards2);
116 EXPECT_GL_ERROR(GL_INVALID_ENUM);
117
118 const GLenum discards3[] = { GL_STENCIL_EXT };
119 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards3);
120 EXPECT_GL_ERROR(GL_INVALID_ENUM);
121
122 const GLenum discards4[] = { GL_STENCIL_EXT, GL_COLOR_EXT, GL_DEPTH_EXT };
123 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, discards4);
124 EXPECT_GL_ERROR(GL_INVALID_ENUM);
125
126 // These should succeed on the non-default framebuffer
127 const GLenum discards5[] = { GL_COLOR_ATTACHMENT0 };
128 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards5);
129 EXPECT_GL_NO_ERROR();
130
131 const GLenum discards6[] = { GL_DEPTH_ATTACHMENT };
132 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards6);
133 EXPECT_GL_NO_ERROR();
134
135 const GLenum discards7[] = { GL_STENCIL_ATTACHMENT };
136 glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards7);
137 EXPECT_GL_NO_ERROR();
138}
139
140// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
141ANGLE_INSTANTIATE_TEST(DiscardFramebufferEXTTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3(), ES2_OPENGL(), ES3_OPENGL());