Пример #1
0
bool
MM_EnvironmentBase::saveObjects(omrobjectptr_t objectPtr)
{
	void *heapBase = getExtensions()->heap->getHeapBase();
	void *heapTop = getExtensions()->heap->getHeapTop();

	Assert_MM_true((heapBase <= objectPtr) && (heapTop > objectPtr));
	Assert_MM_true((heapBase <= objectPtr) && (heapTop > objectPtr));
	Assert_MM_true(_omrVMThread->_savedObject1 != objectPtr);
	Assert_MM_true(_omrVMThread->_savedObject2 != objectPtr);

	if (NULL == _omrVMThread->_savedObject1) {
		_omrVMThread->_savedObject1 = objectPtr;
		return true;
	} else {
		Assert_MM_true((heapBase <= _omrVMThread->_savedObject1) && (heapTop > _omrVMThread->_savedObject1));
	}

	if (NULL == _omrVMThread->_savedObject2) {
		_omrVMThread->_savedObject2 = objectPtr;
		return true;
	} else {
		Assert_MM_true((heapBase <= _omrVMThread->_savedObject2) && (heapTop > _omrVMThread->_savedObject2));
	}

	Assert_MM_unreachable();
	return false;
}
Пример #2
0
void
MM_EnvironmentStandard::flushGCCaches()
{
#if defined(OMR_GC_CONCURRENT_SCAVENGER)
	if (getExtensions()->concurrentScavenger) {
		if (MUTATOR_THREAD == getThreadType()) {
			if (NULL != getExtensions()->scavenger) {
				getExtensions()->scavenger->threadFinalReleaseCopyCaches(this, this);
			}
		}
	}
#endif /* OMR_GC_CONCURRENT_SCAVENGER */
}
Пример #3
0
void
QueryGeometry::flushDeletedQueryObjects( unsigned int contextID, double /*currentTime*/, double& availableTime )
{
    // if no time available don't try to flush objects.
    if (availableTime<=0.0) return;

    const osg::Timer& timer = *osg::Timer::instance();
    osg::Timer_t start_tick = timer.tick();
    double elapsedTime = 0.0;

    {
        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedQueryObjectCache);

        const osg::Drawable::Extensions* extensions = getExtensions( contextID, true );

        QueryObjectList& qol = s_deletedQueryObjectCache[contextID];

        for(QueryObjectList::iterator titr=qol.begin();
            titr!=qol.end() && elapsedTime<availableTime;
            )
        {
            extensions->glDeleteQueries( 1L, &(*titr ) );
            titr = qol.erase(titr);
            elapsedTime = timer.delta_s(start_tick,timer.tick());
        }
    }
        
    availableTime -= elapsedTime;
}
Пример #4
0
void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
{
    // NVIDIA drivers have a bug where calling readPixels in BGRA can return the wrong values for the alpha channel when the alpha is off for the context.
    if (!m_attrs.alpha && getExtensions()->isNVIDIA()) {
        ::glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
#if USE(ACCELERATE)
        vImage_Buffer src;
        src.height = height;
        src.width = width;
        src.rowBytes = width * 4;
        src.data = pixels;

        vImage_Buffer dest;
        dest.height = height;
        dest.width = width;
        dest.rowBytes = width * 4;
        dest.data = pixels;

        // Swap pixel channels from RGBA to BGRA.
        const uint8_t map[4] = { 2, 1, 0, 3 };
        vImagePermuteChannels_ARGB8888(&src, &dest, map, kvImageNoFlags);
#else
        int totalBytes = width * height * 4;
        for (int i = 0; i < totalBytes; i += 4)
            std::swap(pixels[i], pixels[i + 2]);
#endif
    } else
        ::glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
}
Пример #5
0
QueryData genOsqueryExtensions(QueryContext& context) {
  QueryData results;

  ExtensionList extensions;
  if (getExtensions(extensions).ok()) {
    for (const auto& extension : extensions) {
      Row r;
      r["uuid"] = TEXT(extension.first);
      r["name"] = extension.second.name;
      r["version"] = extension.second.version;
      r["sdk_version"] = extension.second.sdk_version;
      r["path"] = getExtensionSocket(extension.first);
      r["type"] = (extension.first == 0) ? "core" : "extension";
      results.push_back(r);
    }
  }

  const auto& modules = RegistryFactory::getModules();
  for (const auto& module : modules) {
    Row r;
    r["uuid"] = TEXT(module.first);
    r["name"] = module.second.name;
    r["version"] = module.second.version;
    r["sdk_version"] = module.second.sdk_version;
    r["path"] = module.second.path;
    r["type"] = "module";
    results.push_back(r);
  }

  return results;
}
Пример #6
0
ESContext::ESContext(EGLDisplay & display, EGLSurface & surface, EGLConfig & config)
	: eglDisplay(nullptr), eglContext(nullptr), eglSurface(nullptr)
{
	EGLint attribList[] = {
		EGL_CONTEXT_CLIENT_VERSION, 2,
		EGL_NONE, EGL_NONE
	};

	//create context
	eglContext = eglCreateContext(display, config, EGL_NO_CONTEXT, attribList);
	if (eglContext == EGL_NO_CONTEXT) {
		destroy();
		std::cout << "Failed to get an EGL context!" <<std::endl;
		return;
	}
	//make context current
	if(!eglMakeCurrent(display, surface, surface, eglContext)) {
		std::cout << "Failed to make render context current!" << std::endl;
		return;
	}
	//get extensions
	getExtensions();
	//get function bindings here
	if (!getBindings()) {
        std::cout << "Failed to get all function bindings!" << std::endl;
	}
	//setup members
	eglDisplay = display;
	eglSurface = surface;
}
Пример #7
0
	// This method calls the lambdas that were collected
	// when the flags were registered. The lambda will decide
	// if the extension is kept in the list or drops out.
	// In a second pass the prerequisites are checked
	// and an error message may be printed.
	void ConversionJob::frontendExtensionInit() {
		// reset extensions list in case extensions changed, we do not want duplicates
		extensionList.clear();

		// register all extensions that should be registered
		for(auto it = extensions.begin(); it != extensions.end(); ++it) {
			if(it->second(*this)) {
				extensionList.push_back(it->first);

				// collect the kidnapped headers and add them to the list
				for(auto kidnappedHeader : it->first->getKidnappedHeaderList()) {
					addSystemHeadersDirectory(kidnappedHeader);
				}

				// add additional include directories
				for(auto includeDir : it->first->getIncludeDirList()) {
					addIncludeDirectory(includeDir);
				}
			}
		}
		// check pre-requisites
		for(auto ext : getExtensions()) {
			auto isMissing = ext->isPrerequisiteMissing(*this);
			if(isMissing) {
				std::cerr << "Prerequisite for an extension is missing:\n" << *isMissing << std::endl;
				assert_fail() << "Aborting due to frontend extension prerequisite error.";
			}
		}
	}
void GraphicsContext3D::validateAttributes()
{
    Extensions3D* extensions = getExtensions();
    if (m_attrs.stencil) {
        const char* packedDepthStencilExtension = isGLES2Compliant() ? "GL_OES_packed_depth_stencil" : "GL_EXT_packed_depth_stencil";
        if (extensions->supports(packedDepthStencilExtension)) {
            extensions->ensureEnabled(packedDepthStencilExtension);
            // Force depth if stencil is true.
            m_attrs.depth = true;
        } else
            m_attrs.stencil = false;
    }
    if (m_attrs.antialias) {
        bool isValidVendor = true;
        // Currently in Mac we only turn on antialias if vendor is NVIDIA,
        // or if ATI and on 10.7.2 and above.
        const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
        if (!std::strstr(vendor, "NVIDIA") && !(std::strstr(vendor, "ATI") && systemAllowsMultisamplingOnATICards()))
            isValidVendor = false;
        if (!isValidVendor || !extensions->supports("GL_ANGLE_framebuffer_multisample") || isGLES2Compliant())
            m_attrs.antialias = false;
        else
            extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample");
    }
}
Пример #9
0
void
MM_EnvironmentBase::restoreObjects(omrobjectptr_t *objectPtrIndirect)
{
	void *heapBase = getExtensions()->heap->getHeapBase();
	void *heapTop = getExtensions()->heap->getHeapTop();

	if (NULL != _omrVMThread->_savedObject2) {
		Assert_MM_true((heapBase <= _omrVMThread->_savedObject2) && (heapTop > _omrVMThread->_savedObject2));
		*objectPtrIndirect = (omrobjectptr_t)_omrVMThread->_savedObject2;
		_omrVMThread->_savedObject2 = NULL;
	} else if (NULL != _omrVMThread->_savedObject1) {
		Assert_MM_true((heapBase <= _omrVMThread->_savedObject1) && (heapTop > _omrVMThread->_savedObject1));
		*objectPtrIndirect = (omrobjectptr_t)_omrVMThread->_savedObject1;
		_omrVMThread->_savedObject1 = NULL;
	} else {
		Assert_MM_unreachable();
	}
}
Пример #10
0
void Extensions3DOpenGLCommon::initializeAvailableExtensions()
{
    String extensionsString = getExtensions();
    Vector<String> availableExtensions;
    extensionsString.split(' ', availableExtensions);
    for (size_t i = 0; i < availableExtensions.size(); ++i)
        m_availableExtensions.add(availableExtensions[i]);
    m_initializedAvailableExtensions = true;
}
Пример #11
0
bool
MM_EnvironmentBase::tryAcquireExclusiveVMAccessForGC(MM_Collector *collector)
{
	MM_GCExtensionsBase *extensions = getExtensions();
	uintptr_t collectorAccessCount = collector->getExclusiveAccessCount();

	_exclusiveAccessBeatenByOtherThread = false;

	while(_omrVMThread != extensions->gcExclusiveAccessThreadId) {
		if(NULL == extensions->gcExclusiveAccessThreadId) {
			/* there is a chance the thread can win the race to acquiring exclusive for GC */
			omrthread_monitor_enter(extensions->gcExclusiveAccessMutex);
			if(NULL == extensions->gcExclusiveAccessThreadId) {
				/* thread is the winner and will request the GC */
				extensions->gcExclusiveAccessThreadId = _omrVMThread;
			}
			omrthread_monitor_exit(extensions->gcExclusiveAccessMutex);
		}

		if(_omrVMThread != extensions->gcExclusiveAccessThreadId) {
			/* thread was not the winner for requesting a GC - allow the GC to proceed and wait for it to complete */
			Assert_MM_true(NULL != extensions->gcExclusiveAccessThreadId);

			uintptr_t accessMask;
			_envLanguageInterface->releaseCriticalHeapAccess(&accessMask);

			/* there is a chance the GC will already have executed at this point or other threads will re-win and re-execute.  loop until the
			 * thread sees that no more GCs are being requested.
			 */
			omrthread_monitor_enter(extensions->gcExclusiveAccessMutex);
			while(NULL != extensions->gcExclusiveAccessThreadId) {
				omrthread_monitor_wait(extensions->gcExclusiveAccessMutex);
			}
			omrthread_monitor_exit(extensions->gcExclusiveAccessMutex);

			_envLanguageInterface->reacquireCriticalHeapAccess(accessMask);

			/* May have been beaten to a GC, but perhaps not the one we wanted.  Check and if in fact the collection we intended has been
			 * completed, we will not acquire exclusive access.
			 */
			if(collector->getExclusiveAccessCount() != collectorAccessCount) {
				return false;
			}
		}
	}

	/* thread is the winner for requesting a GC (possibly through recursive calls).  proceed with acquiring exclusive access. */
	Assert_MM_true(_omrVMThread == extensions->gcExclusiveAccessThreadId);

	this->acquireExclusiveVMAccess();

	collector->incrementExclusiveAccessCount();

	GC_OMRVMInterface::flushCachesForGC(this);

	return true;
}
GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
    : m_currentWidth(0)
    , m_currentHeight(0)
    , m_hostWindow(hostWindow)
    , m_context(BlackBerry::Platform::Graphics::createWebGLContext())
    , m_extensions(adoptPtr(new Extensions3DOpenGL(this)))
    , m_attrs(attrs)
    , m_texture(0)
    , m_fbo(0)
    , m_depthStencilBuffer(0)
    , m_boundFBO(0)
    , m_activeTexture(GL_TEXTURE0)
    , m_boundTexture0(0)
    , m_multisampleFBO(0)
    , m_multisampleDepthStencilBuffer(0)
    , m_multisampleColorBuffer(0)
{
    if (!renderDirectlyToHostWindow) {
#if USE(ACCELERATED_COMPOSITING)
        m_compositingLayer = WebGLLayerWebKitThread::create();
#endif
        makeContextCurrent();

        Extensions3D* extensions = getExtensions();
        if (!extensions->supports("GL_IMG_multisampled_render_to_texture"))
            m_attrs.antialias = false;

        // Create a texture to render into.
        ::glGenTextures(1, &m_texture);
        ::glBindTexture(GL_TEXTURE_2D, m_texture);
        ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        ::glBindTexture(GL_TEXTURE_2D, 0);

        // Create an FBO.
        ::glGenFramebuffers(1, &m_fbo);
        ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
        if (m_attrs.stencil || m_attrs.depth)
            ::glGenRenderbuffers(1, &m_depthStencilBuffer);
        m_boundFBO = m_fbo;

#if USE(ACCELERATED_COMPOSITING)
        static_cast<WebGLLayerWebKitThread*>(m_compositingLayer.get())->setWebGLContext(this);
#endif
    }

    // FIXME: If GraphicsContext3D is created with renderDirectlyToHostWindow == true,
    // makeContextCurrent() will make the shared context current.
    makeContextCurrent();

    // FIXME: Do we need to enable GL_VERTEX_PROGRAM_POINT_SIZE with GL ES2? See PR #120141.

    ::glClearColor(0, 0, 0, 0);
}
Пример #13
0
  ExtensionList registeredExtensions(int attempts = 3) {
    ExtensionList extensions;
    for (int i = 0; i < attempts; ++i) {
      if (getExtensions(socket_path, extensions).ok()) {
        break;
      }
    }

    return extensions;
  }
Пример #14
0
void GraphicsContext3D::validateAttributes()
{
    validateDepthStencil("GL_OES_packed_depth_stencil");

    if (m_attrs.antialias) {
        Extensions3D* extensions = getExtensions();
        if (!extensions->supports("GL_IMG_multisampled_render_to_texture"))
            m_attrs.antialias = false;
    }
}
Пример #15
0
bool FritzingWindow::saveAs(const QString & filename, bool readOnly) {
	DebugDialog::debug(QString("current path: %1").arg(QDir::currentPath()));
	QString fileExt;
    QString path;
    QString untitledBase = untitledFileName();

	if(readOnly) {
		path = defaultSaveFolder() + "/" + QFileInfo(filename).fileName();
    }
	else if(filename.startsWith(untitledBase, Qt::CaseInsensitive)) {
		path = defaultSaveFolder() + "/" + filename;
	}
	else if(filename.isNull() || filename.isEmpty()) {
		path = defaultSaveFolder();
	}
	else {
		path = filename;
	}
	DebugDialog::debug(QString("current file: %1").arg(filename));
    QString newFilename = FolderUtils::getSaveFileName(
						this,
                        tr("Specify a file name"),
                        path,
                        getExtensionString(),
                        &fileExt
                      );

    if (newFilename.isEmpty()) return false; // Cancel pressed

	if (readOnly && (newFilename.compare(filename, Qt::CaseInsensitive) == 0)) {
        QMessageBox::warning(NULL, QObject::tr("Fritzing"),
                     QObject::tr("The file '%1' is read-only; please use a different filename.")
                     .arg(newFilename) );
		return false;

	}

    FileProgressDialog progress("Saving...", 0, this);

	QStringList extensions = getExtensions();
    bool hasExtension = false;
	foreach (QString extension, extensions) {
		if(alreadyHasExtension(newFilename, extension)) {
			hasExtension = true;
			break;
		}
	}

	if (!hasExtension) {
		newFilename += extensions[0];
	}

	return saveAsAux(newFilename);
}
Пример #16
0
	core::ProgramPtr ConversionJob::applyPostProcessing(core::NodeManager& manager, core::ProgramPtr& program) const {
		// strip of OMP annotation since those may contain references to local nodes
		core::visitDepthFirstOnce(program, [](const core::NodePtr& cur) { cur->remAnnotation(omp::BaseAnnotation::KEY); });

		// maybe a visitor wants to manipulate the IR translation unit
		for(auto extension : getExtensions()) {
			program = extension->IRVisit(program);
		}

		// return instance within global manager
		return core::transform::utils::migrate(program, manager);
	}
Пример #17
0
std::pair<char, bool> CSMWorld::ScriptContext::getMemberType (const std::string& name,
    const std::string& id) const
{
    /// \todo invalidate locals cache on change to scripts

    std::string id2 = Misc::StringUtils::lowerCase (id);

    int index = mData.getScripts().searchId (id2);
    bool reference = false;

    if (index==-1)
    {
        // ID is not a script ID. Search for a matching referenceable instead.
        index = mData.getReferenceables().searchId (id2);

        if (index!=-1)
        {
            // Referenceable found.
            int columnIndex = mData.getReferenceables().findColumnIndex (Columns::ColumnId_Script);

            id2 = Misc::StringUtils::lowerCase (mData.getReferenceables().
                getData (index, columnIndex).toString().toUtf8().constData());

            if (!id2.empty())
            {
                // Referenceable has a script -> use it.
                index = mData.getScripts().searchId (id2);
                reference = true;
            }
        }
    }

    if (index==-1)
        return std::make_pair (' ', false);

    std::map<std::string, Compiler::Locals>::iterator iter = mLocals.find (id2);

    if (iter==mLocals.end())
    {
        Compiler::Locals locals;

        Compiler::NullErrorHandler errorHandler;
        std::istringstream stream (mData.getScripts().getRecord (index).get().mScriptText);
        Compiler::QuickFileParser parser (errorHandler, *this, locals);
        Compiler::Scanner scanner (errorHandler, stream, getExtensions());
        scanner.scan (parser);

        iter = mLocals.insert (std::make_pair (id2, locals)).first;
    }

    return std::make_pair (iter->second.getType (Misc::StringUtils::lowerCase (name)), reference);
}
Пример #18
0
bool Display::getConfigAttrib(const Config *configuration, EGLint attribute, EGLint *value)
{
    switch (attribute)
    {
      case EGL_BUFFER_SIZE:               *value = configuration->bufferSize;             break;
      case EGL_ALPHA_SIZE:                *value = configuration->alphaSize;              break;
      case EGL_BLUE_SIZE:                 *value = configuration->blueSize;               break;
      case EGL_GREEN_SIZE:                *value = configuration->greenSize;              break;
      case EGL_RED_SIZE:                  *value = configuration->redSize;                break;
      case EGL_DEPTH_SIZE:                *value = configuration->depthSize;              break;
      case EGL_STENCIL_SIZE:              *value = configuration->stencilSize;            break;
      case EGL_CONFIG_CAVEAT:             *value = configuration->configCaveat;           break;
      case EGL_CONFIG_ID:                 *value = configuration->configID;               break;
      case EGL_LEVEL:                     *value = configuration->level;                  break;
      case EGL_NATIVE_RENDERABLE:         *value = configuration->nativeRenderable;       break;
      case EGL_NATIVE_VISUAL_ID:          *value = configuration->nativeVisualID;         break;
      case EGL_NATIVE_VISUAL_TYPE:        *value = configuration->nativeVisualType;       break;
      case EGL_SAMPLES:                   *value = configuration->samples;                break;
      case EGL_SAMPLE_BUFFERS:            *value = configuration->sampleBuffers;          break;
      case EGL_SURFACE_TYPE:              *value = configuration->surfaceType;            break;
      case EGL_TRANSPARENT_TYPE:          *value = configuration->transparentType;        break;
      case EGL_TRANSPARENT_BLUE_VALUE:    *value = configuration->transparentBlueValue;   break;
      case EGL_TRANSPARENT_GREEN_VALUE:   *value = configuration->transparentGreenValue;  break;
      case EGL_TRANSPARENT_RED_VALUE:     *value = configuration->transparentRedValue;    break;
      case EGL_BIND_TO_TEXTURE_RGB:       *value = configuration->bindToTextureRGB;       break;
      case EGL_BIND_TO_TEXTURE_RGBA:      *value = configuration->bindToTextureRGBA;      break;
      case EGL_MIN_SWAP_INTERVAL:         *value = configuration->minSwapInterval;        break;
      case EGL_MAX_SWAP_INTERVAL:         *value = configuration->maxSwapInterval;        break;
      case EGL_LUMINANCE_SIZE:            *value = configuration->luminanceSize;          break;
      case EGL_ALPHA_MASK_SIZE:           *value = configuration->alphaMaskSize;          break;
      case EGL_COLOR_BUFFER_TYPE:         *value = configuration->colorBufferType;        break;
      case EGL_RENDERABLE_TYPE:           *value = configuration->renderableType;         break;
      case EGL_MATCH_NATIVE_PIXMAP:       *value = false; UNIMPLEMENTED();                break;
      case EGL_CONFORMANT:                *value = configuration->conformant;             break;
      case EGL_MAX_PBUFFER_WIDTH:         *value = configuration->maxPBufferWidth;        break;
      case EGL_MAX_PBUFFER_HEIGHT:        *value = configuration->maxPBufferHeight;       break;
      case EGL_MAX_PBUFFER_PIXELS:        *value = configuration->maxPBufferPixels;       break;

      case EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE:
          if (!getExtensions().surfaceOrientation)
          {
              return false;
          }
          *value = configuration->optimalOrientation;
          break;

      default:
        return false;
    }

    return true;
}
Пример #19
0
float Utilities::getMaxAnisotropy() {
    auto extensions = getExtensions();
    if (extensions.cend() != extensions.find(anisotropyExtension)) {
        float maxAnisotropyLevel;
        glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropyLevel);
        if (isError()) {
            throw RuntimeErrorException(__FILE__, __LINE__, "unable to acquire renderer back-end information");
        }
        return maxAnisotropyLevel;
    } else {
        return getMinAnisotropy();
    }
}
Пример #20
0
void
MM_EnvironmentStandard::flushNonAllocationCaches()
{
	MM_EnvironmentBase::flushNonAllocationCaches();

#if defined(OMR_GC_MODRON_SCAVENGER)
	if (getExtensions()->scavengerEnabled) {
		if (MUTATOR_THREAD == getThreadType()) {
			flushRememberedSet();
		}
	}
#endif /* OMR_GC_MODRON_SCAVENGER */
}
Пример #21
0
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nCreate
  (JNIEnv *env, jobject self, jobject peer_info_handle,
  jint width, jint height, jobject pixel_format,
  jobject pixelFormatCaps, jobject pBufferAttribs)
{
	int origin_x = 0; int origin_y = 0;
	HWND dummy_hwnd;
	HDC dummy_hdc;
	HPBUFFERARB Pbuffer;
	HDC Pbuffer_dc;
	WGLExtensions extensions;
	const int *pBufferAttribs_ptr;
	WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
	int pixel_format_id;

	if ( pBufferAttribs != NULL ) {
		pBufferAttribs_ptr = (const int *)(*env)->GetDirectBufferAddress(env, pBufferAttribs);
	} else {
		pBufferAttribs_ptr = NULL;
	}
	if (!getExtensions(env, &extensions, pixel_format, pixelFormatCaps))
		return;
	dummy_hwnd = createDummyWindow(origin_x, origin_y);
	if (dummy_hwnd == NULL) {
		throwException(env, "Could not create dummy window");
		return;
	}
	dummy_hdc = GetDC(dummy_hwnd);
	pixel_format_id = findPixelFormatOnDC(env, dummy_hdc, origin_x, origin_y, pixel_format, pixelFormatCaps, false, false, true, false);
	if (pixel_format_id == -1) {
		closeWindow(&dummy_hwnd, &dummy_hdc);
		return;
	}
	Pbuffer = extensions.wglCreatePbufferARB(dummy_hdc, pixel_format_id, width, height, pBufferAttribs_ptr);
	closeWindow(&dummy_hwnd, &dummy_hdc);
	if (Pbuffer == NULL) {
		throwException(env, "Could not create Pbuffer");
		return;
	}
	Pbuffer_dc = extensions.wglGetPbufferDCARB(Pbuffer);
	if (Pbuffer_dc == NULL) {
		extensions.wglDestroyPbufferARB(Pbuffer);
		throwException(env, "Could not get Pbuffer DC");
		return;
	}
	peer_info->u.pbuffer.extensions = extensions;
	peer_info->u.pbuffer.pbuffer = Pbuffer;
	peer_info->drawable_hdc = Pbuffer_dc;
}
Пример #22
0
void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value)
{
    // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS
    // because desktop GL's corresponding queries return the number of components
    // whereas GLES2 return the number of vectors (each vector has 4 components).
    // Therefore, the value returned by desktop GL needs to be divided by 4.
    makeContextCurrent();
    switch (pname) {
#if !PLATFORM(IOS)
    case MAX_FRAGMENT_UNIFORM_VECTORS:
        ::glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value);
        *value /= 4;
        break;
    case MAX_VERTEX_UNIFORM_VECTORS:
        ::glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value);
        *value /= 4;
        break;
    case MAX_VARYING_VECTORS:
        ::glGetIntegerv(GL_MAX_VARYING_FLOATS, value);
        *value /= 4;
        break;
#endif
    case MAX_TEXTURE_SIZE:
        ::glGetIntegerv(MAX_TEXTURE_SIZE, value);
        if (getExtensions()->requiresRestrictedMaximumTextureSize())
            *value = std::min(4096, *value);
        break;
    case MAX_CUBE_MAP_TEXTURE_SIZE:
        ::glGetIntegerv(MAX_CUBE_MAP_TEXTURE_SIZE, value);
        if (getExtensions()->requiresRestrictedMaximumTextureSize())
            *value = std::min(1024, *value);
        break;
    default:
        ::glGetIntegerv(pname, value);
    }
}
Пример #23
0
void
MM_EnvironmentBase::allocationFailureEndReportIfRequired(MM_AllocateDescription *allocDescription)
{
	if (_allocationFailureReported) {
		MM_GCExtensionsBase *extensions = getExtensions();
		OMRPORT_ACCESS_FROM_OMRPORT(_portLibrary);

		TRIGGER_J9HOOK_MM_PRIVATE_FAILED_ALLOCATION_COMPLETED(
			extensions->privateHookInterface,
			getOmrVMThread(),
			omrtime_hires_clock(),
			J9HOOK_MM_PRIVATE_FAILED_ALLOCATION_COMPLETED,
			allocDescription->getAllocationSucceeded() ? TRUE : FALSE,
			allocDescription->getBytesRequested());

		Trc_MM_AllocationFailureEnd(getLanguageVMThread(),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_OLD),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_OLD),
			(extensions->largeObjectArea ? extensions->heap->getApproximateActiveFreeLOAMemorySize(MEMORY_TYPE_OLD) : 0),
			(extensions->largeObjectArea ? extensions->heap->getActiveLOAMemorySize(MEMORY_TYPE_OLD) : 0));

		Trc_OMRMM_AllocationFailureEnd(getOmrVMThread(),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_OLD),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_OLD),
			(extensions->largeObjectArea ? extensions->heap->getApproximateActiveFreeLOAMemorySize(MEMORY_TYPE_OLD) : 0),
			(extensions->largeObjectArea ? extensions->heap->getActiveLOAMemorySize(MEMORY_TYPE_OLD) : 0));

		if (J9_EVENT_IS_HOOKED(extensions->privateHookInterface, J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_END)) {
			MM_CommonGCEndData commonData;
			extensions->heap->initializeCommonGCEndData(this, &commonData);

			ALWAYS_TRIGGER_J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_END(
				extensions->privateHookInterface,
				getOmrVMThread(),
				omrtime_hires_clock(),
				J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_END,
				getExclusiveAccessTime(),
				&commonData,
				allocDescription);
		}

		_allocationFailureReported = false;
	}
}
Пример #24
0
void Utilities::setSampler(TextureType target, const TextureSampler& sampler) {
    clearError();
    GLenum target_gl;
    switch (target) {
        case TextureType::_2D:
            target_gl = GL_TEXTURE_2D;
            break;
        case TextureType::_1D:
            target_gl = GL_TEXTURE_1D;
            break;
        default:
            throw UnhandledSwitchCaseException(__FILE__, __LINE__);
    }
    if (isError()) {
        return;
    }

    GLint addressModeS_gl = toOpenGL(sampler.getAddressModeS()),
          addressModeT_gl = toOpenGL(sampler.getAddressModeT());
    glTexParameteri(target_gl, GL_TEXTURE_WRAP_S, addressModeS_gl);
    glTexParameteri(target_gl, GL_TEXTURE_WRAP_T, addressModeT_gl);
    if (isError()) {
        return;
    }

    GLint minFilter_gl, magFilter_gl;
    toOpenGL(sampler.getMinFilter(), sampler.getMagFilter(), sampler.getMipMapFilter(),
             minFilter_gl, magFilter_gl);
    glTexParameteri(target_gl, GL_TEXTURE_MIN_FILTER, minFilter_gl);
    glTexParameteri(target_gl, GL_TEXTURE_MAG_FILTER, magFilter_gl);
    if (isError()) {
        return;
    }

    if (TextureType::_2D == target) {
        auto extensions = getExtensions();
        if (extensions.cend() != extensions.find(anisotropyExtension)) {
            float anisotropyLevel = Ego::Math::constrain(sampler.getAnisotropyLevel(), getMinAnisotropy(), getMaxAnisotropy());
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropyLevel);
            if (isError()) {
                return;
            }
        }
    }
}
Пример #25
0
void
MM_EnvironmentBase::allocationFailureStartReportIfRequired(MM_AllocateDescription *allocDescription, uintptr_t flags)
{
	if (!_allocationFailureReported) {
		MM_GCExtensionsBase *extensions = getExtensions();
		OMRPORT_ACCESS_FROM_OMRPORT(_portLibrary);

		Trc_MM_AllocationFailureStart(getLanguageVMThread(),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_OLD),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_OLD),
			(extensions->largeObjectArea ? extensions->heap->getApproximateActiveFreeLOAMemorySize(MEMORY_TYPE_OLD) : 0),
			(extensions->largeObjectArea ? extensions->heap->getActiveLOAMemorySize(MEMORY_TYPE_OLD) : 0),
			allocDescription->getBytesRequested());

		Trc_OMRMM_AllocationFailureStart(getOmrVMThread(),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_NEW),
			extensions->heap->getApproximateActiveFreeMemorySize(MEMORY_TYPE_OLD),
			extensions->heap->getActiveMemorySize(MEMORY_TYPE_OLD),
			(extensions->largeObjectArea ? extensions->heap->getApproximateActiveFreeLOAMemorySize(MEMORY_TYPE_OLD) : 0),
			(extensions->largeObjectArea ? extensions->heap->getActiveLOAMemorySize(MEMORY_TYPE_OLD) : 0),
			allocDescription->getBytesRequested());

		if (J9_EVENT_IS_HOOKED(extensions->privateHookInterface, J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_START)) {
			MM_CommonGCStartData commonData;
			extensions->heap->initializeCommonGCStartData(this, &commonData);

			ALWAYS_TRIGGER_J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_START(
				extensions->privateHookInterface,
				getOmrVMThread(),
				omrtime_hires_clock(),
				J9HOOK_MM_PRIVATE_ALLOCATION_FAILURE_START,
				allocDescription->getBytesRequested(),
				&commonData,
				flags,
				allocDescription->getTenuredFlag());
		}

		_allocationFailureReported = true;
	}
}
Пример #26
0
		void BaseRouter::requestHandshake(const dtn::data::EID &destination, NodeHandshake &request)
		{
			ibrcommon::RWLock l(getExtensionMutex(), ibrcommon::RWMutex::LOCK_READONLY);

			// walk through all extensions to process the contents of the response
			const BaseRouter::extension_list& extensions = getExtensions();

			// process this handshake using the NodeHandshakeExtension
			_nh_extension.requestHandshake(destination, request);

			// process this handshake using the retransmission extension
			_retransmission_extension.requestHandshake(destination, request);

			for (BaseRouter::extension_list::const_iterator iter = extensions.begin(); iter != extensions.end(); ++iter)
			{
				RoutingExtension &extension = (**iter);
				extension.requestHandshake(destination, request);
			}
		}
Пример #27
0
	std::ostream& ConversionJob::printTo(std::ostream& out) const {
		out << "~~~~~~CONVERSION SETUP~~~~~~\n";
		out << "input files: \n" << files << std::endl;
		out << "flags: \n"
		    << "PrintDiag " << hasOption(ConversionSetup::PrintDiag) << "\n"
		    << "WinCrossCompile " << hasOption(ConversionSetup::WinCrossCompile) << "\n"
		    << "TAG_MPI " << hasOption(ConversionSetup::TAG_MPI) << "\n"
		    << "ProgressBar " << hasOption(ConversionSetup::ProgressBar) << "\n"
		    << "NoWarnings " << hasOption(ConversionSetup::NoWarnings) << "\n"
		    << "NoDefaultExtensions " << hasOption(ConversionSetup::NoDefaultExtensions) << "\n" << std::endl;
		out << "interceptions: \n" << getInterceptedNameSpacePatterns() << std::endl;
		out << "crosscompilation dir: \n" << getCrossCompilationSystemHeadersDir() << std::endl;
		out << "include dirs: \n" << getIncludeDirectories() << std::endl;
		out << "definitions: \n" << getDefinitions() << std::endl;
		out << "libraries: \n" << libs << std::endl;
		out << "standard: \n" << getStandard() << std::endl;
		out << "number of registered extensions: \n" << getExtensions().size() << std::endl;
		out << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
		return out;
	}
Пример #28
0
void GLWidget::initializeGL()
{
    if(!getExtensions())
    {
        fprintf(stderr,"Error: %s.\n","Open OpenGL Extensions Error!!!");
        exit(-1);
    }
    qglClearColor(Qt::gray);
    glClearDepth(1.0);
    glShadeModel(GL_FLAT);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    setLight();
    setFog();



    t = startTimer(50);
}
Пример #29
0
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetPbufferCapabilities
  (JNIEnv *env, jobject self, jobject pixel_format)
{
	int caps = 0;
	WGLExtensions extensions;
	if (!getExtensions(env, &extensions, pixel_format, NULL))
		return 0;
	if (isPbufferSupported(&extensions))
		caps |= org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED;

	if (extensions.WGL_ARB_render_texture)
		caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED;

	if (extensions.WGL_NV_render_texture_rectangle)
		caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED;

	if (extensions.WGL_NV_render_depth_texture)
		caps |= org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED;

	return caps;
}
Пример #30
0
    Codec* Codec::getCodec(const String& extension)
    {
        String lwrcase = extension;
        StringUtil::toLowerCase(lwrcase);
        CodecList::const_iterator i = msMapCodecs.find(lwrcase);
        if (i == msMapCodecs.end())
        {
            String formats_str;
            if(msMapCodecs.empty())
                formats_str = "There are no formats supported (no codecs registered).";
            else
                formats_str = "Supported formats are: " + StringConverter::toString(getExtensions()) + ".";

            OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 
                "Can not find codec for '" + extension + "' image format.\n" + 
                formats_str,
                "Codec::getCodec");
        }

        return i->second;

    }