1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 3.1 Module
3*35238bceSAndroid Build Coastguard Worker * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Shader state query tests
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es31fShaderStateQueryTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "es31fInfoLogQueryShared.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuStringTemplate.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker namespace deqp
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker namespace gles31
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace Functional
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker namespace
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker
brokenShaderSource(const glu::ContextType & contextType)46*35238bceSAndroid Build Coastguard Worker static inline std::string brokenShaderSource(const glu::ContextType &contextType)
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker const std::string glslVersionDecl = glu::getGLSLVersionDeclaration(glu::getContextTypeGLSLVersion(contextType));
49*35238bceSAndroid Build Coastguard Worker
50*35238bceSAndroid Build Coastguard Worker return glslVersionDecl + "\n"
51*35238bceSAndroid Build Coastguard Worker "broken, this should not compile,\n"
52*35238bceSAndroid Build Coastguard Worker "{";
53*35238bceSAndroid Build Coastguard Worker }
54*35238bceSAndroid Build Coastguard Worker
55*35238bceSAndroid Build Coastguard Worker class BaseTypeCase : public TestCase
56*35238bceSAndroid Build Coastguard Worker {
57*35238bceSAndroid Build Coastguard Worker public:
58*35238bceSAndroid Build Coastguard Worker struct TestTypeInfo
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker glw::GLenum glType;
61*35238bceSAndroid Build Coastguard Worker const char *declarationStr;
62*35238bceSAndroid Build Coastguard Worker const char *accessStr;
63*35238bceSAndroid Build Coastguard Worker };
64*35238bceSAndroid Build Coastguard Worker
65*35238bceSAndroid Build Coastguard Worker BaseTypeCase(Context &ctx, const char *name, const char *desc, const char *extension);
66*35238bceSAndroid Build Coastguard Worker
67*35238bceSAndroid Build Coastguard Worker private:
68*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
69*35238bceSAndroid Build Coastguard Worker virtual std::vector<TestTypeInfo> getInfos(void) const = 0;
70*35238bceSAndroid Build Coastguard Worker virtual void checkRequirements(void) const;
71*35238bceSAndroid Build Coastguard Worker
72*35238bceSAndroid Build Coastguard Worker const char *const m_extension;
73*35238bceSAndroid Build Coastguard Worker };
74*35238bceSAndroid Build Coastguard Worker
BaseTypeCase(Context & ctx,const char * name,const char * desc,const char * extension)75*35238bceSAndroid Build Coastguard Worker BaseTypeCase::BaseTypeCase(Context &ctx, const char *name, const char *desc, const char *extension)
76*35238bceSAndroid Build Coastguard Worker : TestCase(ctx, name, desc)
77*35238bceSAndroid Build Coastguard Worker , m_extension(extension)
78*35238bceSAndroid Build Coastguard Worker {
79*35238bceSAndroid Build Coastguard Worker }
80*35238bceSAndroid Build Coastguard Worker
iterate(void)81*35238bceSAndroid Build Coastguard Worker BaseTypeCase::IterateResult BaseTypeCase::iterate(void)
82*35238bceSAndroid Build Coastguard Worker {
83*35238bceSAndroid Build Coastguard Worker static const char *const vertexSourceTemplate = "${VERSIONDECL}\n"
84*35238bceSAndroid Build Coastguard Worker "in highp vec4 a_position;\n"
85*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
86*35238bceSAndroid Build Coastguard Worker "{\n"
87*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
88*35238bceSAndroid Build Coastguard Worker "}\n";
89*35238bceSAndroid Build Coastguard Worker static const char *const fragmentSourceTemplate = "${VERSIONDECL}\n"
90*35238bceSAndroid Build Coastguard Worker "${EXTENSIONSTATEMENT}"
91*35238bceSAndroid Build Coastguard Worker "${DECLARATIONSTR};\n"
92*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out highp vec4 dEQP_FragColor;\n"
93*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
94*35238bceSAndroid Build Coastguard Worker "{\n"
95*35238bceSAndroid Build Coastguard Worker " dEQP_FragColor = vec4(${ACCESSSTR});\n"
96*35238bceSAndroid Build Coastguard Worker "}\n";
97*35238bceSAndroid Build Coastguard Worker
98*35238bceSAndroid Build Coastguard Worker tcu::ResultCollector result(m_testCtx.getLog());
99*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> samplerTypes = getInfos();
100*35238bceSAndroid Build Coastguard Worker auto ctxType = m_context.getRenderContext().getType();
101*35238bceSAndroid Build Coastguard Worker const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) ||
102*35238bceSAndroid Build Coastguard Worker glu::contextSupports(ctxType, glu::ApiType::core(4, 5));
103*35238bceSAndroid Build Coastguard Worker
104*35238bceSAndroid Build Coastguard Worker if (m_extension && !isES32orGL45 && !m_context.getContextInfo().isExtensionSupported(m_extension))
105*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires " + std::string(m_extension));
106*35238bceSAndroid Build Coastguard Worker checkRequirements();
107*35238bceSAndroid Build Coastguard Worker
108*35238bceSAndroid Build Coastguard Worker for (int typeNdx = 0; typeNdx < (int)samplerTypes.size(); ++typeNdx)
109*35238bceSAndroid Build Coastguard Worker {
110*35238bceSAndroid Build Coastguard Worker const tcu::ScopedLogSection section(
111*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog(), std::string(glu::getShaderVarTypeStr(samplerTypes[typeNdx].glType).toString()),
112*35238bceSAndroid Build Coastguard Worker "Uniform type " + glu::getShaderVarTypeStr(samplerTypes[typeNdx].glType).toString());
113*35238bceSAndroid Build Coastguard Worker
114*35238bceSAndroid Build Coastguard Worker std::map<std::string, std::string> shaderArgs;
115*35238bceSAndroid Build Coastguard Worker shaderArgs["DECLARATIONSTR"] = samplerTypes[typeNdx].declarationStr;
116*35238bceSAndroid Build Coastguard Worker shaderArgs["ACCESSSTR"] = samplerTypes[typeNdx].accessStr;
117*35238bceSAndroid Build Coastguard Worker shaderArgs["EXTENSIONSTATEMENT"] =
118*35238bceSAndroid Build Coastguard Worker (m_extension && !isES32orGL45) ? (std::string() + "#extension " + m_extension + " : require\n") : ("");
119*35238bceSAndroid Build Coastguard Worker shaderArgs["VERSIONDECL"] = glu::getGLSLVersionDeclaration(glu::getContextTypeGLSLVersion(ctxType));
120*35238bceSAndroid Build Coastguard Worker
121*35238bceSAndroid Build Coastguard Worker const std::string fragmentSource = tcu::StringTemplate(fragmentSourceTemplate).specialize(shaderArgs);
122*35238bceSAndroid Build Coastguard Worker const std::string vertexSource = tcu::StringTemplate(vertexSourceTemplate).specialize(shaderArgs);
123*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
124*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(), glu::ProgramSources()
125*35238bceSAndroid Build Coastguard Worker << glu::VertexSource(vertexSource)
126*35238bceSAndroid Build Coastguard Worker << glu::FragmentSource(fragmentSource));
127*35238bceSAndroid Build Coastguard Worker
128*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Building program with uniform sampler of type "
129*35238bceSAndroid Build Coastguard Worker << glu::getShaderVarTypeStr(samplerTypes[typeNdx].glType) << tcu::TestLog::EndMessage;
130*35238bceSAndroid Build Coastguard Worker
131*35238bceSAndroid Build Coastguard Worker if (!program.isOk())
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << program;
134*35238bceSAndroid Build Coastguard Worker result.fail("could not build shader");
135*35238bceSAndroid Build Coastguard Worker }
136*35238bceSAndroid Build Coastguard Worker else
137*35238bceSAndroid Build Coastguard Worker {
138*35238bceSAndroid Build Coastguard Worker // only one uniform -- uniform at index 0
139*35238bceSAndroid Build Coastguard Worker int uniforms = 0;
140*35238bceSAndroid Build Coastguard Worker gl.getProgramiv(program.getProgram(), GL_ACTIVE_UNIFORMS, &uniforms);
141*35238bceSAndroid Build Coastguard Worker
142*35238bceSAndroid Build Coastguard Worker if (uniforms != 1)
143*35238bceSAndroid Build Coastguard Worker result.fail("Unexpected GL_ACTIVE_UNIFORMS, expected 1");
144*35238bceSAndroid Build Coastguard Worker else
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker // check type
147*35238bceSAndroid Build Coastguard Worker const glw::GLuint uniformIndex = 0;
148*35238bceSAndroid Build Coastguard Worker glw::GLint type = 0;
149*35238bceSAndroid Build Coastguard Worker
150*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Verifying uniform type." << tcu::TestLog::EndMessage;
151*35238bceSAndroid Build Coastguard Worker gl.getActiveUniformsiv(program.getProgram(), 1, &uniformIndex, GL_UNIFORM_TYPE, &type);
152*35238bceSAndroid Build Coastguard Worker
153*35238bceSAndroid Build Coastguard Worker if (type != (glw::GLint)samplerTypes[typeNdx].glType)
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker std::ostringstream buf;
156*35238bceSAndroid Build Coastguard Worker buf << "Invalid type, expected " << samplerTypes[typeNdx].glType << ", got " << type;
157*35238bceSAndroid Build Coastguard Worker result.fail(buf.str());
158*35238bceSAndroid Build Coastguard Worker }
159*35238bceSAndroid Build Coastguard Worker }
160*35238bceSAndroid Build Coastguard Worker }
161*35238bceSAndroid Build Coastguard Worker
162*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "");
163*35238bceSAndroid Build Coastguard Worker }
164*35238bceSAndroid Build Coastguard Worker
165*35238bceSAndroid Build Coastguard Worker result.setTestContextResult(m_testCtx);
166*35238bceSAndroid Build Coastguard Worker return STOP;
167*35238bceSAndroid Build Coastguard Worker }
168*35238bceSAndroid Build Coastguard Worker
checkRequirements(void) const169*35238bceSAndroid Build Coastguard Worker void BaseTypeCase::checkRequirements(void) const
170*35238bceSAndroid Build Coastguard Worker {
171*35238bceSAndroid Build Coastguard Worker }
172*35238bceSAndroid Build Coastguard Worker
173*35238bceSAndroid Build Coastguard Worker class CoreSamplerTypeCase : public BaseTypeCase
174*35238bceSAndroid Build Coastguard Worker {
175*35238bceSAndroid Build Coastguard Worker public:
176*35238bceSAndroid Build Coastguard Worker CoreSamplerTypeCase(Context &ctx, const char *name, const char *desc);
177*35238bceSAndroid Build Coastguard Worker
178*35238bceSAndroid Build Coastguard Worker private:
179*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> getInfos(void) const;
180*35238bceSAndroid Build Coastguard Worker };
181*35238bceSAndroid Build Coastguard Worker
CoreSamplerTypeCase(Context & ctx,const char * name,const char * desc)182*35238bceSAndroid Build Coastguard Worker CoreSamplerTypeCase::CoreSamplerTypeCase(Context &ctx, const char *name, const char *desc)
183*35238bceSAndroid Build Coastguard Worker : BaseTypeCase(ctx, name, desc, DE_NULL)
184*35238bceSAndroid Build Coastguard Worker {
185*35238bceSAndroid Build Coastguard Worker }
186*35238bceSAndroid Build Coastguard Worker
getInfos(void) const187*35238bceSAndroid Build Coastguard Worker std::vector<BaseTypeCase::TestTypeInfo> CoreSamplerTypeCase::getInfos(void) const
188*35238bceSAndroid Build Coastguard Worker {
189*35238bceSAndroid Build Coastguard Worker static const TestTypeInfo samplerTypes[] = {
190*35238bceSAndroid Build Coastguard Worker {GL_SAMPLER_2D_MULTISAMPLE, "uniform highp sampler2DMS u_sampler",
191*35238bceSAndroid Build Coastguard Worker "texelFetch(u_sampler, ivec2(gl_FragCoord.xy), 0)"},
192*35238bceSAndroid Build Coastguard Worker {GL_INT_SAMPLER_2D_MULTISAMPLE, "uniform highp isampler2DMS u_sampler",
193*35238bceSAndroid Build Coastguard Worker "texelFetch(u_sampler, ivec2(gl_FragCoord.xy), 0)"},
194*35238bceSAndroid Build Coastguard Worker {GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, "uniform highp usampler2DMS u_sampler",
195*35238bceSAndroid Build Coastguard Worker "texelFetch(u_sampler, ivec2(gl_FragCoord.xy), 0)"},
196*35238bceSAndroid Build Coastguard Worker };
197*35238bceSAndroid Build Coastguard Worker
198*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> infos;
199*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(samplerTypes); ++ndx)
200*35238bceSAndroid Build Coastguard Worker infos.push_back(samplerTypes[ndx]);
201*35238bceSAndroid Build Coastguard Worker
202*35238bceSAndroid Build Coastguard Worker return infos;
203*35238bceSAndroid Build Coastguard Worker }
204*35238bceSAndroid Build Coastguard Worker
205*35238bceSAndroid Build Coastguard Worker class MSArraySamplerTypeCase : public BaseTypeCase
206*35238bceSAndroid Build Coastguard Worker {
207*35238bceSAndroid Build Coastguard Worker public:
208*35238bceSAndroid Build Coastguard Worker MSArraySamplerTypeCase(Context &ctx, const char *name, const char *desc);
209*35238bceSAndroid Build Coastguard Worker
210*35238bceSAndroid Build Coastguard Worker private:
211*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> getInfos(void) const;
212*35238bceSAndroid Build Coastguard Worker };
213*35238bceSAndroid Build Coastguard Worker
MSArraySamplerTypeCase(Context & ctx,const char * name,const char * desc)214*35238bceSAndroid Build Coastguard Worker MSArraySamplerTypeCase::MSArraySamplerTypeCase(Context &ctx, const char *name, const char *desc)
215*35238bceSAndroid Build Coastguard Worker : BaseTypeCase(ctx, name, desc, "GL_OES_texture_storage_multisample_2d_array")
216*35238bceSAndroid Build Coastguard Worker {
217*35238bceSAndroid Build Coastguard Worker }
218*35238bceSAndroid Build Coastguard Worker
getInfos(void) const219*35238bceSAndroid Build Coastguard Worker std::vector<BaseTypeCase::TestTypeInfo> MSArraySamplerTypeCase::getInfos(void) const
220*35238bceSAndroid Build Coastguard Worker {
221*35238bceSAndroid Build Coastguard Worker static const TestTypeInfo samplerTypes[] = {
222*35238bceSAndroid Build Coastguard Worker {GL_SAMPLER_2D_MULTISAMPLE_ARRAY, "uniform highp sampler2DMSArray u_sampler",
223*35238bceSAndroid Build Coastguard Worker "texelFetch(u_sampler, ivec3(gl_FragCoord.xyz), 0)"},
224*35238bceSAndroid Build Coastguard Worker {GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, "uniform highp isampler2DMSArray u_sampler",
225*35238bceSAndroid Build Coastguard Worker "texelFetch(u_sampler, ivec3(gl_FragCoord.xyz), 0)"},
226*35238bceSAndroid Build Coastguard Worker {GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, "uniform highp usampler2DMSArray u_sampler",
227*35238bceSAndroid Build Coastguard Worker "texelFetch(u_sampler, ivec3(gl_FragCoord.xyz), 0)"},
228*35238bceSAndroid Build Coastguard Worker };
229*35238bceSAndroid Build Coastguard Worker
230*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> infos;
231*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(samplerTypes); ++ndx)
232*35238bceSAndroid Build Coastguard Worker infos.push_back(samplerTypes[ndx]);
233*35238bceSAndroid Build Coastguard Worker
234*35238bceSAndroid Build Coastguard Worker return infos;
235*35238bceSAndroid Build Coastguard Worker }
236*35238bceSAndroid Build Coastguard Worker
237*35238bceSAndroid Build Coastguard Worker class TextureBufferSamplerTypeCase : public BaseTypeCase
238*35238bceSAndroid Build Coastguard Worker {
239*35238bceSAndroid Build Coastguard Worker public:
240*35238bceSAndroid Build Coastguard Worker TextureBufferSamplerTypeCase(Context &ctx, const char *name, const char *desc);
241*35238bceSAndroid Build Coastguard Worker
242*35238bceSAndroid Build Coastguard Worker private:
243*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> getInfos(void) const;
244*35238bceSAndroid Build Coastguard Worker };
245*35238bceSAndroid Build Coastguard Worker
TextureBufferSamplerTypeCase(Context & ctx,const char * name,const char * desc)246*35238bceSAndroid Build Coastguard Worker TextureBufferSamplerTypeCase::TextureBufferSamplerTypeCase(Context &ctx, const char *name, const char *desc)
247*35238bceSAndroid Build Coastguard Worker : BaseTypeCase(ctx, name, desc, "GL_EXT_texture_buffer")
248*35238bceSAndroid Build Coastguard Worker {
249*35238bceSAndroid Build Coastguard Worker }
250*35238bceSAndroid Build Coastguard Worker
getInfos(void) const251*35238bceSAndroid Build Coastguard Worker std::vector<BaseTypeCase::TestTypeInfo> TextureBufferSamplerTypeCase::getInfos(void) const
252*35238bceSAndroid Build Coastguard Worker {
253*35238bceSAndroid Build Coastguard Worker static const TestTypeInfo samplerTypes[] = {
254*35238bceSAndroid Build Coastguard Worker {GL_SAMPLER_BUFFER, "uniform highp samplerBuffer u_sampler", "texelFetch(u_sampler, int(gl_FragCoord.x))"},
255*35238bceSAndroid Build Coastguard Worker {GL_INT_SAMPLER_BUFFER, "uniform highp isamplerBuffer u_sampler", "texelFetch(u_sampler, int(gl_FragCoord.x))"},
256*35238bceSAndroid Build Coastguard Worker {GL_UNSIGNED_INT_SAMPLER_BUFFER, "uniform highp usamplerBuffer u_sampler",
257*35238bceSAndroid Build Coastguard Worker "texelFetch(u_sampler, int(gl_FragCoord.x))"},
258*35238bceSAndroid Build Coastguard Worker };
259*35238bceSAndroid Build Coastguard Worker
260*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> infos;
261*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(samplerTypes); ++ndx)
262*35238bceSAndroid Build Coastguard Worker infos.push_back(samplerTypes[ndx]);
263*35238bceSAndroid Build Coastguard Worker
264*35238bceSAndroid Build Coastguard Worker return infos;
265*35238bceSAndroid Build Coastguard Worker }
266*35238bceSAndroid Build Coastguard Worker
267*35238bceSAndroid Build Coastguard Worker class TextureBufferImageTypeCase : public BaseTypeCase
268*35238bceSAndroid Build Coastguard Worker {
269*35238bceSAndroid Build Coastguard Worker public:
270*35238bceSAndroid Build Coastguard Worker TextureBufferImageTypeCase(Context &ctx, const char *name, const char *desc);
271*35238bceSAndroid Build Coastguard Worker
272*35238bceSAndroid Build Coastguard Worker private:
273*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> getInfos(void) const;
274*35238bceSAndroid Build Coastguard Worker void checkRequirements(void) const;
275*35238bceSAndroid Build Coastguard Worker };
276*35238bceSAndroid Build Coastguard Worker
TextureBufferImageTypeCase(Context & ctx,const char * name,const char * desc)277*35238bceSAndroid Build Coastguard Worker TextureBufferImageTypeCase::TextureBufferImageTypeCase(Context &ctx, const char *name, const char *desc)
278*35238bceSAndroid Build Coastguard Worker : BaseTypeCase(ctx, name, desc, "GL_EXT_texture_buffer")
279*35238bceSAndroid Build Coastguard Worker {
280*35238bceSAndroid Build Coastguard Worker }
281*35238bceSAndroid Build Coastguard Worker
getInfos(void) const282*35238bceSAndroid Build Coastguard Worker std::vector<BaseTypeCase::TestTypeInfo> TextureBufferImageTypeCase::getInfos(void) const
283*35238bceSAndroid Build Coastguard Worker {
284*35238bceSAndroid Build Coastguard Worker static const TestTypeInfo samplerTypes[] = {
285*35238bceSAndroid Build Coastguard Worker {GL_IMAGE_BUFFER, "layout(binding=0, rgba8) readonly uniform highp imageBuffer u_image",
286*35238bceSAndroid Build Coastguard Worker "imageLoad(u_image, int(gl_FragCoord.x))"},
287*35238bceSAndroid Build Coastguard Worker {GL_INT_IMAGE_BUFFER, "layout(binding=0, r32i) readonly uniform highp iimageBuffer u_image",
288*35238bceSAndroid Build Coastguard Worker "imageLoad(u_image, int(gl_FragCoord.x))"},
289*35238bceSAndroid Build Coastguard Worker {GL_UNSIGNED_INT_IMAGE_BUFFER, "layout(binding=0, r32ui) readonly uniform highp uimageBuffer u_image",
290*35238bceSAndroid Build Coastguard Worker "imageLoad(u_image, int(gl_FragCoord.x))"},
291*35238bceSAndroid Build Coastguard Worker };
292*35238bceSAndroid Build Coastguard Worker
293*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> infos;
294*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(samplerTypes); ++ndx)
295*35238bceSAndroid Build Coastguard Worker infos.push_back(samplerTypes[ndx]);
296*35238bceSAndroid Build Coastguard Worker
297*35238bceSAndroid Build Coastguard Worker return infos;
298*35238bceSAndroid Build Coastguard Worker }
299*35238bceSAndroid Build Coastguard Worker
checkRequirements(void) const300*35238bceSAndroid Build Coastguard Worker void TextureBufferImageTypeCase::checkRequirements(void) const
301*35238bceSAndroid Build Coastguard Worker {
302*35238bceSAndroid Build Coastguard Worker if (m_context.getContextInfo().getInt(GL_MAX_FRAGMENT_IMAGE_UNIFORMS) < 1)
303*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires fragment images");
304*35238bceSAndroid Build Coastguard Worker }
305*35238bceSAndroid Build Coastguard Worker
306*35238bceSAndroid Build Coastguard Worker class CubeArraySamplerTypeCase : public BaseTypeCase
307*35238bceSAndroid Build Coastguard Worker {
308*35238bceSAndroid Build Coastguard Worker public:
309*35238bceSAndroid Build Coastguard Worker CubeArraySamplerTypeCase(Context &ctx, const char *name, const char *desc);
310*35238bceSAndroid Build Coastguard Worker
311*35238bceSAndroid Build Coastguard Worker private:
312*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> getInfos(void) const;
313*35238bceSAndroid Build Coastguard Worker };
314*35238bceSAndroid Build Coastguard Worker
CubeArraySamplerTypeCase(Context & ctx,const char * name,const char * desc)315*35238bceSAndroid Build Coastguard Worker CubeArraySamplerTypeCase::CubeArraySamplerTypeCase(Context &ctx, const char *name, const char *desc)
316*35238bceSAndroid Build Coastguard Worker : BaseTypeCase(ctx, name, desc, "GL_EXT_texture_cube_map_array")
317*35238bceSAndroid Build Coastguard Worker {
318*35238bceSAndroid Build Coastguard Worker }
319*35238bceSAndroid Build Coastguard Worker
getInfos(void) const320*35238bceSAndroid Build Coastguard Worker std::vector<BaseTypeCase::TestTypeInfo> CubeArraySamplerTypeCase::getInfos(void) const
321*35238bceSAndroid Build Coastguard Worker {
322*35238bceSAndroid Build Coastguard Worker static const TestTypeInfo samplerTypes[] = {
323*35238bceSAndroid Build Coastguard Worker {GL_SAMPLER_CUBE_MAP_ARRAY, "uniform highp samplerCubeArray u_sampler",
324*35238bceSAndroid Build Coastguard Worker "texture(u_sampler, gl_FragCoord.xxyz)"},
325*35238bceSAndroid Build Coastguard Worker {GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW, "uniform highp samplerCubeArrayShadow u_sampler",
326*35238bceSAndroid Build Coastguard Worker "texture(u_sampler, gl_FragCoord.xxyz, 0.5)"},
327*35238bceSAndroid Build Coastguard Worker {GL_INT_SAMPLER_CUBE_MAP_ARRAY, "uniform highp isamplerCubeArray u_sampler",
328*35238bceSAndroid Build Coastguard Worker "texture(u_sampler, gl_FragCoord.xxyz)"},
329*35238bceSAndroid Build Coastguard Worker {GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY, "uniform highp usamplerCubeArray u_sampler",
330*35238bceSAndroid Build Coastguard Worker "texture(u_sampler, gl_FragCoord.xxyz)"},
331*35238bceSAndroid Build Coastguard Worker };
332*35238bceSAndroid Build Coastguard Worker
333*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> infos;
334*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(samplerTypes); ++ndx)
335*35238bceSAndroid Build Coastguard Worker infos.push_back(samplerTypes[ndx]);
336*35238bceSAndroid Build Coastguard Worker
337*35238bceSAndroid Build Coastguard Worker return infos;
338*35238bceSAndroid Build Coastguard Worker }
339*35238bceSAndroid Build Coastguard Worker
340*35238bceSAndroid Build Coastguard Worker class CubeArrayImageTypeCase : public BaseTypeCase
341*35238bceSAndroid Build Coastguard Worker {
342*35238bceSAndroid Build Coastguard Worker public:
343*35238bceSAndroid Build Coastguard Worker CubeArrayImageTypeCase(Context &ctx, const char *name, const char *desc);
344*35238bceSAndroid Build Coastguard Worker
345*35238bceSAndroid Build Coastguard Worker private:
346*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> getInfos(void) const;
347*35238bceSAndroid Build Coastguard Worker void checkRequirements(void) const;
348*35238bceSAndroid Build Coastguard Worker };
349*35238bceSAndroid Build Coastguard Worker
CubeArrayImageTypeCase(Context & ctx,const char * name,const char * desc)350*35238bceSAndroid Build Coastguard Worker CubeArrayImageTypeCase::CubeArrayImageTypeCase(Context &ctx, const char *name, const char *desc)
351*35238bceSAndroid Build Coastguard Worker : BaseTypeCase(ctx, name, desc, "GL_EXT_texture_cube_map_array")
352*35238bceSAndroid Build Coastguard Worker {
353*35238bceSAndroid Build Coastguard Worker }
354*35238bceSAndroid Build Coastguard Worker
getInfos(void) const355*35238bceSAndroid Build Coastguard Worker std::vector<BaseTypeCase::TestTypeInfo> CubeArrayImageTypeCase::getInfos(void) const
356*35238bceSAndroid Build Coastguard Worker {
357*35238bceSAndroid Build Coastguard Worker static const TestTypeInfo samplerTypes[] = {
358*35238bceSAndroid Build Coastguard Worker {GL_IMAGE_CUBE_MAP_ARRAY, "layout(binding=0, rgba8) readonly uniform highp imageCubeArray u_image",
359*35238bceSAndroid Build Coastguard Worker "imageLoad(u_image, ivec3(gl_FragCoord.xyx))"},
360*35238bceSAndroid Build Coastguard Worker {GL_INT_IMAGE_CUBE_MAP_ARRAY, "layout(binding=0, r32i) readonly uniform highp iimageCubeArray u_image",
361*35238bceSAndroid Build Coastguard Worker "imageLoad(u_image, ivec3(gl_FragCoord.xyx))"},
362*35238bceSAndroid Build Coastguard Worker {GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY,
363*35238bceSAndroid Build Coastguard Worker "layout(binding=0, r32ui) readonly uniform highp uimageCubeArray u_image",
364*35238bceSAndroid Build Coastguard Worker "imageLoad(u_image, ivec3(gl_FragCoord.xyx))"},
365*35238bceSAndroid Build Coastguard Worker };
366*35238bceSAndroid Build Coastguard Worker
367*35238bceSAndroid Build Coastguard Worker std::vector<TestTypeInfo> infos;
368*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(samplerTypes); ++ndx)
369*35238bceSAndroid Build Coastguard Worker infos.push_back(samplerTypes[ndx]);
370*35238bceSAndroid Build Coastguard Worker
371*35238bceSAndroid Build Coastguard Worker return infos;
372*35238bceSAndroid Build Coastguard Worker }
373*35238bceSAndroid Build Coastguard Worker
checkRequirements(void) const374*35238bceSAndroid Build Coastguard Worker void CubeArrayImageTypeCase::checkRequirements(void) const
375*35238bceSAndroid Build Coastguard Worker {
376*35238bceSAndroid Build Coastguard Worker if (m_context.getContextInfo().getInt(GL_MAX_FRAGMENT_IMAGE_UNIFORMS) < 1)
377*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Test requires fragment images");
378*35238bceSAndroid Build Coastguard Worker }
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker class ShaderLogCase : public TestCase
381*35238bceSAndroid Build Coastguard Worker {
382*35238bceSAndroid Build Coastguard Worker public:
383*35238bceSAndroid Build Coastguard Worker ShaderLogCase(Context &ctx, const char *name, const char *desc, glu::ShaderType shaderType);
384*35238bceSAndroid Build Coastguard Worker
385*35238bceSAndroid Build Coastguard Worker private:
386*35238bceSAndroid Build Coastguard Worker void init(void);
387*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
388*35238bceSAndroid Build Coastguard Worker
389*35238bceSAndroid Build Coastguard Worker const glu::ShaderType m_shaderType;
390*35238bceSAndroid Build Coastguard Worker };
391*35238bceSAndroid Build Coastguard Worker
ShaderLogCase(Context & ctx,const char * name,const char * desc,glu::ShaderType shaderType)392*35238bceSAndroid Build Coastguard Worker ShaderLogCase::ShaderLogCase(Context &ctx, const char *name, const char *desc, glu::ShaderType shaderType)
393*35238bceSAndroid Build Coastguard Worker : TestCase(ctx, name, desc)
394*35238bceSAndroid Build Coastguard Worker , m_shaderType(shaderType)
395*35238bceSAndroid Build Coastguard Worker {
396*35238bceSAndroid Build Coastguard Worker }
397*35238bceSAndroid Build Coastguard Worker
init(void)398*35238bceSAndroid Build Coastguard Worker void ShaderLogCase::init(void)
399*35238bceSAndroid Build Coastguard Worker {
400*35238bceSAndroid Build Coastguard Worker auto ctxType = m_context.getRenderContext().getType();
401*35238bceSAndroid Build Coastguard Worker const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) ||
402*35238bceSAndroid Build Coastguard Worker glu::contextSupports(ctxType, glu::ApiType::core(4, 5));
403*35238bceSAndroid Build Coastguard Worker
404*35238bceSAndroid Build Coastguard Worker switch (m_shaderType)
405*35238bceSAndroid Build Coastguard Worker {
406*35238bceSAndroid Build Coastguard Worker case glu::SHADERTYPE_VERTEX:
407*35238bceSAndroid Build Coastguard Worker case glu::SHADERTYPE_FRAGMENT:
408*35238bceSAndroid Build Coastguard Worker case glu::SHADERTYPE_COMPUTE:
409*35238bceSAndroid Build Coastguard Worker break;
410*35238bceSAndroid Build Coastguard Worker
411*35238bceSAndroid Build Coastguard Worker case glu::SHADERTYPE_GEOMETRY:
412*35238bceSAndroid Build Coastguard Worker if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader") && !isES32orGL45)
413*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError(
414*35238bceSAndroid Build Coastguard Worker "Test requires GL_EXT_geometry_shader extension or an OpenGL ES 3.2 or higher context.");
415*35238bceSAndroid Build Coastguard Worker break;
416*35238bceSAndroid Build Coastguard Worker
417*35238bceSAndroid Build Coastguard Worker case glu::SHADERTYPE_TESSELLATION_CONTROL:
418*35238bceSAndroid Build Coastguard Worker case glu::SHADERTYPE_TESSELLATION_EVALUATION:
419*35238bceSAndroid Build Coastguard Worker if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader") && !isES32orGL45)
420*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError(
421*35238bceSAndroid Build Coastguard Worker "Test requires GL_EXT_tessellation_shader extension or an OpenGL ES 3.2 or higher context.");
422*35238bceSAndroid Build Coastguard Worker break;
423*35238bceSAndroid Build Coastguard Worker
424*35238bceSAndroid Build Coastguard Worker default:
425*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
426*35238bceSAndroid Build Coastguard Worker break;
427*35238bceSAndroid Build Coastguard Worker }
428*35238bceSAndroid Build Coastguard Worker }
429*35238bceSAndroid Build Coastguard Worker
iterate(void)430*35238bceSAndroid Build Coastguard Worker ShaderLogCase::IterateResult ShaderLogCase::iterate(void)
431*35238bceSAndroid Build Coastguard Worker {
432*35238bceSAndroid Build Coastguard Worker using gls::StateQueryUtil::StateQueryMemoryWriteGuard;
433*35238bceSAndroid Build Coastguard Worker
434*35238bceSAndroid Build Coastguard Worker tcu::ResultCollector result(m_testCtx.getLog());
435*35238bceSAndroid Build Coastguard Worker glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
436*35238bceSAndroid Build Coastguard Worker uint32_t shader = 0;
437*35238bceSAndroid Build Coastguard Worker const std::string source = brokenShaderSource(m_context.getRenderContext().getType());
438*35238bceSAndroid Build Coastguard Worker const char *const brokenSource = source.c_str();
439*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<glw::GLint> logLen;
440*35238bceSAndroid Build Coastguard Worker
441*35238bceSAndroid Build Coastguard Worker gl.enableLogging(true);
442*35238bceSAndroid Build Coastguard Worker
443*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Trying to compile broken shader source."
444*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
445*35238bceSAndroid Build Coastguard Worker
446*35238bceSAndroid Build Coastguard Worker shader = gl.glCreateShader(glu::getGLShaderType(m_shaderType));
447*35238bceSAndroid Build Coastguard Worker GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "create shader");
448*35238bceSAndroid Build Coastguard Worker
449*35238bceSAndroid Build Coastguard Worker gl.glShaderSource(shader, 1, &brokenSource, DE_NULL);
450*35238bceSAndroid Build Coastguard Worker gl.glCompileShader(shader);
451*35238bceSAndroid Build Coastguard Worker GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "compile");
452*35238bceSAndroid Build Coastguard Worker
453*35238bceSAndroid Build Coastguard Worker gl.glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLen);
454*35238bceSAndroid Build Coastguard Worker logLen.verifyValidity(result);
455*35238bceSAndroid Build Coastguard Worker
456*35238bceSAndroid Build Coastguard Worker if (!logLen.isUndefined())
457*35238bceSAndroid Build Coastguard Worker verifyInfoLogQuery(result, gl, logLen, shader, &glu::CallLogWrapper::glGetShaderInfoLog, "glGetShaderInfoLog");
458*35238bceSAndroid Build Coastguard Worker
459*35238bceSAndroid Build Coastguard Worker gl.glDeleteShader(shader);
460*35238bceSAndroid Build Coastguard Worker GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "delete");
461*35238bceSAndroid Build Coastguard Worker
462*35238bceSAndroid Build Coastguard Worker result.setTestContextResult(m_testCtx);
463*35238bceSAndroid Build Coastguard Worker return STOP;
464*35238bceSAndroid Build Coastguard Worker }
465*35238bceSAndroid Build Coastguard Worker
466*35238bceSAndroid Build Coastguard Worker } // namespace
467*35238bceSAndroid Build Coastguard Worker
ShaderStateQueryTests(Context & context)468*35238bceSAndroid Build Coastguard Worker ShaderStateQueryTests::ShaderStateQueryTests(Context &context)
469*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "shader", "Shader state query tests")
470*35238bceSAndroid Build Coastguard Worker {
471*35238bceSAndroid Build Coastguard Worker }
472*35238bceSAndroid Build Coastguard Worker
~ShaderStateQueryTests(void)473*35238bceSAndroid Build Coastguard Worker ShaderStateQueryTests::~ShaderStateQueryTests(void)
474*35238bceSAndroid Build Coastguard Worker {
475*35238bceSAndroid Build Coastguard Worker }
476*35238bceSAndroid Build Coastguard Worker
init(void)477*35238bceSAndroid Build Coastguard Worker void ShaderStateQueryTests::init(void)
478*35238bceSAndroid Build Coastguard Worker {
479*35238bceSAndroid Build Coastguard Worker addChild(new CoreSamplerTypeCase(m_context, "sampler_type", "Sampler type cases"));
480*35238bceSAndroid Build Coastguard Worker addChild(new MSArraySamplerTypeCase(m_context, "sampler_type_multisample_array", "MSAA array sampler type cases"));
481*35238bceSAndroid Build Coastguard Worker addChild(new TextureBufferSamplerTypeCase(m_context, "sampler_type_texture_buffer",
482*35238bceSAndroid Build Coastguard Worker "Texture buffer sampler type cases"));
483*35238bceSAndroid Build Coastguard Worker addChild(new TextureBufferImageTypeCase(m_context, "image_type_texture_buffer", "Texture buffer image type cases"));
484*35238bceSAndroid Build Coastguard Worker addChild(new CubeArraySamplerTypeCase(m_context, "sampler_type_cube_array", "Cube array sampler type cases"));
485*35238bceSAndroid Build Coastguard Worker addChild(new CubeArrayImageTypeCase(m_context, "image_type_cube_array", "Cube array image type cases"));
486*35238bceSAndroid Build Coastguard Worker
487*35238bceSAndroid Build Coastguard Worker // shader info log tests
488*35238bceSAndroid Build Coastguard Worker // \note, there exists similar tests in gles3 module. However, the gles31 could use a different
489*35238bceSAndroid Build Coastguard Worker // shader compiler with different INFO_LOG bugs.
490*35238bceSAndroid Build Coastguard Worker {
491*35238bceSAndroid Build Coastguard Worker static const struct
492*35238bceSAndroid Build Coastguard Worker {
493*35238bceSAndroid Build Coastguard Worker const char *caseName;
494*35238bceSAndroid Build Coastguard Worker glu::ShaderType caseType;
495*35238bceSAndroid Build Coastguard Worker } shaderTypes[] = {
496*35238bceSAndroid Build Coastguard Worker {"info_log_vertex", glu::SHADERTYPE_VERTEX},
497*35238bceSAndroid Build Coastguard Worker {"info_log_fragment", glu::SHADERTYPE_FRAGMENT},
498*35238bceSAndroid Build Coastguard Worker {"info_log_geometry", glu::SHADERTYPE_GEOMETRY},
499*35238bceSAndroid Build Coastguard Worker {"info_log_tess_ctrl", glu::SHADERTYPE_TESSELLATION_CONTROL},
500*35238bceSAndroid Build Coastguard Worker {"info_log_tess_eval", glu::SHADERTYPE_TESSELLATION_EVALUATION},
501*35238bceSAndroid Build Coastguard Worker {"info_log_compute", glu::SHADERTYPE_COMPUTE},
502*35238bceSAndroid Build Coastguard Worker };
503*35238bceSAndroid Build Coastguard Worker
504*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ++ndx)
505*35238bceSAndroid Build Coastguard Worker addChild(new ShaderLogCase(m_context, shaderTypes[ndx].caseName, "", shaderTypes[ndx].caseType));
506*35238bceSAndroid Build Coastguard Worker }
507*35238bceSAndroid Build Coastguard Worker }
508*35238bceSAndroid Build Coastguard Worker
509*35238bceSAndroid Build Coastguard Worker } // namespace Functional
510*35238bceSAndroid Build Coastguard Worker } // namespace gles31
511*35238bceSAndroid Build Coastguard Worker } // namespace deqp
512