OpenGLTestDarwin.cpp revision ae2a9b93d772d52146af2c010701ead81e4fb348
/* $Id$ */
/** @file
* VBox host opengl support test
*/
/*
* Copyright (C) 2009-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <VBox/VBoxOGLTest.h>
#include <IOKit/IOKitLib.h>
#include <ApplicationServices/ApplicationServices.h>
#ifdef VBOX_WITH_COCOA_QT
#endif
/**
* @callback_method_impl{FNRTONCE,
* For determining the cached VBoxOglIsOfflineRenderingAppropriate result.}
*/
{
bool *pfAppropriate = (bool *)pvUser;
/* It is assumed that it is makes sense to enable offline rendering
only in case if host has more than one GPU installed. This routine
counts all the PCI devices in IORegistry which have IOName property
set to "display". If the number of such devices is greater than one,
it sets pfAppropriate to TRUE, otherwise to FALSE. */
(const void **)apKeyStrings,
(const void **)apValueStrings,
if (pMatchingDictionary)
{
/* The reference to pMatchingDictionary is consumed by the function below => no IORelease(pMatchingDictionary)! */
kern_return_t krc = IOServiceGetMatchingServices(kIOMasterPortDefault, pMatchingDictionary, &matchingServices);
if (krc == kIOReturnSuccess)
{
int cMatchingServices = 0;
{
}
}
}
LogRel(("OpenGL: Offline rendering support is %s (pid=%d)\n", *pfAppropriate ? "ON" : "OFF", (int)getpid()));
return VINF_SUCCESS;
}
bool RTCALL VBoxOglIsOfflineRenderingAppropriate(void)
{
/* In order to do not slowdown 3D engine which can ask about offline rendering several times,
let's cache the result and assume that renderers amount value is constant. Use the IPRT
execute once construct to make sure there aren't any threading issues. */
static bool s_fCached = false;
return s_fCached;
}
bool RTCALL VBoxOglIs3DAccelerationSupported(void)
{
if (RTEnvExist("VBOX_CROGL_FORCE_SUPPORTED"))
{
LogRel(("VBOX_CROGL_FORCE_SUPPORTED is specified, skipping 3D test, and treating as supported\n"));
return true;
}
{
VBoxOglIsOfflineRenderingAppropriate() ? kCGLPFAAllowOfflineRenderers : (CGLPixelFormatAttribute)NULL,
};
if (rcCgl != kCGLNoError)
{
return false;
}
if (pPixelFormat)
{
CGLContextObj pCglContext = 0;
if (rcCgl != kCGLNoError)
{
return false;
}
if (pCglContext)
{
#ifdef VBOX_WITH_COCOA_QT
/*
* In the Cocoa port we depend on the GL_EXT_framebuffer_object &
* the GL_EXT_texture_rectangle extension. If they are not
* available, disable 3D support.
*/
if (isSupported)
{
if (!isSupported)
LogRel(("OpenGL Info: 3D test found that GL_EXT_texture_rectangle extension not supported.\n"));
}
else
LogRel(("OpenGL Info: 3D test found that GL_EXT_framebuffer_object extension not supported.\n"));
#endif /* VBOX_WITH_COCOA_QT */
return isSupported == GL_TRUE;
}
LogRel(("OpenGL Info: 3D test unable to create context (internal error).\n"));
}
else
LogRel(("OpenGL Info: 3D test unable to choose pixel format (internal error).\n"));
return false;
}