1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL (ES) 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 Framebuffer completeness tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es3fFboCompletenessTests.hpp"
25*35238bceSAndroid Build Coastguard Worker
26*35238bceSAndroid Build Coastguard Worker #include "glsFboCompletenessTests.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
28*35238bceSAndroid Build Coastguard Worker #include <sstream>
29*35238bceSAndroid Build Coastguard Worker
30*35238bceSAndroid Build Coastguard Worker using namespace glw;
31*35238bceSAndroid Build Coastguard Worker using deqp::gls::Range;
32*35238bceSAndroid Build Coastguard Worker using namespace deqp::gls::FboUtil;
33*35238bceSAndroid Build Coastguard Worker using namespace deqp::gls::FboUtil::config;
34*35238bceSAndroid Build Coastguard Worker namespace fboc = deqp::gls::fboc;
35*35238bceSAndroid Build Coastguard Worker typedef tcu::TestCase::IterateResult IterateResult;
36*35238bceSAndroid Build Coastguard Worker using std::ostringstream;
37*35238bceSAndroid Build Coastguard Worker using std::string;
38*35238bceSAndroid Build Coastguard Worker
39*35238bceSAndroid Build Coastguard Worker namespace deqp
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace gles3
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker namespace Functional
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker static const FormatKey s_es3ColorRenderables[] = {
47*35238bceSAndroid Build Coastguard Worker // GLES3, 4.4.4: "An internal format is color-renderable if it is one of
48*35238bceSAndroid Build Coastguard Worker // the formats from table 3.12 noted as color-renderable..."
49*35238bceSAndroid Build Coastguard Worker GL_R8, GL_RG8, GL_RGB8, GL_RGB565, GL_RGBA4, GL_RGB5_A1, GL_RGBA8,
50*35238bceSAndroid Build Coastguard Worker GL_RGB10_A2, GL_RGB10_A2UI, GL_SRGB8_ALPHA8, GL_R8I, GL_R8UI, GL_R16I, GL_R16UI,
51*35238bceSAndroid Build Coastguard Worker GL_R32I, GL_R32UI, GL_RG8I, GL_RG8UI, GL_RG16I, GL_RG16UI, GL_RG32I,
52*35238bceSAndroid Build Coastguard Worker GL_RG32UI, GL_RGBA8I, GL_RGBA8UI, GL_RGBA16I, GL_RGBA16UI, GL_RGBA32I, GL_RGBA32UI,
53*35238bceSAndroid Build Coastguard Worker };
54*35238bceSAndroid Build Coastguard Worker
55*35238bceSAndroid Build Coastguard Worker static const FormatKey s_es3UnsizedColorRenderables[] = {
56*35238bceSAndroid Build Coastguard Worker // "...or if it is unsized format RGBA or RGB."
57*35238bceSAndroid Build Coastguard Worker // See Table 3.3 in GLES3.
58*35238bceSAndroid Build Coastguard Worker GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_BYTE),
59*35238bceSAndroid Build Coastguard Worker GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4),
60*35238bceSAndroid Build Coastguard Worker GLS_UNSIZED_FORMATKEY(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1),
61*35238bceSAndroid Build Coastguard Worker GLS_UNSIZED_FORMATKEY(GL_RGB, GL_UNSIGNED_BYTE),
62*35238bceSAndroid Build Coastguard Worker GLS_UNSIZED_FORMATKEY(GL_RGB, GL_UNSIGNED_SHORT_5_6_5),
63*35238bceSAndroid Build Coastguard Worker };
64*35238bceSAndroid Build Coastguard Worker
65*35238bceSAndroid Build Coastguard Worker static const FormatKey s_es3DepthRenderables[] = {
66*35238bceSAndroid Build Coastguard Worker // GLES3, 4.4.4: "An internal format is depth-renderable if it is one of
67*35238bceSAndroid Build Coastguard Worker // the formats from table 3.13."
68*35238bceSAndroid Build Coastguard Worker GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32F, GL_DEPTH24_STENCIL8, GL_DEPTH32F_STENCIL8,
69*35238bceSAndroid Build Coastguard Worker };
70*35238bceSAndroid Build Coastguard Worker
71*35238bceSAndroid Build Coastguard Worker static const FormatKey s_es3StencilRboRenderables[] = {
72*35238bceSAndroid Build Coastguard Worker // GLES3, 4.4.4: "An internal format is stencil-renderable if it is
73*35238bceSAndroid Build Coastguard Worker // STENCIL_INDEX8..."
74*35238bceSAndroid Build Coastguard Worker GL_STENCIL_INDEX8,
75*35238bceSAndroid Build Coastguard Worker };
76*35238bceSAndroid Build Coastguard Worker
77*35238bceSAndroid Build Coastguard Worker static const FormatKey s_es3StencilRenderables[] = {
78*35238bceSAndroid Build Coastguard Worker // "...or one of the formats from table 3.13 whose base internal format is
79*35238bceSAndroid Build Coastguard Worker // DEPTH_STENCIL."
80*35238bceSAndroid Build Coastguard Worker GL_DEPTH24_STENCIL8,
81*35238bceSAndroid Build Coastguard Worker GL_DEPTH32F_STENCIL8,
82*35238bceSAndroid Build Coastguard Worker };
83*35238bceSAndroid Build Coastguard Worker
84*35238bceSAndroid Build Coastguard Worker static const FormatKey s_es3TextureFloatFormats[] = {
85*35238bceSAndroid Build Coastguard Worker GL_RGBA32F, GL_RGBA16F, GL_R11F_G11F_B10F, GL_RG32F, GL_RG16F, GL_R32F,
86*35238bceSAndroid Build Coastguard Worker GL_R16F, GL_RGBA16F, GL_RGB16F, GL_RG16F, GL_R16F,
87*35238bceSAndroid Build Coastguard Worker };
88*35238bceSAndroid Build Coastguard Worker
89*35238bceSAndroid Build Coastguard Worker static const FormatKey s_es3NotRenderableTextureFormats[] = {
90*35238bceSAndroid Build Coastguard Worker GL_R8_SNORM, GL_RG8_SNORM, GL_RGB8_SNORM, GL_RGBA8_SNORM, GL_RGB9_E5, GL_SRGB8,
91*35238bceSAndroid Build Coastguard Worker GL_RGB8I, GL_RGB16I, GL_RGB32I, GL_RGB8UI, GL_RGB16UI, GL_RGB32UI,
92*35238bceSAndroid Build Coastguard Worker };
93*35238bceSAndroid Build Coastguard Worker
94*35238bceSAndroid Build Coastguard Worker static const FormatEntry s_es3Formats[] = {
95*35238bceSAndroid Build Coastguard Worker // Renderbuffers don't support unsized formats
96*35238bceSAndroid Build Coastguard Worker {REQUIRED_RENDERABLE | COLOR_RENDERABLE | TEXTURE_VALID, GLS_ARRAY_RANGE(s_es3UnsizedColorRenderables)},
97*35238bceSAndroid Build Coastguard Worker {REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID | TEXTURE_VALID,
98*35238bceSAndroid Build Coastguard Worker GLS_ARRAY_RANGE(s_es3ColorRenderables)},
99*35238bceSAndroid Build Coastguard Worker {REQUIRED_RENDERABLE | DEPTH_RENDERABLE | RENDERBUFFER_VALID | TEXTURE_VALID,
100*35238bceSAndroid Build Coastguard Worker GLS_ARRAY_RANGE(s_es3DepthRenderables)},
101*35238bceSAndroid Build Coastguard Worker {REQUIRED_RENDERABLE | STENCIL_RENDERABLE | RENDERBUFFER_VALID, GLS_ARRAY_RANGE(s_es3StencilRboRenderables)},
102*35238bceSAndroid Build Coastguard Worker {REQUIRED_RENDERABLE | STENCIL_RENDERABLE | RENDERBUFFER_VALID | TEXTURE_VALID,
103*35238bceSAndroid Build Coastguard Worker GLS_ARRAY_RANGE(s_es3StencilRenderables)},
104*35238bceSAndroid Build Coastguard Worker {TEXTURE_VALID, GLS_ARRAY_RANGE(s_es3NotRenderableTextureFormats)},
105*35238bceSAndroid Build Coastguard Worker
106*35238bceSAndroid Build Coastguard Worker // These are not color-renderable in vanilla ES3, but we need to mark them
107*35238bceSAndroid Build Coastguard Worker // as valid for textures, since EXT_color_buffer_(half_)float brings in
108*35238bceSAndroid Build Coastguard Worker // color-renderability and only renderbuffer-validity.
109*35238bceSAndroid Build Coastguard Worker {TEXTURE_VALID, GLS_ARRAY_RANGE(s_es3TextureFloatFormats)},
110*35238bceSAndroid Build Coastguard Worker };
111*35238bceSAndroid Build Coastguard Worker
112*35238bceSAndroid Build Coastguard Worker // GL_EXT_color_buffer_float
113*35238bceSAndroid Build Coastguard Worker static const FormatKey s_extColorBufferFloatFormats[] = {
114*35238bceSAndroid Build Coastguard Worker GL_RGBA32F, GL_RGBA16F, GL_R11F_G11F_B10F, GL_RG32F, GL_RG16F, GL_R32F, GL_R16F,
115*35238bceSAndroid Build Coastguard Worker };
116*35238bceSAndroid Build Coastguard Worker
117*35238bceSAndroid Build Coastguard Worker // GL_QCOM_render_shared_exponent
118*35238bceSAndroid Build Coastguard Worker static const FormatKey s_qcomRenderSharedExponent[] = {
119*35238bceSAndroid Build Coastguard Worker GL_RGB9_E5,
120*35238bceSAndroid Build Coastguard Worker };
121*35238bceSAndroid Build Coastguard Worker // GL_OES_texture_stencil8
122*35238bceSAndroid Build Coastguard Worker static const FormatKey s_extOESTextureStencil8[] = {
123*35238bceSAndroid Build Coastguard Worker GL_STENCIL_INDEX8,
124*35238bceSAndroid Build Coastguard Worker };
125*35238bceSAndroid Build Coastguard Worker
126*35238bceSAndroid Build Coastguard Worker // GL_EXT_render_snorm
127*35238bceSAndroid Build Coastguard Worker static const FormatKey s_extRenderSnorm[] = {
128*35238bceSAndroid Build Coastguard Worker GL_R8_SNORM,
129*35238bceSAndroid Build Coastguard Worker GL_RG8_SNORM,
130*35238bceSAndroid Build Coastguard Worker GL_RGBA8_SNORM,
131*35238bceSAndroid Build Coastguard Worker };
132*35238bceSAndroid Build Coastguard Worker
133*35238bceSAndroid Build Coastguard Worker static const FormatExtEntry s_es3ExtFormats[] = {
134*35238bceSAndroid Build Coastguard Worker {"GL_EXT_color_buffer_float",
135*35238bceSAndroid Build Coastguard Worker // These are already texture-valid in ES3, the extension just adds RBO
136*35238bceSAndroid Build Coastguard Worker // support and makes them color-renderable.
137*35238bceSAndroid Build Coastguard Worker (uint32_t)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID),
138*35238bceSAndroid Build Coastguard Worker GLS_ARRAY_RANGE(s_extColorBufferFloatFormats)},
139*35238bceSAndroid Build Coastguard Worker {"GL_OES_texture_stencil8",
140*35238bceSAndroid Build Coastguard Worker // \note: es3 RBO tests actually cover the first two requirements
141*35238bceSAndroid Build Coastguard Worker // - kept here for completeness
142*35238bceSAndroid Build Coastguard Worker (uint32_t)(REQUIRED_RENDERABLE | STENCIL_RENDERABLE | TEXTURE_VALID), GLS_ARRAY_RANGE(s_extOESTextureStencil8)},
143*35238bceSAndroid Build Coastguard Worker
144*35238bceSAndroid Build Coastguard Worker {"GL_EXT_render_snorm", (uint32_t)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | TEXTURE_VALID | RENDERBUFFER_VALID),
145*35238bceSAndroid Build Coastguard Worker GLS_ARRAY_RANGE(s_extRenderSnorm)},
146*35238bceSAndroid Build Coastguard Worker
147*35238bceSAndroid Build Coastguard Worker {"GL_QCOM_render_shared_exponent",
148*35238bceSAndroid Build Coastguard Worker // This is already texture-valid in ES3, the extension just adds RBO
149*35238bceSAndroid Build Coastguard Worker // support to RGB9_E5 and make it color-renderable.
150*35238bceSAndroid Build Coastguard Worker (uint32_t)(REQUIRED_RENDERABLE | COLOR_RENDERABLE | RENDERBUFFER_VALID | TEXTURE_VALID),
151*35238bceSAndroid Build Coastguard Worker GLS_ARRAY_RANGE(s_qcomRenderSharedExponent)},
152*35238bceSAndroid Build Coastguard Worker };
153*35238bceSAndroid Build Coastguard Worker
154*35238bceSAndroid Build Coastguard Worker class ES3Checker : public Checker
155*35238bceSAndroid Build Coastguard Worker {
156*35238bceSAndroid Build Coastguard Worker public:
ES3Checker(const glu::RenderContext & ctx,const FormatDB & formats)157*35238bceSAndroid Build Coastguard Worker ES3Checker(const glu::RenderContext &ctx, const FormatDB &formats)
158*35238bceSAndroid Build Coastguard Worker : Checker(ctx, formats)
159*35238bceSAndroid Build Coastguard Worker , m_ctxInfo(glu::ContextInfo::create(ctx))
160*35238bceSAndroid Build Coastguard Worker , m_numSamples(-1)
161*35238bceSAndroid Build Coastguard Worker , m_depthStencilImage(0)
162*35238bceSAndroid Build Coastguard Worker , m_depthStencilType(GL_NONE)
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker void check(GLenum attPoint, const Attachment &att, const Image *image);
166*35238bceSAndroid Build Coastguard Worker
167*35238bceSAndroid Build Coastguard Worker private:
168*35238bceSAndroid Build Coastguard Worker de::UniquePtr<glu::ContextInfo> m_ctxInfo;
169*35238bceSAndroid Build Coastguard Worker
170*35238bceSAndroid Build Coastguard Worker //! The common number of samples of images.
171*35238bceSAndroid Build Coastguard Worker GLsizei m_numSamples;
172*35238bceSAndroid Build Coastguard Worker
173*35238bceSAndroid Build Coastguard Worker //! The common image for depth and stencil attachments.
174*35238bceSAndroid Build Coastguard Worker GLuint m_depthStencilImage;
175*35238bceSAndroid Build Coastguard Worker GLenum m_depthStencilType;
176*35238bceSAndroid Build Coastguard Worker ImageFormat m_depthStencilFormat;
177*35238bceSAndroid Build Coastguard Worker };
178*35238bceSAndroid Build Coastguard Worker
check(GLenum attPoint,const Attachment & att,const Image * image)179*35238bceSAndroid Build Coastguard Worker void ES3Checker::check(GLenum attPoint, const Attachment &att, const Image *image)
180*35238bceSAndroid Build Coastguard Worker {
181*35238bceSAndroid Build Coastguard Worker GLsizei imgSamples = imageNumSamples(*image);
182*35238bceSAndroid Build Coastguard Worker
183*35238bceSAndroid Build Coastguard Worker if (m_numSamples == -1)
184*35238bceSAndroid Build Coastguard Worker {
185*35238bceSAndroid Build Coastguard Worker m_numSamples = imgSamples;
186*35238bceSAndroid Build Coastguard Worker }
187*35238bceSAndroid Build Coastguard Worker else
188*35238bceSAndroid Build Coastguard Worker {
189*35238bceSAndroid Build Coastguard Worker // GLES3: "The value of RENDERBUFFER_SAMPLES is the same for all attached
190*35238bceSAndroid Build Coastguard Worker // renderbuffers and, if the attached images are a mix of renderbuffers
191*35238bceSAndroid Build Coastguard Worker // and textures, the value of RENDERBUFFER_SAMPLES is zero."
192*35238bceSAndroid Build Coastguard Worker //
193*35238bceSAndroid Build Coastguard Worker // On creating a renderbuffer: "If _samples_ is zero, then
194*35238bceSAndroid Build Coastguard Worker // RENDERBUFFER_SAMPLES is set to zero. Otherwise [...] the resulting
195*35238bceSAndroid Build Coastguard Worker // value for RENDERBUFFER_SAMPLES is guaranteed to be greater than or
196*35238bceSAndroid Build Coastguard Worker // equal to _samples_ and no more than the next larger sample count
197*35238bceSAndroid Build Coastguard Worker // supported by the implementation."
198*35238bceSAndroid Build Coastguard Worker
199*35238bceSAndroid Build Coastguard Worker // Either all attachments are zero-sample renderbuffers and/or
200*35238bceSAndroid Build Coastguard Worker // textures, or none of them are.
201*35238bceSAndroid Build Coastguard Worker if ((m_numSamples == 0) != (imgSamples == 0))
202*35238bceSAndroid Build Coastguard Worker addFBOStatus(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, "Mixed multi- and single-sampled attachments");
203*35238bceSAndroid Build Coastguard Worker
204*35238bceSAndroid Build Coastguard Worker // If the attachments requested a different number of samples, the
205*35238bceSAndroid Build Coastguard Worker // implementation is allowed to report this as incomplete. However, it
206*35238bceSAndroid Build Coastguard Worker // is also possible that despite the different requests, the
207*35238bceSAndroid Build Coastguard Worker // implementation allocated the same number of samples to both. Hence
208*35238bceSAndroid Build Coastguard Worker // reporting the framebuffer as complete is also legal.
209*35238bceSAndroid Build Coastguard Worker if (m_numSamples != imgSamples)
210*35238bceSAndroid Build Coastguard Worker addPotentialFBOStatus(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, "Number of samples differ");
211*35238bceSAndroid Build Coastguard Worker }
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker if (attPoint == GL_DEPTH_ATTACHMENT || attPoint == GL_STENCIL_ATTACHMENT)
214*35238bceSAndroid Build Coastguard Worker {
215*35238bceSAndroid Build Coastguard Worker if (m_depthStencilImage == 0)
216*35238bceSAndroid Build Coastguard Worker {
217*35238bceSAndroid Build Coastguard Worker m_depthStencilImage = att.imageName;
218*35238bceSAndroid Build Coastguard Worker m_depthStencilType = attachmentType(att);
219*35238bceSAndroid Build Coastguard Worker m_depthStencilFormat = image->internalFormat;
220*35238bceSAndroid Build Coastguard Worker }
221*35238bceSAndroid Build Coastguard Worker else if (m_depthStencilImage != att.imageName || m_depthStencilType != attachmentType(att))
222*35238bceSAndroid Build Coastguard Worker {
223*35238bceSAndroid Build Coastguard Worker // "Depth and stencil attachments, if present, are the same image."
224*35238bceSAndroid Build Coastguard Worker if (!m_ctxInfo->isExtensionSupported("GL_EXT_separate_depth_stencil"))
225*35238bceSAndroid Build Coastguard Worker addFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED, "Depth and stencil attachments are not the same image");
226*35238bceSAndroid Build Coastguard Worker
227*35238bceSAndroid Build Coastguard Worker // "The combination of internal formats of the attached images does not violate
228*35238bceSAndroid Build Coastguard Worker // an implementation-dependent set of restrictions."
229*35238bceSAndroid Build Coastguard Worker ImageFormat depthFormat = attPoint == GL_DEPTH_ATTACHMENT ? image->internalFormat : m_depthStencilFormat;
230*35238bceSAndroid Build Coastguard Worker ImageFormat stencilFormat =
231*35238bceSAndroid Build Coastguard Worker attPoint == GL_STENCIL_ATTACHMENT ? image->internalFormat : m_depthStencilFormat;
232*35238bceSAndroid Build Coastguard Worker if (m_formats.getFormatInfo(depthFormat) & STENCIL_RENDERABLE)
233*35238bceSAndroid Build Coastguard Worker addPotentialFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED,
234*35238bceSAndroid Build Coastguard Worker "Separate depth attachment has combined depth and stencil format");
235*35238bceSAndroid Build Coastguard Worker if (m_formats.getFormatInfo(stencilFormat) & DEPTH_RENDERABLE)
236*35238bceSAndroid Build Coastguard Worker addPotentialFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED,
237*35238bceSAndroid Build Coastguard Worker "Separate stencil attachment has combined depth and stencil format");
238*35238bceSAndroid Build Coastguard Worker }
239*35238bceSAndroid Build Coastguard Worker }
240*35238bceSAndroid Build Coastguard Worker }
241*35238bceSAndroid Build Coastguard Worker
242*35238bceSAndroid Build Coastguard Worker struct NumLayersParams
243*35238bceSAndroid Build Coastguard Worker {
244*35238bceSAndroid Build Coastguard Worker GLenum textureKind; //< GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY
245*35238bceSAndroid Build Coastguard Worker GLsizei numLayers; //< Number of layers in texture
246*35238bceSAndroid Build Coastguard Worker GLsizei attachmentLayer; //< Layer referenced by attachment
247*35238bceSAndroid Build Coastguard Worker
248*35238bceSAndroid Build Coastguard Worker static string getName(const NumLayersParams ¶ms);
249*35238bceSAndroid Build Coastguard Worker static string getDescription(const NumLayersParams ¶ms);
250*35238bceSAndroid Build Coastguard Worker };
251*35238bceSAndroid Build Coastguard Worker
getName(const NumLayersParams & params)252*35238bceSAndroid Build Coastguard Worker string NumLayersParams::getName(const NumLayersParams ¶ms)
253*35238bceSAndroid Build Coastguard Worker {
254*35238bceSAndroid Build Coastguard Worker ostringstream os;
255*35238bceSAndroid Build Coastguard Worker const string kindStr = params.textureKind == GL_TEXTURE_3D ? "3d" : "2darr";
256*35238bceSAndroid Build Coastguard Worker os << kindStr << "_" << params.numLayers << "_" << params.attachmentLayer;
257*35238bceSAndroid Build Coastguard Worker return os.str();
258*35238bceSAndroid Build Coastguard Worker }
259*35238bceSAndroid Build Coastguard Worker
getDescription(const NumLayersParams & params)260*35238bceSAndroid Build Coastguard Worker string NumLayersParams::getDescription(const NumLayersParams ¶ms)
261*35238bceSAndroid Build Coastguard Worker {
262*35238bceSAndroid Build Coastguard Worker ostringstream os;
263*35238bceSAndroid Build Coastguard Worker const string kindStr = (params.textureKind == GL_TEXTURE_3D ? "3D Texture" : "2D Array Texture");
264*35238bceSAndroid Build Coastguard Worker os << kindStr + ", " << params.numLayers << " layers, "
265*35238bceSAndroid Build Coastguard Worker << "attached layer " << params.attachmentLayer << ".";
266*35238bceSAndroid Build Coastguard Worker return os.str();
267*35238bceSAndroid Build Coastguard Worker }
268*35238bceSAndroid Build Coastguard Worker
269*35238bceSAndroid Build Coastguard Worker class NumLayersTest : public fboc::ParamTest<NumLayersParams>
270*35238bceSAndroid Build Coastguard Worker {
271*35238bceSAndroid Build Coastguard Worker public:
NumLayersTest(fboc::Context & ctx,NumLayersParams param)272*35238bceSAndroid Build Coastguard Worker NumLayersTest(fboc::Context &ctx, NumLayersParams param) : fboc::ParamTest<NumLayersParams>(ctx, param)
273*35238bceSAndroid Build Coastguard Worker {
274*35238bceSAndroid Build Coastguard Worker }
275*35238bceSAndroid Build Coastguard Worker
276*35238bceSAndroid Build Coastguard Worker IterateResult build(FboBuilder &builder);
277*35238bceSAndroid Build Coastguard Worker };
278*35238bceSAndroid Build Coastguard Worker
build(FboBuilder & builder)279*35238bceSAndroid Build Coastguard Worker IterateResult NumLayersTest::build(FboBuilder &builder)
280*35238bceSAndroid Build Coastguard Worker {
281*35238bceSAndroid Build Coastguard Worker TextureLayered *texCfg = DE_NULL;
282*35238bceSAndroid Build Coastguard Worker const GLenum target = GL_COLOR_ATTACHMENT0;
283*35238bceSAndroid Build Coastguard Worker
284*35238bceSAndroid Build Coastguard Worker switch (m_params.textureKind)
285*35238bceSAndroid Build Coastguard Worker {
286*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_3D:
287*35238bceSAndroid Build Coastguard Worker texCfg = &builder.makeConfig<Texture3D>();
288*35238bceSAndroid Build Coastguard Worker break;
289*35238bceSAndroid Build Coastguard Worker case GL_TEXTURE_2D_ARRAY:
290*35238bceSAndroid Build Coastguard Worker texCfg = &builder.makeConfig<Texture2DArray>();
291*35238bceSAndroid Build Coastguard Worker break;
292*35238bceSAndroid Build Coastguard Worker default:
293*35238bceSAndroid Build Coastguard Worker DE_FATAL("Impossible case");
294*35238bceSAndroid Build Coastguard Worker }
295*35238bceSAndroid Build Coastguard Worker texCfg->internalFormat = getDefaultFormat(target, GL_TEXTURE);
296*35238bceSAndroid Build Coastguard Worker texCfg->width = 64;
297*35238bceSAndroid Build Coastguard Worker texCfg->height = 64;
298*35238bceSAndroid Build Coastguard Worker texCfg->numLayers = m_params.numLayers;
299*35238bceSAndroid Build Coastguard Worker const GLuint tex = builder.glCreateTexture(*texCfg);
300*35238bceSAndroid Build Coastguard Worker
301*35238bceSAndroid Build Coastguard Worker TextureLayerAttachment *att = &builder.makeConfig<TextureLayerAttachment>();
302*35238bceSAndroid Build Coastguard Worker att->layer = m_params.attachmentLayer;
303*35238bceSAndroid Build Coastguard Worker att->imageName = tex;
304*35238bceSAndroid Build Coastguard Worker
305*35238bceSAndroid Build Coastguard Worker builder.glAttach(target, att);
306*35238bceSAndroid Build Coastguard Worker
307*35238bceSAndroid Build Coastguard Worker return STOP;
308*35238bceSAndroid Build Coastguard Worker }
309*35238bceSAndroid Build Coastguard Worker
310*35238bceSAndroid Build Coastguard Worker enum
311*35238bceSAndroid Build Coastguard Worker {
312*35238bceSAndroid Build Coastguard Worker SAMPLES_NONE = -2,
313*35238bceSAndroid Build Coastguard Worker SAMPLES_TEXTURE = -1
314*35238bceSAndroid Build Coastguard Worker };
315*35238bceSAndroid Build Coastguard Worker struct NumSamplesParams
316*35238bceSAndroid Build Coastguard Worker {
317*35238bceSAndroid Build Coastguard Worker // >= 0: renderbuffer with N samples, -1: texture, -2: no attachment
318*35238bceSAndroid Build Coastguard Worker GLsizei numSamples[3];
319*35238bceSAndroid Build Coastguard Worker
320*35238bceSAndroid Build Coastguard Worker static string getName(const NumSamplesParams ¶ms);
321*35238bceSAndroid Build Coastguard Worker static string getDescription(const NumSamplesParams ¶ms);
322*35238bceSAndroid Build Coastguard Worker };
323*35238bceSAndroid Build Coastguard Worker
getName(const NumSamplesParams & params)324*35238bceSAndroid Build Coastguard Worker string NumSamplesParams::getName(const NumSamplesParams ¶ms)
325*35238bceSAndroid Build Coastguard Worker {
326*35238bceSAndroid Build Coastguard Worker ostringstream os;
327*35238bceSAndroid Build Coastguard Worker bool first = true;
328*35238bceSAndroid Build Coastguard Worker for (const GLsizei *ns = DE_ARRAY_BEGIN(params.numSamples); ns != DE_ARRAY_END(params.numSamples); ns++)
329*35238bceSAndroid Build Coastguard Worker {
330*35238bceSAndroid Build Coastguard Worker if (first)
331*35238bceSAndroid Build Coastguard Worker first = false;
332*35238bceSAndroid Build Coastguard Worker else
333*35238bceSAndroid Build Coastguard Worker os << "_";
334*35238bceSAndroid Build Coastguard Worker
335*35238bceSAndroid Build Coastguard Worker if (*ns == SAMPLES_NONE)
336*35238bceSAndroid Build Coastguard Worker os << "none";
337*35238bceSAndroid Build Coastguard Worker else if (*ns == SAMPLES_TEXTURE)
338*35238bceSAndroid Build Coastguard Worker os << "tex";
339*35238bceSAndroid Build Coastguard Worker else
340*35238bceSAndroid Build Coastguard Worker os << "rbo" << *ns;
341*35238bceSAndroid Build Coastguard Worker }
342*35238bceSAndroid Build Coastguard Worker return os.str();
343*35238bceSAndroid Build Coastguard Worker }
344*35238bceSAndroid Build Coastguard Worker
getDescription(const NumSamplesParams & params)345*35238bceSAndroid Build Coastguard Worker string NumSamplesParams::getDescription(const NumSamplesParams ¶ms)
346*35238bceSAndroid Build Coastguard Worker {
347*35238bceSAndroid Build Coastguard Worker ostringstream os;
348*35238bceSAndroid Build Coastguard Worker bool first = true;
349*35238bceSAndroid Build Coastguard Worker static const char *const s_names[] = {"color", "depth", "stencil"};
350*35238bceSAndroid Build Coastguard Worker DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_names) == DE_LENGTH_OF_ARRAY(params.numSamples));
351*35238bceSAndroid Build Coastguard Worker
352*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < DE_LENGTH_OF_ARRAY(s_names); i++)
353*35238bceSAndroid Build Coastguard Worker {
354*35238bceSAndroid Build Coastguard Worker GLsizei ns = params.numSamples[i];
355*35238bceSAndroid Build Coastguard Worker
356*35238bceSAndroid Build Coastguard Worker if (ns == SAMPLES_NONE)
357*35238bceSAndroid Build Coastguard Worker continue;
358*35238bceSAndroid Build Coastguard Worker
359*35238bceSAndroid Build Coastguard Worker if (first)
360*35238bceSAndroid Build Coastguard Worker first = false;
361*35238bceSAndroid Build Coastguard Worker else
362*35238bceSAndroid Build Coastguard Worker os << ", ";
363*35238bceSAndroid Build Coastguard Worker
364*35238bceSAndroid Build Coastguard Worker if (ns == SAMPLES_TEXTURE)
365*35238bceSAndroid Build Coastguard Worker os << "texture " << s_names[i] << " attachment";
366*35238bceSAndroid Build Coastguard Worker else
367*35238bceSAndroid Build Coastguard Worker os << ns << "-sample renderbuffer " << s_names[i] << " attachment";
368*35238bceSAndroid Build Coastguard Worker }
369*35238bceSAndroid Build Coastguard Worker return os.str();
370*35238bceSAndroid Build Coastguard Worker }
371*35238bceSAndroid Build Coastguard Worker
372*35238bceSAndroid Build Coastguard Worker class NumSamplesTest : public fboc::ParamTest<NumSamplesParams>
373*35238bceSAndroid Build Coastguard Worker {
374*35238bceSAndroid Build Coastguard Worker public:
NumSamplesTest(fboc::Context & ctx,NumSamplesParams param)375*35238bceSAndroid Build Coastguard Worker NumSamplesTest(fboc::Context &ctx, NumSamplesParams param) : fboc::ParamTest<NumSamplesParams>(ctx, param)
376*35238bceSAndroid Build Coastguard Worker {
377*35238bceSAndroid Build Coastguard Worker }
378*35238bceSAndroid Build Coastguard Worker
379*35238bceSAndroid Build Coastguard Worker IterateResult build(FboBuilder &builder);
380*35238bceSAndroid Build Coastguard Worker };
381*35238bceSAndroid Build Coastguard Worker
build(FboBuilder & builder)382*35238bceSAndroid Build Coastguard Worker IterateResult NumSamplesTest::build(FboBuilder &builder)
383*35238bceSAndroid Build Coastguard Worker {
384*35238bceSAndroid Build Coastguard Worker static const GLenum s_targets[] = {
385*35238bceSAndroid Build Coastguard Worker GL_COLOR_ATTACHMENT0,
386*35238bceSAndroid Build Coastguard Worker GL_COLOR_ATTACHMENT1,
387*35238bceSAndroid Build Coastguard Worker GL_DEPTH_ATTACHMENT,
388*35238bceSAndroid Build Coastguard Worker };
389*35238bceSAndroid Build Coastguard Worker // Non-integer formats for each attachment type.
390*35238bceSAndroid Build Coastguard Worker // \todo [2013-12-17 lauri] Add fixed/floating/integer metadata for formats so
391*35238bceSAndroid Build Coastguard Worker // we can pick one smartly or maybe try several.
392*35238bceSAndroid Build Coastguard Worker static const GLenum s_formats[] = {
393*35238bceSAndroid Build Coastguard Worker GL_RGBA8,
394*35238bceSAndroid Build Coastguard Worker GL_RGB565,
395*35238bceSAndroid Build Coastguard Worker GL_DEPTH_COMPONENT24,
396*35238bceSAndroid Build Coastguard Worker };
397*35238bceSAndroid Build Coastguard Worker DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_targets) == DE_LENGTH_OF_ARRAY(m_params.numSamples));
398*35238bceSAndroid Build Coastguard Worker
399*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < DE_LENGTH_OF_ARRAY(s_targets); i++)
400*35238bceSAndroid Build Coastguard Worker {
401*35238bceSAndroid Build Coastguard Worker const GLenum target = s_targets[i];
402*35238bceSAndroid Build Coastguard Worker const ImageFormat fmt = {s_formats[i], GL_NONE};
403*35238bceSAndroid Build Coastguard Worker
404*35238bceSAndroid Build Coastguard Worker const GLsizei ns = m_params.numSamples[i];
405*35238bceSAndroid Build Coastguard Worker if (ns == -2)
406*35238bceSAndroid Build Coastguard Worker continue;
407*35238bceSAndroid Build Coastguard Worker
408*35238bceSAndroid Build Coastguard Worker if (ns == -1)
409*35238bceSAndroid Build Coastguard Worker {
410*35238bceSAndroid Build Coastguard Worker attachTargetToNew(target, GL_TEXTURE, fmt, 64, 64, builder);
411*35238bceSAndroid Build Coastguard Worker }
412*35238bceSAndroid Build Coastguard Worker else
413*35238bceSAndroid Build Coastguard Worker {
414*35238bceSAndroid Build Coastguard Worker Renderbuffer &rboCfg = builder.makeConfig<Renderbuffer>();
415*35238bceSAndroid Build Coastguard Worker rboCfg.internalFormat = fmt;
416*35238bceSAndroid Build Coastguard Worker rboCfg.width = rboCfg.height = 64;
417*35238bceSAndroid Build Coastguard Worker rboCfg.numSamples = ns;
418*35238bceSAndroid Build Coastguard Worker
419*35238bceSAndroid Build Coastguard Worker const GLuint rbo = builder.glCreateRbo(rboCfg);
420*35238bceSAndroid Build Coastguard Worker // Implementations do not necessarily support sample sizes greater than 1.
421*35238bceSAndroid Build Coastguard Worker TCU_CHECK_AND_THROW(NotSupportedError, builder.getError() != GL_INVALID_OPERATION,
422*35238bceSAndroid Build Coastguard Worker "Unsupported number of samples");
423*35238bceSAndroid Build Coastguard Worker RenderbufferAttachment &att = builder.makeConfig<RenderbufferAttachment>();
424*35238bceSAndroid Build Coastguard Worker att.imageName = rbo;
425*35238bceSAndroid Build Coastguard Worker builder.glAttach(target, &att);
426*35238bceSAndroid Build Coastguard Worker }
427*35238bceSAndroid Build Coastguard Worker }
428*35238bceSAndroid Build Coastguard Worker
429*35238bceSAndroid Build Coastguard Worker return STOP;
430*35238bceSAndroid Build Coastguard Worker }
431*35238bceSAndroid Build Coastguard Worker
432*35238bceSAndroid Build Coastguard Worker class ES3CheckerFactory : public CheckerFactory
433*35238bceSAndroid Build Coastguard Worker {
434*35238bceSAndroid Build Coastguard Worker public:
createChecker(const glu::RenderContext & ctx,const FormatDB & formats)435*35238bceSAndroid Build Coastguard Worker Checker *createChecker(const glu::RenderContext &ctx, const FormatDB &formats)
436*35238bceSAndroid Build Coastguard Worker {
437*35238bceSAndroid Build Coastguard Worker return new ES3Checker(ctx, formats);
438*35238bceSAndroid Build Coastguard Worker }
439*35238bceSAndroid Build Coastguard Worker };
440*35238bceSAndroid Build Coastguard Worker
441*35238bceSAndroid Build Coastguard Worker class TestGroup : public TestCaseGroup
442*35238bceSAndroid Build Coastguard Worker {
443*35238bceSAndroid Build Coastguard Worker public:
444*35238bceSAndroid Build Coastguard Worker TestGroup(Context &context);
445*35238bceSAndroid Build Coastguard Worker void init(void);
446*35238bceSAndroid Build Coastguard Worker
447*35238bceSAndroid Build Coastguard Worker private:
448*35238bceSAndroid Build Coastguard Worker ES3CheckerFactory m_checkerFactory;
449*35238bceSAndroid Build Coastguard Worker fboc::Context m_fboc;
450*35238bceSAndroid Build Coastguard Worker };
451*35238bceSAndroid Build Coastguard Worker
init(void)452*35238bceSAndroid Build Coastguard Worker void TestGroup::init(void)
453*35238bceSAndroid Build Coastguard Worker {
454*35238bceSAndroid Build Coastguard Worker addChild(m_fboc.createRenderableTests());
455*35238bceSAndroid Build Coastguard Worker addChild(m_fboc.createAttachmentTests());
456*35238bceSAndroid Build Coastguard Worker addChild(m_fboc.createSizeTests());
457*35238bceSAndroid Build Coastguard Worker
458*35238bceSAndroid Build Coastguard Worker TestCaseGroup *layerTests = new TestCaseGroup(getContext(), "layer", "Tests for layer attachments");
459*35238bceSAndroid Build Coastguard Worker
460*35238bceSAndroid Build Coastguard Worker static const NumLayersParams s_layersParams[] = {
461*35238bceSAndroid Build Coastguard Worker // textureKind numLayers attachmentKind
462*35238bceSAndroid Build Coastguard Worker {GL_TEXTURE_2D_ARRAY, 1, 0}, {GL_TEXTURE_2D_ARRAY, 1, 3}, {GL_TEXTURE_2D_ARRAY, 4, 3},
463*35238bceSAndroid Build Coastguard Worker {GL_TEXTURE_2D_ARRAY, 4, 15}, {GL_TEXTURE_3D, 1, 0}, {GL_TEXTURE_3D, 1, 15},
464*35238bceSAndroid Build Coastguard Worker {GL_TEXTURE_3D, 4, 15}, {GL_TEXTURE_3D, 64, 15},
465*35238bceSAndroid Build Coastguard Worker };
466*35238bceSAndroid Build Coastguard Worker
467*35238bceSAndroid Build Coastguard Worker for (const NumLayersParams *lp = DE_ARRAY_BEGIN(s_layersParams); lp != DE_ARRAY_END(s_layersParams); ++lp)
468*35238bceSAndroid Build Coastguard Worker layerTests->addChild(new NumLayersTest(m_fboc, *lp));
469*35238bceSAndroid Build Coastguard Worker
470*35238bceSAndroid Build Coastguard Worker addChild(layerTests);
471*35238bceSAndroid Build Coastguard Worker
472*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sampleTests = new TestCaseGroup(getContext(), "samples", "Tests for multisample attachments");
473*35238bceSAndroid Build Coastguard Worker
474*35238bceSAndroid Build Coastguard Worker static const NumSamplesParams s_samplesParams[] = {
475*35238bceSAndroid Build Coastguard Worker {{0, SAMPLES_NONE, SAMPLES_NONE}},
476*35238bceSAndroid Build Coastguard Worker {{1, SAMPLES_NONE, SAMPLES_NONE}},
477*35238bceSAndroid Build Coastguard Worker {{2, SAMPLES_NONE, SAMPLES_NONE}},
478*35238bceSAndroid Build Coastguard Worker {{0, SAMPLES_TEXTURE, SAMPLES_NONE}},
479*35238bceSAndroid Build Coastguard Worker {{1, SAMPLES_TEXTURE, SAMPLES_NONE}},
480*35238bceSAndroid Build Coastguard Worker {{2, SAMPLES_TEXTURE, SAMPLES_NONE}},
481*35238bceSAndroid Build Coastguard Worker {{2, 1, SAMPLES_NONE}},
482*35238bceSAndroid Build Coastguard Worker {{2, 2, SAMPLES_NONE}},
483*35238bceSAndroid Build Coastguard Worker {{0, 0, SAMPLES_TEXTURE}},
484*35238bceSAndroid Build Coastguard Worker {{1, 2, 0}},
485*35238bceSAndroid Build Coastguard Worker {{2, 2, 0}},
486*35238bceSAndroid Build Coastguard Worker {{1, 1, 1}},
487*35238bceSAndroid Build Coastguard Worker {{1, 2, 4}},
488*35238bceSAndroid Build Coastguard Worker };
489*35238bceSAndroid Build Coastguard Worker
490*35238bceSAndroid Build Coastguard Worker for (const NumSamplesParams *lp = DE_ARRAY_BEGIN(s_samplesParams); lp != DE_ARRAY_END(s_samplesParams); ++lp)
491*35238bceSAndroid Build Coastguard Worker sampleTests->addChild(new NumSamplesTest(m_fboc, *lp));
492*35238bceSAndroid Build Coastguard Worker
493*35238bceSAndroid Build Coastguard Worker addChild(sampleTests);
494*35238bceSAndroid Build Coastguard Worker }
495*35238bceSAndroid Build Coastguard Worker
TestGroup(Context & ctx)496*35238bceSAndroid Build Coastguard Worker TestGroup::TestGroup(Context &ctx)
497*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(ctx, "completeness", "Completeness tests")
498*35238bceSAndroid Build Coastguard Worker , m_checkerFactory()
499*35238bceSAndroid Build Coastguard Worker , m_fboc(ctx.getTestContext(), ctx.getRenderContext(), m_checkerFactory)
500*35238bceSAndroid Build Coastguard Worker {
501*35238bceSAndroid Build Coastguard Worker const FormatEntries stdRange = GLS_ARRAY_RANGE(s_es3Formats);
502*35238bceSAndroid Build Coastguard Worker const FormatExtEntries extRange = GLS_ARRAY_RANGE(s_es3ExtFormats);
503*35238bceSAndroid Build Coastguard Worker
504*35238bceSAndroid Build Coastguard Worker m_fboc.addFormats(stdRange);
505*35238bceSAndroid Build Coastguard Worker m_fboc.addExtFormats(extRange);
506*35238bceSAndroid Build Coastguard Worker m_fboc.setHaveMulticolorAtts(true); // Vanilla ES3 has multiple color attachments
507*35238bceSAndroid Build Coastguard Worker }
508*35238bceSAndroid Build Coastguard Worker
createFboCompletenessTests(Context & context)509*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *createFboCompletenessTests(Context &context)
510*35238bceSAndroid Build Coastguard Worker {
511*35238bceSAndroid Build Coastguard Worker return new TestGroup(context);
512*35238bceSAndroid Build Coastguard Worker }
513*35238bceSAndroid Build Coastguard Worker
514*35238bceSAndroid Build Coastguard Worker } // namespace Functional
515*35238bceSAndroid Build Coastguard Worker } // namespace gles3
516*35238bceSAndroid Build Coastguard Worker } // namespace deqp
517