1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2023 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker // Test state requests and compilation of tokens added by OES_shader_multisample_interpolation
7*8975f5c5SAndroid Build Coastguard Worker
8*8975f5c5SAndroid Build Coastguard Worker #include "common/mathutil.h"
9*8975f5c5SAndroid Build Coastguard Worker #include "test_utils/ANGLETest.h"
10*8975f5c5SAndroid Build Coastguard Worker #include "test_utils/gl_raii.h"
11*8975f5c5SAndroid Build Coastguard Worker
12*8975f5c5SAndroid Build Coastguard Worker using namespace angle;
13*8975f5c5SAndroid Build Coastguard Worker
14*8975f5c5SAndroid Build Coastguard Worker namespace
15*8975f5c5SAndroid Build Coastguard Worker {
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard Worker class SampleMultisampleInterpolationTest : public ANGLETest<>
18*8975f5c5SAndroid Build Coastguard Worker {
19*8975f5c5SAndroid Build Coastguard Worker protected:
SampleMultisampleInterpolationTest()20*8975f5c5SAndroid Build Coastguard Worker SampleMultisampleInterpolationTest()
21*8975f5c5SAndroid Build Coastguard Worker {
22*8975f5c5SAndroid Build Coastguard Worker setConfigRedBits(8);
23*8975f5c5SAndroid Build Coastguard Worker setConfigGreenBits(8);
24*8975f5c5SAndroid Build Coastguard Worker setConfigBlueBits(8);
25*8975f5c5SAndroid Build Coastguard Worker setConfigAlphaBits(8);
26*8975f5c5SAndroid Build Coastguard Worker setExtensionsEnabled(false);
27*8975f5c5SAndroid Build Coastguard Worker }
28*8975f5c5SAndroid Build Coastguard Worker };
29*8975f5c5SAndroid Build Coastguard Worker
30*8975f5c5SAndroid Build Coastguard Worker // Test state queries
TEST_P(SampleMultisampleInterpolationTest,StateQueries)31*8975f5c5SAndroid Build Coastguard Worker TEST_P(SampleMultisampleInterpolationTest, StateQueries)
32*8975f5c5SAndroid Build Coastguard Worker {
33*8975f5c5SAndroid Build Coastguard Worker // New state queries fail without the extension
34*8975f5c5SAndroid Build Coastguard Worker {
35*8975f5c5SAndroid Build Coastguard Worker GLint bits = 0;
36*8975f5c5SAndroid Build Coastguard Worker glGetIntegerv(GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES, &bits);
37*8975f5c5SAndroid Build Coastguard Worker EXPECT_GL_ERROR(GL_INVALID_ENUM);
38*8975f5c5SAndroid Build Coastguard Worker EXPECT_EQ(bits, 0);
39*8975f5c5SAndroid Build Coastguard Worker
40*8975f5c5SAndroid Build Coastguard Worker GLfloat minOffset = 0.0f;
41*8975f5c5SAndroid Build Coastguard Worker glGetFloatv(GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES, &minOffset);
42*8975f5c5SAndroid Build Coastguard Worker EXPECT_GL_ERROR(GL_INVALID_ENUM);
43*8975f5c5SAndroid Build Coastguard Worker EXPECT_EQ(minOffset, 0.0f);
44*8975f5c5SAndroid Build Coastguard Worker
45*8975f5c5SAndroid Build Coastguard Worker GLfloat maxOffset = 0.0f;
46*8975f5c5SAndroid Build Coastguard Worker glGetFloatv(GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES, &maxOffset);
47*8975f5c5SAndroid Build Coastguard Worker EXPECT_GL_ERROR(GL_INVALID_ENUM);
48*8975f5c5SAndroid Build Coastguard Worker EXPECT_EQ(maxOffset, 0.0f);
49*8975f5c5SAndroid Build Coastguard Worker
50*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_NO_ERROR();
51*8975f5c5SAndroid Build Coastguard Worker }
52*8975f5c5SAndroid Build Coastguard Worker
53*8975f5c5SAndroid Build Coastguard Worker ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_shader_multisample_interpolation"));
54*8975f5c5SAndroid Build Coastguard Worker
55*8975f5c5SAndroid Build Coastguard Worker // Implementation-dependent values
56*8975f5c5SAndroid Build Coastguard Worker {
57*8975f5c5SAndroid Build Coastguard Worker GLint bits = 0;
58*8975f5c5SAndroid Build Coastguard Worker glGetIntegerv(GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES, &bits);
59*8975f5c5SAndroid Build Coastguard Worker EXPECT_GE(bits, 4);
60*8975f5c5SAndroid Build Coastguard Worker
61*8975f5c5SAndroid Build Coastguard Worker GLfloat minOffset = 0.0f;
62*8975f5c5SAndroid Build Coastguard Worker glGetFloatv(GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES, &minOffset);
63*8975f5c5SAndroid Build Coastguard Worker EXPECT_LE(minOffset, -0.5f + std::pow(2, -bits));
64*8975f5c5SAndroid Build Coastguard Worker
65*8975f5c5SAndroid Build Coastguard Worker GLfloat maxOffset = 0.0f;
66*8975f5c5SAndroid Build Coastguard Worker glGetFloatv(GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES, &maxOffset);
67*8975f5c5SAndroid Build Coastguard Worker EXPECT_GE(maxOffset, 0.5f - std::pow(2, -bits));
68*8975f5c5SAndroid Build Coastguard Worker
69*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_NO_ERROR();
70*8975f5c5SAndroid Build Coastguard Worker }
71*8975f5c5SAndroid Build Coastguard Worker }
72*8975f5c5SAndroid Build Coastguard Worker
73*8975f5c5SAndroid Build Coastguard Worker // Test gl_SampleMaskIn values with per-sample shading
TEST_P(SampleMultisampleInterpolationTest,SampleMaskInPerSample)74*8975f5c5SAndroid Build Coastguard Worker TEST_P(SampleMultisampleInterpolationTest, SampleMaskInPerSample)
75*8975f5c5SAndroid Build Coastguard Worker {
76*8975f5c5SAndroid Build Coastguard Worker ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_sample_variables"));
77*8975f5c5SAndroid Build Coastguard Worker ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_shader_multisample_interpolation"));
78*8975f5c5SAndroid Build Coastguard Worker
79*8975f5c5SAndroid Build Coastguard Worker const char kVS[] = R"(#version 300 es
80*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_shader_multisample_interpolation : require
81*8975f5c5SAndroid Build Coastguard Worker
82*8975f5c5SAndroid Build Coastguard Worker in vec4 a_position;
83*8975f5c5SAndroid Build Coastguard Worker sample out float interpolant;
84*8975f5c5SAndroid Build Coastguard Worker
85*8975f5c5SAndroid Build Coastguard Worker void main()
86*8975f5c5SAndroid Build Coastguard Worker {
87*8975f5c5SAndroid Build Coastguard Worker gl_Position = a_position;
88*8975f5c5SAndroid Build Coastguard Worker interpolant = 0.5;
89*8975f5c5SAndroid Build Coastguard Worker })";
90*8975f5c5SAndroid Build Coastguard Worker
91*8975f5c5SAndroid Build Coastguard Worker const char kFS[] = R"(#version 300 es
92*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_sample_variables : require
93*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_shader_multisample_interpolation : require
94*8975f5c5SAndroid Build Coastguard Worker
95*8975f5c5SAndroid Build Coastguard Worker precision highp float;
96*8975f5c5SAndroid Build Coastguard Worker sample in float interpolant;
97*8975f5c5SAndroid Build Coastguard Worker out vec4 color;
98*8975f5c5SAndroid Build Coastguard Worker
99*8975f5c5SAndroid Build Coastguard Worker bool isPow2(int v)
100*8975f5c5SAndroid Build Coastguard Worker {
101*8975f5c5SAndroid Build Coastguard Worker return v != 0 && (v & (v - 1)) == 0;
102*8975f5c5SAndroid Build Coastguard Worker }
103*8975f5c5SAndroid Build Coastguard Worker
104*8975f5c5SAndroid Build Coastguard Worker void main()
105*8975f5c5SAndroid Build Coastguard Worker {
106*8975f5c5SAndroid Build Coastguard Worker float r = float(isPow2(gl_SampleMaskIn[0]));
107*8975f5c5SAndroid Build Coastguard Worker color = vec4(r, interpolant, 0, 1);
108*8975f5c5SAndroid Build Coastguard Worker })";
109*8975f5c5SAndroid Build Coastguard Worker
110*8975f5c5SAndroid Build Coastguard Worker ANGLE_GL_PROGRAM(program, kVS, kFS);
111*8975f5c5SAndroid Build Coastguard Worker glUseProgram(program);
112*8975f5c5SAndroid Build Coastguard Worker
113*8975f5c5SAndroid Build Coastguard Worker for (GLint sampleCount : {0, 4})
114*8975f5c5SAndroid Build Coastguard Worker {
115*8975f5c5SAndroid Build Coastguard Worker GLFramebuffer fbo;
116*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_FRAMEBUFFER, fbo);
117*8975f5c5SAndroid Build Coastguard Worker
118*8975f5c5SAndroid Build Coastguard Worker GLRenderbuffer rbo;
119*8975f5c5SAndroid Build Coastguard Worker glBindRenderbuffer(GL_RENDERBUFFER, rbo);
120*8975f5c5SAndroid Build Coastguard Worker glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_RGBA8, 1, 1);
121*8975f5c5SAndroid Build Coastguard Worker glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
122*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
123*8975f5c5SAndroid Build Coastguard Worker
124*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
125*8975f5c5SAndroid Build Coastguard Worker drawQuad(program, "a_position", 0.0);
126*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_NO_ERROR();
127*8975f5c5SAndroid Build Coastguard Worker
128*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
129*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
130*8975f5c5SAndroid Build Coastguard Worker glBlitFramebuffer(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
131*8975f5c5SAndroid Build Coastguard Worker
132*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
133*8975f5c5SAndroid Build Coastguard Worker GLubyte pixel[4];
134*8975f5c5SAndroid Build Coastguard Worker glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
135*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_NO_ERROR();
136*8975f5c5SAndroid Build Coastguard Worker
137*8975f5c5SAndroid Build Coastguard Worker EXPECT_EQ(pixel[0], 255) << "Samples: " << sampleCount;
138*8975f5c5SAndroid Build Coastguard Worker }
139*8975f5c5SAndroid Build Coastguard Worker }
140*8975f5c5SAndroid Build Coastguard Worker
141*8975f5c5SAndroid Build Coastguard Worker // Test gl_SampleMaskIn values with per-sample noperspective shading
TEST_P(SampleMultisampleInterpolationTest,SampleMaskInPerSampleNoPerspective)142*8975f5c5SAndroid Build Coastguard Worker TEST_P(SampleMultisampleInterpolationTest, SampleMaskInPerSampleNoPerspective)
143*8975f5c5SAndroid Build Coastguard Worker {
144*8975f5c5SAndroid Build Coastguard Worker ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_sample_variables"));
145*8975f5c5SAndroid Build Coastguard Worker ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_shader_multisample_interpolation"));
146*8975f5c5SAndroid Build Coastguard Worker ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_NV_shader_noperspective_interpolation"));
147*8975f5c5SAndroid Build Coastguard Worker
148*8975f5c5SAndroid Build Coastguard Worker const char kVS[] = R"(#version 300 es
149*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_shader_multisample_interpolation : require
150*8975f5c5SAndroid Build Coastguard Worker #extension GL_NV_shader_noperspective_interpolation : require
151*8975f5c5SAndroid Build Coastguard Worker
152*8975f5c5SAndroid Build Coastguard Worker in vec4 a_position;
153*8975f5c5SAndroid Build Coastguard Worker noperspective sample out float interpolant;
154*8975f5c5SAndroid Build Coastguard Worker
155*8975f5c5SAndroid Build Coastguard Worker void main()
156*8975f5c5SAndroid Build Coastguard Worker {
157*8975f5c5SAndroid Build Coastguard Worker gl_Position = a_position;
158*8975f5c5SAndroid Build Coastguard Worker interpolant = 0.5;
159*8975f5c5SAndroid Build Coastguard Worker })";
160*8975f5c5SAndroid Build Coastguard Worker
161*8975f5c5SAndroid Build Coastguard Worker const char kFS[] = R"(#version 300 es
162*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_sample_variables : require
163*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_shader_multisample_interpolation : require
164*8975f5c5SAndroid Build Coastguard Worker #extension GL_NV_shader_noperspective_interpolation : require
165*8975f5c5SAndroid Build Coastguard Worker
166*8975f5c5SAndroid Build Coastguard Worker precision highp float;
167*8975f5c5SAndroid Build Coastguard Worker noperspective sample in float interpolant;
168*8975f5c5SAndroid Build Coastguard Worker out vec4 color;
169*8975f5c5SAndroid Build Coastguard Worker
170*8975f5c5SAndroid Build Coastguard Worker bool isPow2(int v)
171*8975f5c5SAndroid Build Coastguard Worker {
172*8975f5c5SAndroid Build Coastguard Worker return v != 0 && (v & (v - 1)) == 0;
173*8975f5c5SAndroid Build Coastguard Worker }
174*8975f5c5SAndroid Build Coastguard Worker
175*8975f5c5SAndroid Build Coastguard Worker void main()
176*8975f5c5SAndroid Build Coastguard Worker {
177*8975f5c5SAndroid Build Coastguard Worker float r = float(isPow2(gl_SampleMaskIn[0]));
178*8975f5c5SAndroid Build Coastguard Worker color = vec4(r, interpolant, 0, 1);
179*8975f5c5SAndroid Build Coastguard Worker })";
180*8975f5c5SAndroid Build Coastguard Worker
181*8975f5c5SAndroid Build Coastguard Worker ANGLE_GL_PROGRAM(program, kVS, kFS);
182*8975f5c5SAndroid Build Coastguard Worker glUseProgram(program);
183*8975f5c5SAndroid Build Coastguard Worker
184*8975f5c5SAndroid Build Coastguard Worker for (GLint sampleCount : {0, 4})
185*8975f5c5SAndroid Build Coastguard Worker {
186*8975f5c5SAndroid Build Coastguard Worker GLFramebuffer fbo;
187*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_FRAMEBUFFER, fbo);
188*8975f5c5SAndroid Build Coastguard Worker
189*8975f5c5SAndroid Build Coastguard Worker GLRenderbuffer rbo;
190*8975f5c5SAndroid Build Coastguard Worker glBindRenderbuffer(GL_RENDERBUFFER, rbo);
191*8975f5c5SAndroid Build Coastguard Worker glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_RGBA8, 1, 1);
192*8975f5c5SAndroid Build Coastguard Worker glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
193*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
194*8975f5c5SAndroid Build Coastguard Worker
195*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
196*8975f5c5SAndroid Build Coastguard Worker drawQuad(program, "a_position", 0.0);
197*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_NO_ERROR();
198*8975f5c5SAndroid Build Coastguard Worker
199*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
200*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
201*8975f5c5SAndroid Build Coastguard Worker glBlitFramebuffer(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
202*8975f5c5SAndroid Build Coastguard Worker
203*8975f5c5SAndroid Build Coastguard Worker glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
204*8975f5c5SAndroid Build Coastguard Worker GLubyte pixel[4];
205*8975f5c5SAndroid Build Coastguard Worker glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
206*8975f5c5SAndroid Build Coastguard Worker ASSERT_GL_NO_ERROR();
207*8975f5c5SAndroid Build Coastguard Worker
208*8975f5c5SAndroid Build Coastguard Worker EXPECT_EQ(pixel[0], 255) << "Samples: " << sampleCount;
209*8975f5c5SAndroid Build Coastguard Worker }
210*8975f5c5SAndroid Build Coastguard Worker }
211*8975f5c5SAndroid Build Coastguard Worker
212*8975f5c5SAndroid Build Coastguard Worker // Test that a shader with interpolateAt* calls and directly used interpolants compiles
213*8975f5c5SAndroid Build Coastguard Worker // successfully.
TEST_P(SampleMultisampleInterpolationTest,CompileInterpolateAt)214*8975f5c5SAndroid Build Coastguard Worker TEST_P(SampleMultisampleInterpolationTest, CompileInterpolateAt)
215*8975f5c5SAndroid Build Coastguard Worker {
216*8975f5c5SAndroid Build Coastguard Worker ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_shader_multisample_interpolation"));
217*8975f5c5SAndroid Build Coastguard Worker
218*8975f5c5SAndroid Build Coastguard Worker EnsureGLExtensionEnabled("GL_NV_shader_noperspective_interpolation");
219*8975f5c5SAndroid Build Coastguard Worker
220*8975f5c5SAndroid Build Coastguard Worker constexpr char kVS[] = R"(#version 300 es
221*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_shader_multisample_interpolation : require
222*8975f5c5SAndroid Build Coastguard Worker #extension GL_NV_shader_noperspective_interpolation : enable
223*8975f5c5SAndroid Build Coastguard Worker
224*8975f5c5SAndroid Build Coastguard Worker precision highp float;
225*8975f5c5SAndroid Build Coastguard Worker
226*8975f5c5SAndroid Build Coastguard Worker out float interpolant;
227*8975f5c5SAndroid Build Coastguard Worker out float interpolantArray[2];
228*8975f5c5SAndroid Build Coastguard Worker
229*8975f5c5SAndroid Build Coastguard Worker centroid out float interpolantCentroid;
230*8975f5c5SAndroid Build Coastguard Worker centroid out float interpolantCentroidArray[2];
231*8975f5c5SAndroid Build Coastguard Worker
232*8975f5c5SAndroid Build Coastguard Worker sample out float interpolantSample;
233*8975f5c5SAndroid Build Coastguard Worker sample out float interpolantSampleArray[2];
234*8975f5c5SAndroid Build Coastguard Worker
235*8975f5c5SAndroid Build Coastguard Worker smooth out float interpolantSmooth;
236*8975f5c5SAndroid Build Coastguard Worker smooth out float interpolantSmoothArray[2];
237*8975f5c5SAndroid Build Coastguard Worker
238*8975f5c5SAndroid Build Coastguard Worker flat out float interpolantFlat;
239*8975f5c5SAndroid Build Coastguard Worker flat out float interpolantFlatArray[2];
240*8975f5c5SAndroid Build Coastguard Worker
241*8975f5c5SAndroid Build Coastguard Worker #ifdef GL_NV_shader_noperspective_interpolation
242*8975f5c5SAndroid Build Coastguard Worker noperspective out float interpolantNp;
243*8975f5c5SAndroid Build Coastguard Worker noperspective out float interpolantNpArray[2];
244*8975f5c5SAndroid Build Coastguard Worker
245*8975f5c5SAndroid Build Coastguard Worker noperspective centroid out float interpolantNpCentroid;
246*8975f5c5SAndroid Build Coastguard Worker noperspective centroid out float interpolantNpCentroidArray[2];
247*8975f5c5SAndroid Build Coastguard Worker
248*8975f5c5SAndroid Build Coastguard Worker noperspective sample out float interpolantNpSample;
249*8975f5c5SAndroid Build Coastguard Worker noperspective sample out float interpolantNpSampleArray[2];
250*8975f5c5SAndroid Build Coastguard Worker #endif
251*8975f5c5SAndroid Build Coastguard Worker
252*8975f5c5SAndroid Build Coastguard Worker void main()
253*8975f5c5SAndroid Build Coastguard Worker {
254*8975f5c5SAndroid Build Coastguard Worker gl_Position = vec4(0, 0, 0, 1);
255*8975f5c5SAndroid Build Coastguard Worker
256*8975f5c5SAndroid Build Coastguard Worker interpolant = 1.0;
257*8975f5c5SAndroid Build Coastguard Worker interpolantArray[1] = 2.0;
258*8975f5c5SAndroid Build Coastguard Worker
259*8975f5c5SAndroid Build Coastguard Worker interpolantCentroid = 3.0;
260*8975f5c5SAndroid Build Coastguard Worker interpolantCentroidArray[1] = 4.0;
261*8975f5c5SAndroid Build Coastguard Worker
262*8975f5c5SAndroid Build Coastguard Worker interpolantSample = 5.0;
263*8975f5c5SAndroid Build Coastguard Worker interpolantSampleArray[1] = 6.0;
264*8975f5c5SAndroid Build Coastguard Worker
265*8975f5c5SAndroid Build Coastguard Worker interpolantSmooth = 7.0;
266*8975f5c5SAndroid Build Coastguard Worker interpolantSmoothArray[1] = 8.0;
267*8975f5c5SAndroid Build Coastguard Worker
268*8975f5c5SAndroid Build Coastguard Worker interpolantFlat = 9.0;
269*8975f5c5SAndroid Build Coastguard Worker interpolantFlatArray[1] = 10.0;
270*8975f5c5SAndroid Build Coastguard Worker
271*8975f5c5SAndroid Build Coastguard Worker #ifdef GL_NV_shader_noperspective_interpolation
272*8975f5c5SAndroid Build Coastguard Worker interpolantNp = 11.0;
273*8975f5c5SAndroid Build Coastguard Worker interpolantNpArray[1] = 12.0;
274*8975f5c5SAndroid Build Coastguard Worker
275*8975f5c5SAndroid Build Coastguard Worker interpolantNpCentroid = 13.0;
276*8975f5c5SAndroid Build Coastguard Worker interpolantNpCentroidArray[1] = 14.0;
277*8975f5c5SAndroid Build Coastguard Worker
278*8975f5c5SAndroid Build Coastguard Worker interpolantNpSample = 15.0;
279*8975f5c5SAndroid Build Coastguard Worker interpolantNpSampleArray[1] = 16.0;
280*8975f5c5SAndroid Build Coastguard Worker #endif
281*8975f5c5SAndroid Build Coastguard Worker })";
282*8975f5c5SAndroid Build Coastguard Worker
283*8975f5c5SAndroid Build Coastguard Worker constexpr char kFS[] = R"(#version 300 es
284*8975f5c5SAndroid Build Coastguard Worker #extension GL_OES_shader_multisample_interpolation : require
285*8975f5c5SAndroid Build Coastguard Worker #extension GL_NV_shader_noperspective_interpolation : enable
286*8975f5c5SAndroid Build Coastguard Worker
287*8975f5c5SAndroid Build Coastguard Worker precision highp float;
288*8975f5c5SAndroid Build Coastguard Worker
289*8975f5c5SAndroid Build Coastguard Worker in float interpolant;
290*8975f5c5SAndroid Build Coastguard Worker in float interpolantArray[2];
291*8975f5c5SAndroid Build Coastguard Worker
292*8975f5c5SAndroid Build Coastguard Worker centroid in float interpolantCentroid;
293*8975f5c5SAndroid Build Coastguard Worker centroid in float interpolantCentroidArray[2];
294*8975f5c5SAndroid Build Coastguard Worker
295*8975f5c5SAndroid Build Coastguard Worker sample in float interpolantSample;
296*8975f5c5SAndroid Build Coastguard Worker sample in float interpolantSampleArray[2];
297*8975f5c5SAndroid Build Coastguard Worker
298*8975f5c5SAndroid Build Coastguard Worker smooth in float interpolantSmooth;
299*8975f5c5SAndroid Build Coastguard Worker smooth in float interpolantSmoothArray[2];
300*8975f5c5SAndroid Build Coastguard Worker
301*8975f5c5SAndroid Build Coastguard Worker flat in float interpolantFlat;
302*8975f5c5SAndroid Build Coastguard Worker flat in float interpolantFlatArray[2];
303*8975f5c5SAndroid Build Coastguard Worker
304*8975f5c5SAndroid Build Coastguard Worker #ifdef GL_NV_shader_noperspective_interpolation
305*8975f5c5SAndroid Build Coastguard Worker noperspective in float interpolantNp;
306*8975f5c5SAndroid Build Coastguard Worker noperspective in float interpolantNpArray[2];
307*8975f5c5SAndroid Build Coastguard Worker
308*8975f5c5SAndroid Build Coastguard Worker noperspective centroid in float interpolantNpCentroid;
309*8975f5c5SAndroid Build Coastguard Worker noperspective centroid in float interpolantNpCentroidArray[2];
310*8975f5c5SAndroid Build Coastguard Worker
311*8975f5c5SAndroid Build Coastguard Worker noperspective sample in float interpolantNpSample;
312*8975f5c5SAndroid Build Coastguard Worker noperspective sample in float interpolantNpSampleArray[2];
313*8975f5c5SAndroid Build Coastguard Worker #endif
314*8975f5c5SAndroid Build Coastguard Worker
315*8975f5c5SAndroid Build Coastguard Worker out vec4 color;
316*8975f5c5SAndroid Build Coastguard Worker
317*8975f5c5SAndroid Build Coastguard Worker void main()
318*8975f5c5SAndroid Build Coastguard Worker {
319*8975f5c5SAndroid Build Coastguard Worker float r;
320*8975f5c5SAndroid Build Coastguard Worker
321*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolant);
322*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolant, int(interpolant));
323*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolant, vec2(interpolant));
324*8975f5c5SAndroid Build Coastguard Worker
325*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantArray[1]);
326*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantArray[1], int(interpolantArray[0]));
327*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantArray[1], vec2(interpolantArray[0]));
328*8975f5c5SAndroid Build Coastguard Worker
329*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantCentroid);
330*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantCentroid, int(interpolantCentroid));
331*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantCentroid, vec2(interpolantCentroid));
332*8975f5c5SAndroid Build Coastguard Worker
333*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantCentroidArray[1]);
334*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantCentroidArray[1], int(interpolantCentroidArray[0]));
335*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantCentroidArray[1], vec2(interpolantCentroidArray[0]));
336*8975f5c5SAndroid Build Coastguard Worker
337*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantSample);
338*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantSample, int(interpolantSample));
339*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantSample, vec2(interpolantSample));
340*8975f5c5SAndroid Build Coastguard Worker
341*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantSampleArray[1]);
342*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantSampleArray[1], int(interpolantSampleArray[0]));
343*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantSampleArray[1], vec2(interpolantSampleArray[0]));
344*8975f5c5SAndroid Build Coastguard Worker
345*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantSmooth);
346*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantSmooth, int(interpolantSmooth));
347*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantSmooth, vec2(interpolantSmooth));
348*8975f5c5SAndroid Build Coastguard Worker
349*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantSmoothArray[1]);
350*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantSmoothArray[1], int(interpolantSmoothArray[0]));
351*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantSmoothArray[1], vec2(interpolantSmoothArray[0]));
352*8975f5c5SAndroid Build Coastguard Worker
353*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantFlat);
354*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantFlat, int(interpolantFlat));
355*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantFlat, vec2(interpolantFlat));
356*8975f5c5SAndroid Build Coastguard Worker
357*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantFlatArray[1]);
358*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantFlatArray[1], int(interpolantFlatArray[0]));
359*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantFlatArray[1], vec2(interpolantFlatArray[0]));
360*8975f5c5SAndroid Build Coastguard Worker
361*8975f5c5SAndroid Build Coastguard Worker #ifdef GL_NV_shader_noperspective_interpolation
362*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantNp);
363*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantNp, int(interpolantNp));
364*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantNp, vec2(interpolantNp));
365*8975f5c5SAndroid Build Coastguard Worker
366*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantNpArray[1]);
367*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantNpArray[1], int(interpolantNpArray[0]));
368*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantNpArray[1], vec2(interpolantNpArray[0]));
369*8975f5c5SAndroid Build Coastguard Worker
370*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantNpCentroid);
371*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantNpCentroid, int(interpolantNpCentroid));
372*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantNpCentroid, vec2(interpolantNpCentroid));
373*8975f5c5SAndroid Build Coastguard Worker
374*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantNpCentroidArray[1]);
375*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantNpCentroidArray[1], int(interpolantNpCentroidArray[0]));
376*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantNpCentroidArray[1], vec2(interpolantNpCentroidArray[0]));
377*8975f5c5SAndroid Build Coastguard Worker
378*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantNpSample);
379*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantNpSample, int(interpolantNpSample));
380*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantNpSample, vec2(interpolantNpSample));
381*8975f5c5SAndroid Build Coastguard Worker
382*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtCentroid(interpolantNpSampleArray[1]);
383*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtSample(interpolantNpSampleArray[1], int(interpolantNpSampleArray[0]));
384*8975f5c5SAndroid Build Coastguard Worker r += interpolateAtOffset(interpolantNpSampleArray[1], vec2(interpolantNpSampleArray[0]));
385*8975f5c5SAndroid Build Coastguard Worker #endif
386*8975f5c5SAndroid Build Coastguard Worker
387*8975f5c5SAndroid Build Coastguard Worker color = vec4(r);
388*8975f5c5SAndroid Build Coastguard Worker })";
389*8975f5c5SAndroid Build Coastguard Worker
390*8975f5c5SAndroid Build Coastguard Worker ANGLE_GL_PROGRAM(program, kVS, kFS);
391*8975f5c5SAndroid Build Coastguard Worker }
392*8975f5c5SAndroid Build Coastguard Worker
393*8975f5c5SAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SampleMultisampleInterpolationTest);
394*8975f5c5SAndroid Build Coastguard Worker ANGLE_INSTANTIATE_TEST_ES3(SampleMultisampleInterpolationTest);
395*8975f5c5SAndroid Build Coastguard Worker
396*8975f5c5SAndroid Build Coastguard Worker } // anonymous namespace
397