// Test creating a pbuffer from a d3d surface and clearing it TEST_P(D3DTextureTest, Clear) { if (!valid()) { return; } EGLWindow *window = getEGLWindow(); EGLDisplay display = window->getDisplay(); const size_t bufferSize = 32; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_NO_TEXTURE, EGL_NO_TEXTURE, 1, 0); ASSERT_EGL_SUCCESS(); ASSERT_NE(pbuffer, EGL_NO_SURFACE); // Apply the Pbuffer and clear it to purple and verify eglMakeCurrent(display, pbuffer, pbuffer, window->getContext()); ASSERT_EGL_SUCCESS(); glViewport(0, 0, static_cast<GLsizei>(bufferSize), static_cast<GLsizei>(bufferSize)); glClearColor(1.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ASSERT_GL_NO_ERROR(); EXPECT_PIXEL_EQ(static_cast<GLint>(bufferSize) / 2, static_cast<GLint>(bufferSize) / 2, 255, 0, 255, 255); // Make current with fixture EGL to ensure the Surface can be released immediately. getEGLWindow()->makeCurrent(); eglDestroySurface(display, pbuffer); }
// Test creating a pbuffer from a multisampled d3d surface and clearing it. TEST_P(D3DTextureTestMS, Clear) { EGLWindow *window = getEGLWindow(); EGLDisplay display = window->getDisplay(); constexpr size_t bufferSize = 32; constexpr UINT testpoint = bufferSize / 2; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_NO_TEXTURE, EGL_NO_TEXTURE, 4, static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN)); ASSERT_EGL_SUCCESS(); ASSERT_NE(pbuffer, EGL_NO_SURFACE); // Apply the Pbuffer and clear it to magenta and verify eglMakeCurrent(display, pbuffer, pbuffer, window->getContext()); ASSERT_EGL_SUCCESS(); glViewport(0, 0, static_cast<GLsizei>(bufferSize), static_cast<GLsizei>(bufferSize)); glClearColor(1.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ASSERT_GL_NO_ERROR(); EXPECT_PIXEL_COLOR_EQ(testpoint, testpoint, GLColor::magenta); // Make current with fixture EGL to ensure the Surface can be released immediately. getEGLWindow()->makeCurrent(); eglDestroySurface(display, pbuffer); }
OSXPBuffer::OSXPBuffer( PixelComponentType format, uint32 width, uint32 height ) : GLPBuffer( format, width, height ), mContext( NULL ) { LogManager::getSingleton().logMessage( "OSXPBuffer::OSXPBuffer()" ); createPBuffer(); // Create context //mContext = OGRE_NEW OSXCarbonContext(mAGLContext); }
// Verify that creating a pbuffer from a multisampled texture with a multisampled window will fail // when the sample counts do not match. TEST_P(D3DTextureTestMS, CheckSampleMismatch) { constexpr size_t bufferSize = 32; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_NO_TEXTURE, EGL_NO_TEXTURE, 2, static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN)); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EQ(pbuffer, nullptr); }
// Test for failure when creating a pbuffer from a multisampled d3d surface to bind to a texture. TEST_P(D3DTextureTestMS, BindTexture) { constexpr size_t bufferSize = 32; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_TEXTURE_RGBA, EGL_TEXTURE_2D, 4, static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN)); EXPECT_EGL_ERROR(EGL_BAD_ATTRIBUTE); EXPECT_EQ(pbuffer, nullptr); }
OglContext::OglContext(ms_uint32 width, ms_uint32 height) : valid(false) { if (!window && !initWindow()) return; if (!sharingContext && !initSharingContext()) return; if (!(this->width = getTextureSize(GL_TEXTURE_WIDTH, width))) return; if (!(this->height = getTextureSize(GL_TEXTURE_HEIGHT, height))) return; if (!createPBuffer(this->width, this->height)) return; if (!makeCurrent()) return; valid = true; }
// Test creating a pbuffer with a D3D texture and depth stencil bits in the EGL config creates keeps // its depth stencil buffer TEST_P(D3DTextureTest, DepthStencil) { if (!valid()) { return; } EGLWindow *window = getEGLWindow(); EGLDisplay display = window->getDisplay(); const size_t bufferSize = 32; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_NO_TEXTURE, EGL_NO_TEXTURE, 1, 0); ASSERT_EGL_SUCCESS(); ASSERT_NE(pbuffer, EGL_NO_SURFACE); // Apply the Pbuffer and clear it to purple and verify eglMakeCurrent(display, pbuffer, pbuffer, window->getContext()); ASSERT_EGL_SUCCESS(); glViewport(0, 0, static_cast<GLsizei>(bufferSize), static_cast<GLsizei>(bufferSize)); glClearColor(0.0f, 1.0f, 1.0f, 1.0f); glClearDepthf(0.5f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ASSERT_GL_NO_ERROR(); glEnable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); glUseProgram(mTextureProgram); glUniform1i(mTextureUniformLocation, 0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &GLColor::green); // Draw a quad that will fail the depth test and verify that the buffer is unchanged drawQuad(mTextureProgram, "position", 1.0f); EXPECT_PIXEL_COLOR_EQ(static_cast<GLint>(bufferSize) / 2, static_cast<GLint>(bufferSize) / 2, GLColor::cyan); // Draw a quad that will pass the depth test and verify that the buffer is green drawQuad(mTextureProgram, "position", -1.0f); EXPECT_PIXEL_COLOR_EQ(static_cast<GLint>(bufferSize) / 2, static_cast<GLint>(bufferSize) / 2, GLColor::green); // Make current with fixture EGL to ensure the Surface can be released immediately. getEGLWindow()->makeCurrent(); eglDestroySurface(display, pbuffer); }
Win32PBuffer::Win32PBuffer(PixelComponentType format, size_t width, size_t height): GLPBuffer(format, width, height), mContext(0) { createPBuffer(); // Create context mContext = new Win32Context(mHDC, mGlrc); #if 0 if(mUseBind) { // Bind texture glBindTextureEXT(GL_TEXTURE_2D, static_cast<GLTexture*>(mTexture.get())->getGLID()); wglBindTexImageARB(mPBuffer, WGL_FRONT_LEFT_ARB); } #endif }
// Test creating a pbuffer from a multisampled d3d surface and drawing with a program. TEST_P(D3DTextureTestMS, DrawProgram) { EGLWindow *window = getEGLWindow(); EGLDisplay display = window->getDisplay(); constexpr size_t bufferSize = 32; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_NO_TEXTURE, EGL_NO_TEXTURE, 4, static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN)); ASSERT_EGL_SUCCESS(); ASSERT_NE(pbuffer, EGL_NO_SURFACE); // Apply the Pbuffer and clear it to magenta eglMakeCurrent(display, pbuffer, pbuffer, window->getContext()); ASSERT_EGL_SUCCESS(); glViewport(0, 0, static_cast<GLsizei>(bufferSize), static_cast<GLsizei>(bufferSize)); glClearColor(1.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ASSERT_GL_NO_ERROR(); constexpr GLint testPoint = bufferSize / 2; EXPECT_PIXEL_COLOR_EQ(testPoint, testPoint, GLColor::magenta); // Apply the window surface eglMakeCurrent(display, window->getSurface(), window->getSurface(), window->getContext()); ASSERT_EGL_SUCCESS(); glViewport(0, 0, getWindowWidth(), getWindowHeight()); ASSERT_EGL_SUCCESS(); // Draw a quad and verify that it is magenta glUseProgram(mTextureProgramNoSampling); EXPECT_GL_NO_ERROR(); drawQuad(mTextureProgramNoSampling, "position", 0.5f); EXPECT_GL_NO_ERROR(); // Verify that magenta was drawn EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::magenta); // Make current with fixture EGL to ensure the Surface can be released immediately. getEGLWindow()->makeCurrent(); eglDestroySurface(display, pbuffer); }
// Verify that creating a pbuffer with a multisampled texture will fail on a non-multisampled // window. TEST_P(D3DTextureTest, CheckSampleMismatch) { if (!valid()) { return; } // Multisampling is not supported on D3D9 or OpenGL. if (IsD3D9() || IsOpenGL()) { return; } constexpr size_t bufferSize = 32; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_NO_TEXTURE, EGL_NO_TEXTURE, 2, static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN)); EXPECT_EGL_ERROR(EGL_BAD_PARAMETER); EXPECT_EQ(pbuffer, nullptr); }
void MakeCurrentPerfCase::createSurfaces (void) { vector<SurfaceType> types; if ((m_spec.surfaceTypes & SURFACETYPE_WINDOW) != 0) types.push_back(SURFACETYPE_WINDOW); if ((m_spec.surfaceTypes & SURFACETYPE_PIXMAP) != 0) types.push_back(SURFACETYPE_PIXMAP); if ((m_spec.surfaceTypes & SURFACETYPE_PBUFFER) != 0) types.push_back(SURFACETYPE_PBUFFER); DE_ASSERT((int)types.size() <= m_spec.surfaceCount); // Create surfaces for (int surfaceNdx = 0; surfaceNdx < m_spec.surfaceCount; surfaceNdx++) { SurfaceType type = types[surfaceNdx % types.size()]; switch (type) { case SURFACETYPE_PBUFFER: createPBuffer(); break; case SURFACETYPE_WINDOW: createWindow(); break; case SURFACETYPE_PIXMAP: createPixmap(); break; default: DE_ASSERT(false); }; } }
// Test creating a pbuffer from a d3d surface and binding it to a texture TEST_P(D3DTextureTest, BindTexImage) { if (!valid()) { return; } EGLWindow *window = getEGLWindow(); EGLDisplay display = window->getDisplay(); const size_t bufferSize = 32; EGLSurface pbuffer = createPBuffer(bufferSize, bufferSize, EGL_TEXTURE_RGBA, EGL_TEXTURE_2D, 1, 0); ASSERT_EGL_SUCCESS(); ASSERT_NE(pbuffer, EGL_NO_SURFACE); // Apply the Pbuffer and clear it to purple eglMakeCurrent(display, pbuffer, pbuffer, window->getContext()); ASSERT_EGL_SUCCESS(); glViewport(0, 0, static_cast<GLsizei>(bufferSize), static_cast<GLsizei>(bufferSize)); glClearColor(1.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ASSERT_GL_NO_ERROR(); EXPECT_PIXEL_EQ(static_cast<GLint>(bufferSize) / 2, static_cast<GLint>(bufferSize) / 2, 255, 0, 255, 255); // Apply the window surface eglMakeCurrent(display, window->getSurface(), window->getSurface(), window->getContext()); // Create a texture and bind the Pbuffer to it GLuint texture = 0; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); EXPECT_GL_NO_ERROR(); eglBindTexImage(display, pbuffer, EGL_BACK_BUFFER); glViewport(0, 0, getWindowWidth(), getWindowHeight()); ASSERT_EGL_SUCCESS(); // Draw a quad and verify that it is purple glUseProgram(mTextureProgram); glUniform1i(mTextureUniformLocation, 0); drawQuad(mTextureProgram, "position", 0.5f); EXPECT_GL_NO_ERROR(); // Unbind the texture eglReleaseTexImage(display, pbuffer, EGL_BACK_BUFFER); ASSERT_EGL_SUCCESS(); // Verify that purple was drawn EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 255, 0, 255, 255); glDeleteTextures(1, &texture); // Make current with fixture EGL to ensure the Surface can be released immediately. getEGLWindow()->makeCurrent(); eglDestroySurface(display, pbuffer); }