Esempio n. 1
0
    void runMipmapTest(OGLMemoryMode memoryMode, const string& sFName)
    {
        cerr << "    Testing mipmap support, " << sFName << ", " << 
                oglMemoryMode2String(memoryMode) << endl;
        BitmapPtr pOrigBmp = loadTestBmp(sFName);
        GLContextManager* pCM = GLContextManager::get();
        MCTexturePtr pTex = pCM->createTextureFromBmp(pOrigBmp, true);
        pCM->uploadData();
        pTex->generateMipmaps();

        if (GLContext::getCurrent()->isGLES()) {
            // GLES doesn't support attaching texture mipmap levels other than 0 to
            // FBOs, so moveTextureToBmp() will fail. Skip result image comparison.
            return;
        }
        BitmapPtr pResultBmp = pTex->moveTextureToBmp(1);
        IntPoint newSize(pOrigBmp->getSize()/2);
        TEST(pResultBmp->getSize() == newSize);
        FilterResizeBilinear resizer(newSize);
        BitmapPtr pBaselineBmp = resizer.apply(pOrigBmp);
        string sName;
        if (memoryMode == MM_PBO) {
            sName = "pbo-mipmap";
        } else {
            sName = "ogl-mipmap";
        }
        testEqual(*pResultBmp, *pBaselineBmp, sName, 7, 15);
    }
Esempio n. 2
0
GPUBlurFilter::GPUBlurFilter(const IntPoint& size, PixelFormat pfSrc, PixelFormat pfDest,
        float stdDev, bool bClipBorders, bool bStandalone, bool bUseFloatKernel)
    : GPUFilter(pfSrc, pfDest, bStandalone, SHADERID_HORIZ, 2),
      m_bClipBorders(bClipBorders),
      m_bUseFloatKernel(bUseFloatKernel)
{
    ObjectCounter::get()->incRef(&typeid(*this));

    GLContext::getCurrent()->ensureFullShaders("GPUBlurFilter");
#ifndef AVG_ENABLE_EGL
    if (!m_bClipBorders) {
        //TODO: TO_BORDER DOES NOT EXIST IN GLESV2
        m_WrapMode = WrapMode(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
    }
#endif
    setDimensions(size, stdDev);
    GLContextManager* pCM = GLContextManager::get();
    pCM->createShader(SHADERID_VERT);
    setStdDev(stdDev);

    m_pHorizWidthParam = pCM->createShaderParam<float>(SHADERID_HORIZ, "u_Width");
    m_pHorizRadiusParam = pCM->createShaderParam<int>(SHADERID_HORIZ, "u_Radius");
    m_pHorizTextureParam = pCM->createShaderParam<int>(SHADERID_HORIZ, "u_Texture");
    m_pHorizKernelTexParam = pCM->createShaderParam<int>(SHADERID_HORIZ, "u_KernelTex");

    m_pVertWidthParam = pCM->createShaderParam<float>(SHADERID_VERT, "u_Width");
    m_pVertRadiusParam = pCM->createShaderParam<int>(SHADERID_VERT, "u_Radius");
    m_pVertTextureParam = pCM->createShaderParam<int>(SHADERID_VERT, "u_Texture");
    m_pVertKernelTexParam = pCM->createShaderParam<int>(SHADERID_VERT, "u_KernelTex");
}
Esempio n. 3
0
 void runTests() 
 {
     BitmapPtr pOrigBmp = loadTestBmp("rgb24-64x64");
     GLContextManager* pCM = GLContextManager::get();
     MCTexturePtr pTex = pCM->createTextureFromBmp(pOrigBmp);
     pCM->uploadData();
     GPURGB2YUVFilter f(pOrigBmp->getSize());
     f.apply(pTex->getCurTex());
     BitmapPtr pResultBmp = f.getResults();
     pResultBmp = convertYUVX444ToRGB(pResultBmp);
     testEqual(*pResultBmp, *pOrigBmp, "RGB2YUV", 1, 2);
 }
Esempio n. 4
0
    void runCompressionTest(OGLMemoryMode memoryMode, const string& sFName)
    {
        cerr << "    Testing B5G6R5 compression, " << sFName << ", " << 
                oglMemoryMode2String(memoryMode) << endl;
        BitmapPtr pFileBmp = loadTestBmp(sFName);
        BitmapPtr pOrigBmp(new Bitmap(pFileBmp->getSize(), B5G6R5));
        pOrigBmp->copyPixels(*pFileBmp);
        GLContextManager* pCM = GLContextManager::get();
        MCTexturePtr pTex = pCM->createTextureFromBmp(pOrigBmp);
        pCM->uploadData();

        BitmapPtr pDestBmp = pTex->moveTextureToBmp();
    }
Esempio n. 5
0
 void runImageTest(bool bPOT, OGLMemoryMode memoryMode, const string& sFName)
 {
     string sResultFName = sFName + "-" + oglMemoryMode2String(memoryMode) + "-";
     if (bPOT) {
         sResultFName += "pot";
     } else {
         sResultFName += "npot";
     }
     cerr << "    Testing " << sResultFName << endl;
     BitmapPtr pOrigBmp = loadTestBmp(sFName);
     {
         GLContextManager* pCM = GLContextManager::get();
         MCTexturePtr pTex = pCM->createTextureFromBmp(pOrigBmp, false,
                 GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, bPOT, 0);
         pCM->uploadData();
         BitmapPtr pDestBmp = pTex->moveTextureToBmp();
         testEqual(*pDestBmp, *pOrigBmp, sResultFName+"-move", 0.01, 0.1);
     }
 }
Esempio n. 6
0
void RasterNode::setupFX()
{
    if (m_pSurface && m_pSurface->getSize() != IntPoint(-1,-1) && m_pFXNode) {
        m_pFXNode->setSize(m_pSurface->getSize());
        m_pFXNode->connect();
        m_bFXDirty = true;
        if (!m_pFBO || m_pFBO->getSize() != m_pSurface->getSize()) {
            PixelFormat pf = BitmapLoader::get()->getDefaultPixelFormat(true);
#ifdef AVG_ENABLE_EGL
            unsigned wrapMode = GL_CLAMP_TO_EDGE;
#else
            unsigned wrapMode = GL_CLAMP_TO_BORDER;
#endif
            GLContextManager* pCM = GLContextManager::get();
            m_pFBO = pCM->createFBO(IntPoint(m_pSurface->getSize()), pf, 1, 1, false, 
                    false, getMipmap(), wrapMode, wrapMode);
            m_pImagingProjection = ImagingProjectionPtr(new ImagingProjection(
                    m_pSurface->getSize()));
        }
    }
}
Esempio n. 7
0
bool runTests(bool bGLES, GLConfig::ShaderUsage su)
{
    string sVariant = string("GLES: ") + toString(bGLES) + ", ShaderUsage: " +
            GLConfig::shaderUsageToString(su);
    cerr << "---------------------------------------------------" << endl;
    cerr << sVariant << endl; 
    cerr << "---------------------------------------------------" << endl;
    GLContextManager cm;
    GLContext* pContext = cm.createContext(GLConfig(bGLES, false, true, 1, su, true));
    pContext->enableErrorChecks(true);
    glDisable(GL_BLEND);
    GLContext::checkError("glDisable(GL_BLEND)");
    ShaderRegistry::get()->setShaderPath("./shaders");
    try {
        GPUTestSuite suite(sVariant);
        suite.runTests();
        delete pContext;
        return suite.isOk();
    } catch (Exception& ex) {
        cerr << "Exception: " << ex.getStr() << endl;
        delete pContext;
        return false;
    }
}
Esempio n. 8
0
void GPUImage::setupBitmapSurface()
{
    GLContextManager* pCM = GLContextManager::get();
    MCTexturePtr pTex = pCM->createTextureFromBmp(m_pBmp, m_bUseMipmaps);
    m_pSurface->create(m_pBmp->getPixelFormat(), pTex);
}