1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief EGL gles2 sharing tests
22 *//*--------------------------------------------------------------------*/
24 #include "teglGLES2SharingTests.hpp"
26 #include "teglGLES2SharingThreadedTests.hpp"
28 #include "egluNativeWindow.hpp"
29 #include "egluUtil.hpp"
30 #include "egluUnique.hpp"
32 #include "eglwLibrary.hpp"
33 #include "eglwEnums.hpp"
35 #include "tcuCommandLine.hpp"
36 #include "tcuImageCompare.hpp"
37 #include "tcuSurface.hpp"
38 #include "tcuTestLog.hpp"
39 #include "tcuTexture.hpp"
40 #include "tcuTextureUtil.hpp"
42 #include "deUniquePtr.hpp"
43 #include "deRandom.hpp"
49 #include "gluDefs.hpp"
50 #include "gluShaderProgram.hpp"
52 #include "glwFunctions.hpp"
53 #include "glwEnums.hpp"
69 class GLES2SharingTest : public TestCase
83 bool destroyContextBFirst;
85 bool destroyOnContexB;
93 GLES2SharingTest (EglTestContext& eglTestCtx, const char* name , const char* desc, const TestSpec& spec);
97 IterateResult iterate (void);
102 EGLContext createContext (EGLDisplay display, EGLContext share, EGLConfig config);
103 void makeCurrent (EGLDisplay display, EGLContext context, EGLSurface surface);
110 virtual void createResource (void) { DE_ASSERT(false); }
111 virtual void destroyResource (void) { DE_ASSERT(false); }
112 virtual void renderResource (tcu::Surface* screen, tcu::Surface* reference) { DE_UNREF(screen); DE_UNREF(reference); DE_ASSERT(false); }
115 GLES2SharingTest::GLES2SharingTest (EglTestContext& eglTestCtx, const char* name , const char* desc, const TestSpec& spec)
116 : TestCase (eglTestCtx, name, desc)
118 , m_random (deStringHash(name))
119 , m_log (eglTestCtx.getTestContext().getLog())
123 void GLES2SharingTest::init (void)
125 m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
128 EGLContext GLES2SharingTest::createContext (EGLDisplay display, EGLContext share, EGLConfig config)
130 const Library& egl = m_eglTestCtx.getLibrary();
131 EGLContext context = EGL_NO_CONTEXT;
132 const EGLint attriblist[] =
134 EGL_CONTEXT_CLIENT_VERSION, 2,
138 EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
140 context = egl.createContext(display, config, share, attriblist);
141 EGLU_CHECK_MSG(egl, "Failed to create GLES2 context");
142 TCU_CHECK(context != EGL_NO_CONTEXT);
147 void GLES2SharingTest::makeCurrent (EGLDisplay display, EGLContext context, EGLSurface surface)
149 const Library& egl = m_eglTestCtx.getLibrary();
150 EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
153 TestCase::IterateResult GLES2SharingTest::iterate (void)
155 const Library& egl = m_eglTestCtx.getLibrary();
156 tcu::TestLog& log = m_testCtx.getLog();
157 eglu::UniqueDisplay display (egl, eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay()));
158 const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
161 EGLContext contextA = EGL_NO_CONTEXT;
162 EGLContext contextB = EGL_NO_CONTEXT;
165 const EGLint attribList[] =
167 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
168 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
173 config = eglu::chooseSingleConfig(egl, *display, attribList);
178 de::UniquePtr<eglu::NativeWindow> window (windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), *display, config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
179 eglu::UniqueSurface surface (egl, *display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, *display, config, DE_NULL));
181 m_log << tcu::TestLog::Message << "Create context A (share_context = EGL_NO_CONTEXT)" << tcu::TestLog::EndMessage;
182 contextA = createContext(*display, EGL_NO_CONTEXT, config);
184 m_log << tcu::TestLog::Message << "Create context B (share_context = context A)" << tcu::TestLog::EndMessage;
185 contextB = createContext(*display, contextA, config);
187 if (m_spec.useResource)
189 m_log << tcu::TestLog::Message << "Make current context A" << tcu::TestLog::EndMessage;
190 makeCurrent(*display, contextA, *surface);
191 m_log << tcu::TestLog::Message << "Creating resource" << tcu::TestLog::EndMessage;
197 if (m_spec.renderOnContexA)
199 m_log << tcu::TestLog::Message << "Render resource" << tcu::TestLog::EndMessage;
200 if (m_spec.verifyOnContexA)
202 tcu::Surface screen (width, height);
203 tcu::Surface ref (width, height);
204 renderResource(&screen, &ref);
206 if (!fuzzyCompare(log, "Rendered image", "Rendering result comparision", ref, screen, 0.05f, tcu::COMPARE_LOG_RESULT))
211 renderResource(DE_NULL, DE_NULL);
215 if (m_spec.renderOnContexB)
217 m_log << tcu::TestLog::Message << "Make current context B" << tcu::TestLog::EndMessage;
218 makeCurrent(*display, contextB, *surface);
219 m_log << tcu::TestLog::Message << "Render resource" << tcu::TestLog::EndMessage;
220 if (m_spec.verifyOnContexB)
222 tcu::Surface screen (width, height);
223 tcu::Surface ref (width, height);
224 renderResource(&screen, &ref);
226 if (!fuzzyCompare(log, "Rendered image", "Rendering result comparision", ref, screen, 0.05f, tcu::COMPARE_LOG_RESULT))
231 renderResource(DE_NULL, DE_NULL);
235 if (m_spec.destroyOnContexB)
237 m_log << tcu::TestLog::Message << "Make current context B" << tcu::TestLog::EndMessage;
238 makeCurrent(*display, contextB, *surface);
239 m_log << tcu::TestLog::Message << "Destroy resource" << tcu::TestLog::EndMessage;
244 m_log << tcu::TestLog::Message << "Make current context A" << tcu::TestLog::EndMessage;
245 makeCurrent(*display, contextA, *surface);
246 m_log << tcu::TestLog::Message << "Destroy resource" << tcu::TestLog::EndMessage;
251 makeCurrent(*display, EGL_NO_CONTEXT, EGL_NO_SURFACE);
253 if (m_spec.destroyContextBFirst)
255 m_log << tcu::TestLog::Message << "Destroy context B" << tcu::TestLog::EndMessage;
256 egl.destroyContext(*display, contextB);
257 contextB = EGL_NO_CONTEXT;
259 m_log << tcu::TestLog::Message << "Destroy context A" << tcu::TestLog::EndMessage;
260 egl.destroyContext(*display, contextA);
261 contextA = EGL_NO_CONTEXT;
265 m_log << tcu::TestLog::Message << "Destroy context A" << tcu::TestLog::EndMessage;
266 egl.destroyContext(*display, contextA);
267 contextA = EGL_NO_CONTEXT;
269 m_log << tcu::TestLog::Message << "Destroy context B" << tcu::TestLog::EndMessage;
270 egl.destroyContext(*display, contextB);
271 contextB = EGL_NO_CONTEXT;
278 egl.makeCurrent(*display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
279 if (contextA != EGL_NO_CONTEXT)
280 egl.destroyContext(*display, contextA);
281 if (contextB != EGL_NO_CONTEXT)
282 egl.destroyContext(*display, contextB);
287 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
289 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
294 class GLES2BufferSharingTest : public GLES2SharingTest
297 GLES2BufferSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec);
301 std::vector<GLubyte> m_buffer;
303 virtual void createResource (void);
304 virtual void destroyResource (void);
305 virtual void renderResource (tcu::Surface* screen, tcu::Surface* reference);
309 GLES2BufferSharingTest::GLES2BufferSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec)
310 : GLES2SharingTest (eglTestCtx, name, desc, spec)
315 void GLES2BufferSharingTest::createResource (void)
319 m_buffer.reserve(size);
321 for (int i = 0; i < size; i++)
322 m_buffer.push_back((GLubyte)m_random.getInt(0, 255));
324 GLU_CHECK_GLW_CALL(m_gl, genBuffers(1, &m_glBuffer));
325 GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, m_glBuffer));
326 GLU_CHECK_GLW_CALL(m_gl, bufferData(GL_ARRAY_BUFFER, (GLsizei)(m_buffer.size() * sizeof(GLubyte)), &(m_buffer[0]), GL_DYNAMIC_DRAW));
327 GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, 0));
330 void GLES2BufferSharingTest::destroyResource (void)
332 GLU_CHECK_GLW_CALL(m_gl, deleteBuffers(1, &m_glBuffer));
336 void GLES2BufferSharingTest::renderResource (tcu::Surface* screen, tcu::Surface* reference)
338 DE_ASSERT((screen && reference) || (!screen && !reference));
340 const char* vertexShader = ""
341 "attribute mediump vec2 a_pos;\n"
342 "attribute mediump float a_color;\n"
343 "varying mediump float v_color;\n"
346 "\tv_color = a_color;\n"
347 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
350 const char* fragmentShader = ""
351 "varying mediump float v_color;\n"
354 "\tgl_FragColor = vec4(v_color, v_color, v_color, 1.0);\n"
357 glu::ShaderProgram program(m_gl, glu::makeVtxFragSources(vertexShader, fragmentShader));
360 TCU_FAIL("Failed to compile shader program");
362 std::vector<deUint16> indices;
363 std::vector<float> coords;
365 DE_ASSERT(m_buffer.size() % 4 == 0);
367 for (int i = 0; i < (int)m_buffer.size() / 4; i++)
369 indices.push_back((deUint16)(i*4));
370 indices.push_back((deUint16)(i*4 + 1));
371 indices.push_back((deUint16)(i*4 + 2));
372 indices.push_back((deUint16)(i*4 + 2));
373 indices.push_back((deUint16)(i*4 + 3));
374 indices.push_back((deUint16)(i*4));
376 coords.push_back(0.125f * (float)(i % 16) - 1.0f);
377 coords.push_back(0.125f * (float)((int)((float)i / 16.0f)) - 1.0f);
379 coords.push_back(0.125f * (float)(i % 16) - 1.0f);
380 coords.push_back(0.125f * (float)((int)((float)i / 16.0f) + 1) - 1.0f);
382 coords.push_back(0.125f * (float)((i % 16) + 1) - 1.0f);
383 coords.push_back(0.125f * (float)((int)((float)i / 16.0f) + 1) - 1.0f);
385 coords.push_back(0.125f * (float)((i % 16) + 1) - 1.0f);
386 coords.push_back(0.125f * (float)((int)((float)i / 16.0f)) - 1.0f);
394 width = screen->getWidth();
395 height = screen->getHeight();
398 GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
400 GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
401 GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
403 GLU_CHECK_GLW_CALL(m_gl, useProgram(program.getProgram()));
405 GLuint gridLocation = m_gl.getAttribLocation(program.getProgram(), "a_pos");
406 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
407 TCU_CHECK(gridLocation != (GLuint)-1);
409 GLuint colorLocation = m_gl.getAttribLocation(program.getProgram(), "a_color");
410 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
411 TCU_CHECK(colorLocation != (GLuint)-1);
413 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(colorLocation));
414 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(gridLocation));
416 GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, m_glBuffer));
417 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(colorLocation, 1, GL_UNSIGNED_BYTE, GL_TRUE, 0, DE_NULL));
418 GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, 0));
420 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(gridLocation, 2, GL_FLOAT, GL_FALSE, 0, &(coords[0])));
422 GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, &(indices[0])));
423 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(colorLocation));
424 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(gridLocation));
426 GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
430 tcu::clear(reference->getAccess(), tcu::IVec4(0xff, 0, 0, 0xff));
431 m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
432 for (int i = 0; i < (int)m_buffer.size() / 4; i++)
434 float fx1 = 0.125f * (float)(i % 16) - 1.0f;
435 float fy1 = 0.125f * (float)((int)((float)i / 16.0f)) - 1.0f;
436 float fx2 = 0.125f * (float)((i % 16) + 1) - 1.0f;
437 float fy2 = 0.125f * (float)((int)((float)i / 16.0f) + 1) - 1.0f;
439 int ox = deRoundFloatToInt32((float)width / 2.0f);
440 int oy = deRoundFloatToInt32((float)height / 2.0f);
441 int x1 = deRoundFloatToInt32(((float)width * fx1 / 2.0f) + (float)ox);
442 int y1 = deRoundFloatToInt32(((float)height * fy1 / 2.0f) + (float)oy);
443 int x2 = deRoundFloatToInt32(((float)width * fx2 / 2.0f) + (float)ox);
444 int y2 = deRoundFloatToInt32(((float)height * fy2 / 2.0f) + (float)oy);
446 for (int x = x1; x < x2; x++)
448 for (int y = y1; y < y2; y++)
450 float xf = ((float)(x-x1) + 0.5f) / (float)(x2 - x1);
451 float yf = ((float)(y-y1) + 0.5f) / (float)(y2 - y1);
453 deUint8 a = m_buffer[i*4 + (tri ? 1 : 3)];
454 deUint8 b = m_buffer[i*4 + (tri ? 2 : 0)];
455 deUint8 c = m_buffer[i*4 + (tri ? 0 : 2)];
456 float s = tri ? xf : 1.0f-xf;
457 float t = tri ? 1.0f-yf : yf;
458 float val = (float)a + (float)(b-a)*s + (float)(c-a)*t;
460 reference->setPixel(x, y, tcu::RGBA((deUint8)val, (deUint8)val, (deUint8)val, 255));
467 class GLES2TextureSharingTest : public GLES2SharingTest
470 GLES2TextureSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec, bool asColorAttachment);
474 tcu::Texture2D m_texture;
475 bool m_glTextureAsColorAttachment;
477 virtual void createResource (void);
478 virtual void destroyResource (void);
479 virtual void renderResource (tcu::Surface* screen, tcu::Surface* reference);
483 GLES2TextureSharingTest::GLES2TextureSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec, bool asColorAttachment)
484 : GLES2SharingTest (eglTestCtx, name, desc, spec)
486 , m_texture (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), 1, 1)
487 , m_glTextureAsColorAttachment(asColorAttachment)
491 void GLES2TextureSharingTest::createResource (void)
495 m_texture = tcu::Texture2D(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), width, height);
496 m_texture.allocLevel(0);
498 tcu::fillWithComponentGradients(m_texture.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
499 GLU_CHECK_GLW_CALL(m_gl, genTextures(1, &m_glTexture));
500 GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, m_glTexture));
501 GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT));
502 GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT));
503 GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
504 GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
505 GLU_CHECK_GLW_CALL(m_gl, texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_texture.getLevel(0).getDataPtr()));
506 GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, 0));
509 void GLES2TextureSharingTest::destroyResource (void)
511 GLU_CHECK_GLW_CALL(m_gl, deleteTextures(1, &m_glTexture));
514 void GLES2TextureSharingTest::renderResource (tcu::Surface* screen, tcu::Surface* reference)
516 DE_ASSERT((screen && reference) || (!screen && !reference));
518 const char* vertexShader = ""
519 "attribute mediump vec2 a_pos;\n"
520 "attribute mediump vec2 a_texCorod;\n"
521 "varying mediump vec2 v_texCoord;\n"
524 "\tv_texCoord = a_texCorod;\n"
525 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
528 const char* fragmentShader = ""
529 "varying mediump vec2 v_texCoord;\n"
530 "uniform sampler2D u_sampler;\n"
533 "\tgl_FragColor = texture2D(u_sampler, v_texCoord);\n"
536 glu::ShaderProgram program(m_gl, glu::makeVtxFragSources(vertexShader, fragmentShader));
539 TCU_FAIL("Failed to compile shader program");
546 width = screen->getWidth();
547 height = screen->getHeight();
550 static const GLfloat coords[] = {
557 static const GLfloat texCoords[] = {
564 static const GLushort indices[] = {
569 GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
571 GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
572 GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
574 GLU_CHECK_GLW_CALL(m_gl, useProgram(program.getProgram()));
576 GLuint coordLocation = m_gl.getAttribLocation(program.getProgram(), "a_pos");
577 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
578 TCU_CHECK(coordLocation != (GLuint)-1);
580 GLuint texCoordLocation = m_gl.getAttribLocation(program.getProgram(), "a_texCorod");
581 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
582 TCU_CHECK(texCoordLocation != (GLuint)-1);
585 GLuint samplerLocation = m_gl.getUniformLocation(program.getProgram(), "u_sampler");
586 GLU_CHECK_GLW_MSG(m_gl, "glGetUniformLocation()");
587 TCU_CHECK(samplerLocation != (GLuint)-1);
589 GLU_CHECK_GLW_CALL(m_gl, activeTexture(GL_TEXTURE0));
590 GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, m_glTexture));
592 GLU_CHECK_GLW_CALL(m_gl, uniform1i(samplerLocation, 0));
593 if(!m_glTextureAsColorAttachment)
596 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(texCoordLocation));
597 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
599 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texCoords));
600 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
602 GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
603 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(coordLocation));
604 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(texCoordLocation));
606 GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, 0));
607 GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
611 m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
613 for (int x = 0; x < width; x++)
615 for (int y = 0; y < height; y++)
617 float t = ((float)x / ((float)width - 1.0f));
618 float s = ((float)y / ((float)height - 1.0f));
621 tcu::Vec4 color = m_texture.sample(tcu::Sampler(tcu::Sampler::REPEAT_GL, tcu::Sampler::REPEAT_GL, tcu::Sampler::REPEAT_GL, tcu::Sampler::LINEAR, tcu::Sampler::LINEAR), t, s, lod);
623 int r = deClamp32((int)(255.0f * color.x()), 0, 255);
624 int g = deClamp32((int)(255.0f * color.y()), 0, 255);
625 int b = deClamp32((int)(255.0f * color.z()), 0, 255);
626 int a = deClamp32((int)(255.0f * color.w()), 0, 255);
628 reference->setPixel(x, y, tcu::RGBA(r, g, b, a));
635 DE_ASSERT(m_glTextureAsColorAttachment);
637 for(int i=0; i < 2; i++)
639 /* Draw left half of rectangle */
641 GLfloat vertices[] = { -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f };
642 GLfloat texcoords[] = {0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 1.0f, 0.0f, 1.0f};
643 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(texCoordLocation));
644 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
646 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords));
647 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, vertices));
648 GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
651 /* Bind the m_glTexture as user fbo color attachments */
654 GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, m_glTexture));
655 GLU_CHECK_GLW_CALL(m_gl, genFramebuffers(1, &fbo));
656 GLU_CHECK_GLW_CALL(m_gl, bindFramebuffer(GL_FRAMEBUFFER, fbo));
657 GLU_CHECK_GLW_CALL(m_gl, framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_glTexture, 0));
658 GLU_CHECK_GLW_CALL(m_gl, checkFramebufferStatus(GL_FRAMEBUFFER));
659 GLubyte data[] = { 0, 0, 0, 0 };
660 m_gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data);
661 GLU_CHECK_GLW_CALL(m_gl, bindFramebuffer(GL_FRAMEBUFFER, 0));
662 GLU_CHECK_GLW_CALL(m_gl, deleteFramebuffers(1, &fbo));
664 /* Draw right half of rectangle */
666 GLfloat vertices[] = { 0.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f};
667 GLfloat texcoords[] = {0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.5f, 1.0f};
668 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(texCoordLocation));
669 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
671 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords));
672 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, vertices));
673 GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
678 /* Get the reference data */
679 m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, reference->getAccess().getDataPtr());
683 m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
690 class GLES2ProgramSharingTest : public GLES2SharingTest
693 GLES2ProgramSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec);
696 glu::ShaderProgram* m_program;
698 virtual void createResource (void);
699 virtual void destroyResource (void);
700 virtual void renderResource (tcu::Surface* screen, tcu::Surface* reference);
704 GLES2ProgramSharingTest::GLES2ProgramSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec)
705 : GLES2SharingTest (eglTestCtx, name, desc, spec)
706 , m_program (DE_NULL)
710 void GLES2ProgramSharingTest::createResource (void)
712 const char* vertexShader = ""
713 "attribute mediump vec2 a_pos;\n"
714 "attribute mediump vec4 a_color;\n"
715 "varying mediump vec4 v_color;\n"
718 "\tv_color = a_color;\n"
719 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
722 const char* fragmentShader = ""
723 "varying mediump vec4 v_color;\n"
726 "\tgl_FragColor = v_color;\n"
729 m_program = new glu::ShaderProgram(m_gl, glu::makeVtxFragSources(vertexShader, fragmentShader));
731 if (!m_program->isOk())
732 TCU_FAIL("Failed to compile shader program");
735 void GLES2ProgramSharingTest::destroyResource (void)
740 void GLES2ProgramSharingTest::renderResource (tcu::Surface* screen, tcu::Surface* reference)
742 DE_ASSERT((screen && reference) || (!screen && !reference));
749 width = screen->getWidth();
750 height = screen->getHeight();
753 static const GLfloat coords[] = {
760 static const GLfloat colors [] = {
761 0.0f, 0.0f, 0.0f, 1.0f,
762 1.0f, 0.0f, 0.0f, 1.0f,
763 0.0f, 1.0f, 0.0f, 1.0f,
764 0.0f, 0.0f, 1.0f, 1.0f
767 static const GLushort indices[] = {
772 GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
774 GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
775 GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
777 GLU_CHECK_GLW_CALL(m_gl, useProgram(m_program->getProgram()));
779 GLuint coordLocation = m_gl.getAttribLocation(m_program->getProgram(), "a_pos");
780 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
781 TCU_CHECK(coordLocation != (GLuint)-1);
783 GLuint colorLocation = m_gl.getAttribLocation(m_program->getProgram(), "a_color");
784 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
785 TCU_CHECK(colorLocation != (GLuint)-1);
787 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(colorLocation));
788 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
790 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, colors));
791 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
793 GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
794 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(coordLocation));
795 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(colorLocation));
796 GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
800 m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
802 tcu::clear(reference->getAccess(), tcu::IVec4(0xff, 0, 0, 0xff));
804 int x1 = (int)(((float)width/2.0f) * (-0.9f) + ((float)width/2.0f));
805 int x2 = (int)(((float)width/2.0f) * 0.9f + ((float)width/2.0f));
806 int y1 = (int)(((float)height/2.0f) * (-0.9f) + ((float)height/2.0f));
807 int y2 = (int)(((float)height/2.0f) * 0.9f + ((float)height/2.0f));
809 for (int x = x1; x <= x2; x++)
811 for (int y = y1; y <= y2; y++)
813 float t = ((float)(x-x1) / (float)(x2-x1));
814 float s = ((float)(y-y1) / (float)(y2-y1));
815 bool isUpper = t > s;
817 tcu::Vec4 a(colors[0], colors[1], colors[2], colors[3]);
818 tcu::Vec4 b(colors[4 + 0], colors[4 + 1], colors[4 + 2], colors[4 + 3]);
819 tcu::Vec4 c(colors[8 + 0], colors[8 + 1], colors[8 + 2], colors[8 + 3]);
820 tcu::Vec4 d(colors[12 + 0], colors[12 + 1], colors[12 + 2], colors[12 + 3]);
826 color = a * (1.0f - t) + b * (t - s) + s * c;
828 color = a * (1.0f - s) + d * (s - t) + t * c;
830 int red = deClamp32((int)(255.0f * color.x()), 0, 255);
831 int green = deClamp32((int)(255.0f * color.y()), 0, 255);
832 int blue = deClamp32((int)(255.0f * color.z()), 0, 255);
833 int alpha = deClamp32((int)(255.0f * color.w()), 0, 255);
835 reference->setPixel(x, y, tcu::RGBA(red, green, blue, alpha));
841 class GLES2ShaderSharingTest : public GLES2SharingTest
844 GLES2ShaderSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, GLenum shaderType, const GLES2SharingTest::TestSpec& spec);
850 virtual void createResource (void);
851 virtual void destroyResource (void);
852 virtual void renderResource (tcu::Surface* screen, tcu::Surface* reference);
856 GLES2ShaderSharingTest::GLES2ShaderSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, GLenum shaderType, const GLES2SharingTest::TestSpec& spec)
857 : GLES2SharingTest (eglTestCtx, name, desc, spec)
859 , m_shaderType (shaderType)
863 void GLES2ShaderSharingTest::createResource (void)
865 const char* vertexShader = ""
866 "attribute mediump vec2 a_pos;\n"
867 "attribute mediump vec4 a_color;\n"
868 "varying mediump vec4 v_color;\n"
871 "\tv_color = a_color;\n"
872 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
875 const char* fragmentShader = ""
876 "varying mediump vec4 v_color;\n"
879 "\tgl_FragColor = v_color;\n"
883 m_shader = m_gl.createShader(m_shaderType);
884 GLU_CHECK_GLW_MSG(m_gl, "glCreateShader()");
886 switch (m_shaderType)
888 case GL_VERTEX_SHADER:
889 GLU_CHECK_GLW_CALL(m_gl, shaderSource(m_shader, 1, &vertexShader, DE_NULL));
892 case GL_FRAGMENT_SHADER:
893 GLU_CHECK_GLW_CALL(m_gl, shaderSource(m_shader, 1, &fragmentShader, DE_NULL));
900 GLU_CHECK_GLW_CALL(m_gl, compileShader(m_shader));
903 GLU_CHECK_GLW_CALL(m_gl, getShaderiv(m_shader, GL_COMPILE_STATUS, &status));
908 GLU_CHECK_GLW_CALL(m_gl, getShaderInfoLog(m_shader, 256, DE_NULL, buffer));
910 m_log << tcu::TestLog::Message << "Failed to compile shader" << tcu::TestLog::EndMessage;
912 switch (m_shaderType)
914 case GL_VERTEX_SHADER:
915 m_log << tcu::TestLog::Message << vertexShader << tcu::TestLog::EndMessage;
918 case GL_FRAGMENT_SHADER:
919 m_log << tcu::TestLog::Message << fragmentShader << tcu::TestLog::EndMessage;
926 m_log << tcu::TestLog::Message << buffer << tcu::TestLog::EndMessage;
927 TCU_FAIL("Failed to compile shader");
931 void GLES2ShaderSharingTest::destroyResource (void)
933 GLU_CHECK_GLW_CALL(m_gl, deleteShader(m_shader));
936 void GLES2ShaderSharingTest::renderResource (tcu::Surface* screen, tcu::Surface* reference)
938 DE_ASSERT((screen && reference) || (!screen && !reference));
943 const char* vertexShader = ""
944 "attribute mediump vec2 a_pos;\n"
945 "attribute mediump vec4 a_color;\n"
946 "varying mediump vec4 v_color;\n"
949 "\tv_color = a_color;\n"
950 "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
953 const char* fragmentShader = ""
954 "varying mediump vec4 v_color;\n"
957 "\tgl_FragColor = v_color;\n"
961 GLuint otherShader = (GLuint)-1;
963 switch (m_shaderType)
965 case GL_VERTEX_SHADER:
966 otherShader = m_gl.createShader(GL_FRAGMENT_SHADER);
967 GLU_CHECK_GLW_MSG(m_gl, "glCreateShader()");
968 GLU_CHECK_GLW_CALL(m_gl, shaderSource(otherShader, 1, &fragmentShader, DE_NULL));
971 case GL_FRAGMENT_SHADER:
972 otherShader = m_gl.createShader(GL_VERTEX_SHADER);
973 GLU_CHECK_GLW_MSG(m_gl, "glCreateShader()");
974 GLU_CHECK_GLW_CALL(m_gl, shaderSource(otherShader, 1, &vertexShader, DE_NULL));
981 GLU_CHECK_GLW_CALL(m_gl, compileShader(otherShader));
984 GLU_CHECK_GLW_CALL(m_gl, getShaderiv(otherShader, GL_COMPILE_STATUS, &status));
989 GLU_CHECK_GLW_CALL(m_gl, getShaderInfoLog(otherShader, 256, DE_NULL, buffer));
991 m_log << tcu::TestLog::Message << "Failed to compile shader" << tcu::TestLog::EndMessage;
993 switch (m_shaderType)
995 case GL_FRAGMENT_SHADER:
996 m_log << tcu::TestLog::Message << vertexShader << tcu::TestLog::EndMessage;
999 case GL_VERTEX_SHADER:
1000 m_log << tcu::TestLog::Message << fragmentShader << tcu::TestLog::EndMessage;
1007 m_log << tcu::TestLog::Message << buffer << tcu::TestLog::EndMessage;
1008 TCU_FAIL("Failed to compile shader");
1011 GLuint program = m_gl.createProgram();
1012 GLU_CHECK_GLW_MSG(m_gl, "glCreateProgram()");
1014 GLU_CHECK_GLW_CALL(m_gl, attachShader(program, m_shader));
1015 GLU_CHECK_GLW_CALL(m_gl, attachShader(program, otherShader));
1017 GLU_CHECK_GLW_CALL(m_gl, linkProgram(program));
1018 GLU_CHECK_GLW_CALL(m_gl, deleteShader(otherShader));
1021 GLU_CHECK_GLW_CALL(m_gl, getProgramiv(program, GL_LINK_STATUS, &status));
1026 GLU_CHECK_GLW_CALL(m_gl, getProgramInfoLog(program, 256, DE_NULL, buffer));
1028 m_log << tcu::TestLog::Message << "Failed to link program" << tcu::TestLog::EndMessage;
1030 m_log << tcu::TestLog::Message << vertexShader << tcu::TestLog::EndMessage;
1031 m_log << tcu::TestLog::Message << fragmentShader << tcu::TestLog::EndMessage;
1032 m_log << tcu::TestLog::Message << buffer << tcu::TestLog::EndMessage;
1033 TCU_FAIL("Failed to link program");
1038 width = screen->getWidth();
1039 height = screen->getHeight();
1042 static const GLfloat coords[] = {
1049 static const GLfloat colors [] = {
1050 0.0f, 0.0f, 0.0f, 1.0f,
1051 1.0f, 0.0f, 0.0f, 1.0f,
1052 0.0f, 1.0f, 0.0f, 1.0f,
1053 0.0f, 0.0f, 1.0f, 1.0f
1056 static const GLushort indices[] = {
1061 GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
1063 GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
1064 GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
1066 GLU_CHECK_GLW_CALL(m_gl, useProgram(program));
1068 GLuint coordLocation = m_gl.getAttribLocation(program, "a_pos");
1069 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
1070 TCU_CHECK(coordLocation != (GLuint)-1);
1072 GLuint colorLocation = m_gl.getAttribLocation(program, "a_color");
1073 GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
1074 TCU_CHECK(colorLocation != (GLuint)-1);
1076 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(colorLocation));
1077 GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
1079 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, colors));
1080 GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
1082 GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
1083 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(coordLocation));
1084 GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(colorLocation));
1085 GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
1089 m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
1091 tcu::clear(reference->getAccess(), tcu::IVec4(0xff, 0, 0, 0xff));
1093 int x1 = (int)(((float)width/2.0f) * (-0.9f) + ((float)width/2.0f));
1094 int x2 = (int)(((float)width/2.0f) * 0.9f + ((float)width/2.0f));
1095 int y1 = (int)(((float)height/2.0f) * (-0.9f) + ((float)height/2.0f));
1096 int y2 = (int)(((float)height/2.0f) * 0.9f + ((float)height/2.0f));
1098 for (int x = x1; x <= x2; x++)
1100 for (int y = y1; y <= y2; y++)
1102 float t = ((float)(x-x1) / (float)(x2-x1));
1103 float s = ((float)(y-y1) / (float)(y2-y1));
1104 bool isUpper = t > s;
1106 tcu::Vec4 a(colors[0], colors[1], colors[2], colors[3]);
1107 tcu::Vec4 b(colors[4 + 0], colors[4 + 1], colors[4 + 2], colors[4 + 3]);
1108 tcu::Vec4 c(colors[8 + 0], colors[8 + 1], colors[8 + 2], colors[8 + 3]);
1109 tcu::Vec4 d(colors[12 + 0], colors[12 + 1], colors[12 + 2], colors[12 + 3]);
1115 color = a * (1.0f - t) + b * (t - s) + s * c;
1117 color = a * (1.0f - s) + d * (s - t) + t * c;
1119 int red = deClamp32((int)(255.0f * color.x()), 0, 255);
1120 int green = deClamp32((int)(255.0f * color.y()), 0, 255);
1121 int blue = deClamp32((int)(255.0f * color.z()), 0, 255);
1122 int alpha = deClamp32((int)(255.0f * color.w()), 0, 255);
1124 reference->setPixel(x, y, tcu::RGBA(red, green, blue, alpha));
1130 SharingTests::SharingTests (EglTestContext& eglTestCtx)
1131 : TestCaseGroup (eglTestCtx, "sharing", "Sharing test cases")
1135 void SharingTests::init (void)
1137 TestCaseGroup* gles2 = new TestCaseGroup(m_eglTestCtx, "gles2", "OpenGL ES 2 sharing test");
1139 TestCaseGroup* context = new TestCaseGroup(m_eglTestCtx, "context", "Context creation and destruction tests");
1142 GLES2SharingTest::TestSpec spec;
1143 spec.destroyContextBFirst = false;
1144 spec.useResource = false;
1145 spec.destroyOnContexB = false;
1146 spec.initializeData = true;
1147 spec.renderOnContexA = true;
1148 spec.renderOnContexB = true;
1149 spec.verifyOnContexA = true;
1150 spec.verifyOnContexB = true;
1152 context->addChild(new GLES2SharingTest(m_eglTestCtx, "create_destroy", "Simple context creation and destruction", spec));
1155 GLES2SharingTest::TestSpec spec;
1156 spec.destroyContextBFirst = true;
1157 spec.useResource = false;
1158 spec.destroyOnContexB = false;
1159 spec.initializeData = false;
1160 spec.renderOnContexA = false;
1161 spec.renderOnContexB = false;
1162 spec.verifyOnContexA = false;
1163 spec.verifyOnContexB = false;
1165 context->addChild(new GLES2SharingTest(m_eglTestCtx, "create_destroy_mixed", "Simple context creation and destruction test with different destruction order", spec));
1168 gles2->addChild(context);
1170 TestCaseGroup* buffer = new TestCaseGroup(m_eglTestCtx, "buffer", "Buffer creation, destruction and rendering test");
1173 GLES2SharingTest::TestSpec spec;
1174 spec.destroyContextBFirst = false;
1175 spec.useResource = true;
1176 spec.destroyOnContexB = false;
1177 spec.initializeData = true;
1178 spec.renderOnContexA = false;
1179 spec.renderOnContexB = false;
1180 spec.verifyOnContexA = false;
1181 spec.verifyOnContexB = false;
1183 buffer->addChild(new GLES2BufferSharingTest(m_eglTestCtx, "create_delete", "Create and delete on shared context", spec));
1186 GLES2SharingTest::TestSpec spec;
1187 spec.destroyContextBFirst = false;
1188 spec.useResource = true;
1189 spec.destroyOnContexB = true;
1190 spec.initializeData = true;
1191 spec.renderOnContexA = false;
1192 spec.renderOnContexB = false;
1193 spec.verifyOnContexA = false;
1194 spec.verifyOnContexB = false;
1196 buffer->addChild(new GLES2BufferSharingTest(m_eglTestCtx, "create_delete_mixed", "Create and delet on different contexts", spec));
1199 GLES2SharingTest::TestSpec spec;
1200 spec.destroyContextBFirst = false;
1201 spec.useResource = true;
1202 spec.destroyOnContexB = false;
1203 spec.initializeData = true;
1204 spec.renderOnContexA = true;
1205 spec.renderOnContexB = true;
1206 spec.verifyOnContexA = true;
1207 spec.verifyOnContexB = true;
1209 buffer->addChild(new GLES2BufferSharingTest(m_eglTestCtx, "render", "Create, rendering on two different contexts and delete", spec));
1212 gles2->addChild(buffer);
1214 TestCaseGroup* texture = new TestCaseGroup(m_eglTestCtx, "texture", "Texture creation, destruction and rendering tests");
1217 GLES2SharingTest::TestSpec spec;
1218 spec.destroyContextBFirst = false;
1219 spec.useResource = true;
1220 spec.destroyOnContexB = false;
1221 spec.initializeData = true;
1222 spec.renderOnContexA = false;
1223 spec.renderOnContexB = false;
1224 spec.verifyOnContexA = false;
1225 spec.verifyOnContexB = false;
1227 texture->addChild(new GLES2TextureSharingTest(m_eglTestCtx, "create_delete", "Create and delete on shared context", spec, false));
1230 GLES2SharingTest::TestSpec spec;
1231 spec.destroyContextBFirst = false;
1232 spec.useResource = true;
1233 spec.destroyOnContexB = true;
1234 spec.initializeData = true;
1235 spec.renderOnContexA = false;
1236 spec.renderOnContexB = false;
1237 spec.verifyOnContexA = false;
1238 spec.verifyOnContexB = false;
1240 texture->addChild(new GLES2TextureSharingTest(m_eglTestCtx, "create_delete_mixed", "Create and delete on different contexts", spec, false));
1243 GLES2SharingTest::TestSpec spec;
1244 spec.destroyContextBFirst = false;
1245 spec.useResource = true;
1246 spec.destroyOnContexB = false;
1247 spec.initializeData = true;
1248 spec.renderOnContexA = true;
1249 spec.renderOnContexB = true;
1250 spec.verifyOnContexA = true;
1251 spec.verifyOnContexB = true;
1253 texture->addChild(new GLES2TextureSharingTest(m_eglTestCtx,"render", "Create, render in two contexts and delete" , spec, false));
1256 GLES2SharingTest::TestSpec spec;
1257 spec.destroyContextBFirst = false;
1258 spec.useResource = true;
1259 spec.destroyOnContexB = false;
1260 spec.initializeData = true;
1261 spec.renderOnContexA = true;
1262 spec.renderOnContexB = false;
1263 spec.verifyOnContexA = true;
1264 spec.verifyOnContexB = false;
1266 texture->addChild(new GLES2TextureSharingTest(m_eglTestCtx, "render_sample_mixed", "sampling, read pixels in different fbo", spec, true));
1268 gles2->addChild(texture);
1270 TestCaseGroup* program = new TestCaseGroup(m_eglTestCtx, "program", "Program creation, destruction and rendering test");
1273 GLES2SharingTest::TestSpec spec;
1274 spec.destroyContextBFirst = false;
1275 spec.useResource = true;
1276 spec.destroyOnContexB = false;
1277 spec.initializeData = true;
1278 spec.renderOnContexA = false;
1279 spec.renderOnContexB = false;
1280 spec.verifyOnContexA = false;
1281 spec.verifyOnContexB = false;
1283 program->addChild(new GLES2ProgramSharingTest(m_eglTestCtx, "create_delete", "Create and delete on shared context", spec));
1286 GLES2SharingTest::TestSpec spec;
1287 spec.destroyContextBFirst = false;
1288 spec.useResource = true;
1289 spec.destroyOnContexB = true;
1290 spec.initializeData = true;
1291 spec.renderOnContexA = false;
1292 spec.renderOnContexB = false;
1293 spec.verifyOnContexA = false;
1294 spec.verifyOnContexB = false;
1296 program->addChild(new GLES2ProgramSharingTest(m_eglTestCtx, "create_delete_mixed", "Create and delete on different contexts", spec));
1299 GLES2SharingTest::TestSpec spec;
1300 spec.destroyContextBFirst = false;
1301 spec.useResource = true;
1302 spec.destroyOnContexB = false;
1303 spec.initializeData = true;
1304 spec.renderOnContexA = true;
1305 spec.renderOnContexB = true;
1306 spec.verifyOnContexA = true;
1307 spec.verifyOnContexB = true;
1309 program->addChild(new GLES2ProgramSharingTest(m_eglTestCtx, "render", "Create, render in two contexts and delete", spec));
1312 gles2->addChild(program);
1314 TestCaseGroup* shader = new TestCaseGroup(m_eglTestCtx, "shader", "Shader creation, destruction and rendering test");
1317 GLES2SharingTest::TestSpec spec;
1318 spec.destroyContextBFirst = false;
1319 spec.useResource = true;
1320 spec.destroyOnContexB = false;
1321 spec.initializeData = true;
1322 spec.renderOnContexA = false;
1323 spec.renderOnContexB = false;
1324 spec.verifyOnContexA = false;
1325 spec.verifyOnContexB = false;
1327 shader->addChild(new GLES2ShaderSharingTest(m_eglTestCtx, "create_delete_vert", "Create and delete on shared context", GL_VERTEX_SHADER, spec));
1330 GLES2SharingTest::TestSpec spec;
1331 spec.destroyContextBFirst = false;
1332 spec.useResource = true;
1333 spec.destroyOnContexB = true;
1334 spec.initializeData = true;
1335 spec.renderOnContexA = false;
1336 spec.renderOnContexB = false;
1337 spec.verifyOnContexA = false;
1338 spec.verifyOnContexB = false;
1340 shader->addChild(new GLES2ShaderSharingTest(m_eglTestCtx, "create_delete_mixed_vert", "Create and delete on different contexts", GL_VERTEX_SHADER, spec));
1343 GLES2SharingTest::TestSpec spec;
1344 spec.destroyContextBFirst = false;
1345 spec.useResource = true;
1346 spec.destroyOnContexB = false;
1347 spec.initializeData = true;
1348 spec.renderOnContexA = true;
1349 spec.renderOnContexB = true;
1350 spec.verifyOnContexA = true;
1351 spec.verifyOnContexB = true;
1353 shader->addChild(new GLES2ShaderSharingTest(m_eglTestCtx, "render_vert", "Create, render on two contexts and delete", GL_VERTEX_SHADER, spec));
1356 GLES2SharingTest::TestSpec spec;
1357 spec.destroyContextBFirst = false;
1358 spec.useResource = true;
1359 spec.destroyOnContexB = false;
1360 spec.initializeData = true;
1361 spec.renderOnContexA = false;
1362 spec.renderOnContexB = false;
1363 spec.verifyOnContexA = false;
1364 spec.verifyOnContexB = false;
1366 shader->addChild(new GLES2ShaderSharingTest(m_eglTestCtx, "create_delete_frag", "Create and delete on shared context", GL_FRAGMENT_SHADER, spec));
1369 GLES2SharingTest::TestSpec spec;
1370 spec.destroyContextBFirst = false;
1371 spec.useResource = true;
1372 spec.destroyOnContexB = true;
1373 spec.initializeData = true;
1374 spec.renderOnContexA = false;
1375 spec.renderOnContexB = false;
1376 spec.verifyOnContexA = false;
1377 spec.verifyOnContexB = false;
1379 shader->addChild(new GLES2ShaderSharingTest(m_eglTestCtx, "create_delete_mixed_frag", "Create and delete on different contexts", GL_FRAGMENT_SHADER, spec));
1382 GLES2SharingTest::TestSpec spec;
1383 spec.destroyContextBFirst = false;
1384 spec.useResource = true;
1385 spec.destroyOnContexB = false;
1386 spec.initializeData = true;
1387 spec.renderOnContexA = true;
1388 spec.renderOnContexB = true;
1389 spec.verifyOnContexA = true;
1390 spec.verifyOnContexB = true;
1392 shader->addChild(new GLES2ShaderSharingTest(m_eglTestCtx, "render_frag", "Create, render on two contexts and delete", GL_FRAGMENT_SHADER, spec));
1396 gles2->addChild(shader);
1399 gles2->addChild(new GLES2SharingThreadedTests(m_eglTestCtx));