mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-19 16:01:57 +09:00
[Chore] (MG_Backend, MG_Backend/DirectGLES, MG_Backend/DirectVulkan, MG_Backend/MGPipe, MG_Backend/Record, MG_Benchmark/Buffer, MG_Benchmark/Container, MG_Benchmark/Driver, MG_Benchmark/Program, MG_Benchmark/ShaderCache, MG_Benchmark/Transpile, MG_Gbm, MG_Impl, MG_Impl/CGLImpl, MG_Impl/DyldInterpose, MG_Impl/EGLImpl, MG_Impl/GLImpl, MG_Impl/GLXImpl, MG_Impl/NSOpenGLImpl, MG_Impl/Pipe, MG_Impl/WGLImpl, MG_IntegrationTest, MG_IntegrationTest/Harness, MG_IntegrationTest/Scenarios, MG_Pipe, MG_Remote, MG_Remote/Client, MG_Remote/Protocol, MG_Remote/Server, MG_Remote/Transport, MG_Remote/Wire, MG_State/EGLState, MG_State/GLState, MG_Test, MG_Test/Backend, MG_Test/BackendLoader, MG_Test/Buffer, MG_Test/EGLState, MG_Test/Framebuffer, MG_Test/Gbm, MG_Test/Pipe, MG_Test/Pipeline, MG_Test/Program, MG_Test/Query, MG_Test/SelfTest, MG_Test/ShaderTranspiler, MG_Test/State, MG_Test/Swapchain, MG_Test/Texture, MG_Test/Util, MG_Test/VertexArray, MG_Test/Wire, MG_Util/Async, MG_Util/BackendLoaders, MG_Util/Converters, MG_Util/Damage, MG_Util/Debug, MG_Util/Math, MG_Util/Metrics, MG_Util/SelfTest, MG_Util/ShaderTranspiler, MG_Util/Texture, MG_Util/X11, MobileGL, scripts/data, tools/cts, tools/device_bench, tools/spikes, tools/trace_replay, tools/wgl-smoke): clang-format every C and C++ source
- Layout only: token streams match up to split literals, continuations and using order - The size totals fall, so the structure baseline is lowered
This commit is contained in:
@@ -82,36 +82,31 @@ using std::vector;
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
||||
#endif
|
||||
|
||||
namespace tcu
|
||||
{
|
||||
namespace mobilegl
|
||||
{
|
||||
namespace tcu {
|
||||
namespace mobilegl {
|
||||
|
||||
static string getLibraryName(void)
|
||||
{
|
||||
const char *env = std::getenv("MOBILEGL_CTS_LIB");
|
||||
return (env && env[0]) ? string(env) : string("libMobileGL.so");
|
||||
}
|
||||
static string getLibraryName(void) {
|
||||
const char* env = std::getenv("MOBILEGL_CTS_LIB");
|
||||
return (env && env[0]) ? string(env) : string("libMobileGL.so");
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
//! Window surfaces default on: they are the only kind DirectVulkan can use
|
||||
//! on Android (its pbuffer path needs VK_EXT_headless_surface).
|
||||
static bool useWindowSurface(void)
|
||||
{
|
||||
const char *env = std::getenv("MOBILEGL_CTS_SURFACE");
|
||||
return !(env && string(env) == "pbuffer");
|
||||
}
|
||||
//! Window surfaces default on: they are the only kind DirectVulkan can use
|
||||
//! on Android (its pbuffer path needs VK_EXT_headless_surface).
|
||||
static bool useWindowSurface(void) {
|
||||
const char* env = std::getenv("MOBILEGL_CTS_SURFACE");
|
||||
return !(env && string(env) == "pbuffer");
|
||||
}
|
||||
#else
|
||||
//! Desktop: pbuffer only. VK_EXT_headless_surface is available there and no
|
||||
//! Activity-free native window abstraction exists.
|
||||
static bool useWindowSurface(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//! Desktop: pbuffer only. VK_EXT_headless_surface is available there and no
|
||||
//! Activity-free native window abstraction exists.
|
||||
static bool useWindowSurface(void) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
/*--------------------------------------------------------------------*//*!
|
||||
/*--------------------------------------------------------------------*//*!
|
||||
* \brief A real ANativeWindow with no Activity behind it.
|
||||
*
|
||||
* AImageReader's window is an ordinary BufferQueue producer, so both
|
||||
@@ -119,381 +114,305 @@ static bool useWindowSurface(void)
|
||||
* listener must drain the queue: without it the producer blocks once maxImages
|
||||
* buffers are in flight and the next swap deadlocks.
|
||||
*//*--------------------------------------------------------------------*/
|
||||
class ImageReaderWindow
|
||||
{
|
||||
public:
|
||||
ImageReaderWindow(int width, int height) : m_reader(nullptr), m_window(nullptr)
|
||||
{
|
||||
const media_status_t status =
|
||||
AImageReader_newWithUsage(width, height, AIMAGE_FORMAT_RGBA_8888,
|
||||
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
|
||||
AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT,
|
||||
kMaxImages, &m_reader);
|
||||
if (status != AMEDIA_OK || m_reader == nullptr)
|
||||
throw tcu::ResourceError("AImageReader_newWithUsage() failed");
|
||||
class ImageReaderWindow {
|
||||
public:
|
||||
ImageReaderWindow(int width, int height) : m_reader(nullptr), m_window(nullptr) {
|
||||
const media_status_t status = AImageReader_newWithUsage(width, height, AIMAGE_FORMAT_RGBA_8888,
|
||||
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
|
||||
AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT,
|
||||
kMaxImages, &m_reader);
|
||||
if (status != AMEDIA_OK || m_reader == nullptr)
|
||||
throw tcu::ResourceError("AImageReader_newWithUsage() failed");
|
||||
|
||||
AImageReader_ImageListener listener = {this, onImageAvailable};
|
||||
AImageReader_setImageListener(m_reader, &listener);
|
||||
AImageReader_ImageListener listener = {this, onImageAvailable};
|
||||
AImageReader_setImageListener(m_reader, &listener);
|
||||
|
||||
if (AImageReader_getWindow(m_reader, &m_window) != AMEDIA_OK || m_window == nullptr)
|
||||
{
|
||||
AImageReader_delete(m_reader);
|
||||
m_reader = nullptr;
|
||||
throw tcu::ResourceError("AImageReader_getWindow() failed");
|
||||
}
|
||||
ANativeWindow_acquire(m_window);
|
||||
}
|
||||
if (AImageReader_getWindow(m_reader, &m_window) != AMEDIA_OK || m_window == nullptr) {
|
||||
AImageReader_delete(m_reader);
|
||||
m_reader = nullptr;
|
||||
throw tcu::ResourceError("AImageReader_getWindow() failed");
|
||||
}
|
||||
ANativeWindow_acquire(m_window);
|
||||
}
|
||||
|
||||
~ImageReaderWindow(void)
|
||||
{
|
||||
if (m_window != nullptr)
|
||||
ANativeWindow_release(m_window);
|
||||
if (m_reader != nullptr)
|
||||
{
|
||||
AImageReader_setImageListener(m_reader, nullptr);
|
||||
AImageReader_delete(m_reader);
|
||||
}
|
||||
}
|
||||
~ImageReaderWindow(void) {
|
||||
if (m_window != nullptr) ANativeWindow_release(m_window);
|
||||
if (m_reader != nullptr) {
|
||||
AImageReader_setImageListener(m_reader, nullptr);
|
||||
AImageReader_delete(m_reader);
|
||||
}
|
||||
}
|
||||
|
||||
ANativeWindow *getWindow(void) const
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
ANativeWindow* getWindow(void) const { return m_window; }
|
||||
|
||||
private:
|
||||
static const int kMaxImages = 4;
|
||||
private:
|
||||
static const int kMaxImages = 4;
|
||||
|
||||
static void onImageAvailable(void *, AImageReader *reader)
|
||||
{
|
||||
AImage *image = nullptr;
|
||||
if (AImageReader_acquireNextImage(reader, &image) == AMEDIA_OK && image != nullptr)
|
||||
AImage_delete(image);
|
||||
}
|
||||
static void onImageAvailable(void*, AImageReader* reader) {
|
||||
AImage* image = nullptr;
|
||||
if (AImageReader_acquireNextImage(reader, &image) == AMEDIA_OK && image != nullptr)
|
||||
AImage_delete(image);
|
||||
}
|
||||
|
||||
ImageReaderWindow(const ImageReaderWindow &);
|
||||
ImageReaderWindow &operator=(const ImageReaderWindow &);
|
||||
ImageReaderWindow(const ImageReaderWindow&);
|
||||
ImageReaderWindow& operator=(const ImageReaderWindow&);
|
||||
|
||||
AImageReader *m_reader;
|
||||
ANativeWindow *m_window;
|
||||
};
|
||||
AImageReader* m_reader;
|
||||
ANativeWindow* m_window;
|
||||
};
|
||||
#else
|
||||
//! Never instantiated on desktop; keeps EglRenderContext's member deletable.
|
||||
class ImageReaderWindow
|
||||
{
|
||||
};
|
||||
//! Never instantiated on desktop; keeps EglRenderContext's member deletable.
|
||||
class ImageReaderWindow {};
|
||||
#endif
|
||||
|
||||
class GetProcFuncLoader : public glw::FunctionLoader
|
||||
{
|
||||
public:
|
||||
GetProcFuncLoader(const eglw::Library &egl) : m_egl(egl)
|
||||
{
|
||||
}
|
||||
class GetProcFuncLoader : public glw::FunctionLoader {
|
||||
public:
|
||||
GetProcFuncLoader(const eglw::Library& egl) : m_egl(egl) {}
|
||||
|
||||
glw::GenericFuncType get(const char *name) const
|
||||
{
|
||||
return (glw::GenericFuncType)m_egl.getProcAddress(name);
|
||||
}
|
||||
glw::GenericFuncType get(const char* name) const {
|
||||
return (glw::GenericFuncType)m_egl.getProcAddress(name);
|
||||
}
|
||||
|
||||
protected:
|
||||
const eglw::Library &m_egl;
|
||||
};
|
||||
protected:
|
||||
const eglw::Library& m_egl;
|
||||
};
|
||||
|
||||
class EglRenderContext : public glu::RenderContext
|
||||
{
|
||||
public:
|
||||
EglRenderContext(const glu::RenderConfig &config, const tcu::CommandLine &cmdLine,
|
||||
const glu::RenderContext *sharedContext);
|
||||
~EglRenderContext(void);
|
||||
class EglRenderContext : public glu::RenderContext {
|
||||
public:
|
||||
EglRenderContext(const glu::RenderConfig& config, const tcu::CommandLine& cmdLine,
|
||||
const glu::RenderContext* sharedContext);
|
||||
~EglRenderContext(void);
|
||||
|
||||
glu::ContextType getType(void) const
|
||||
{
|
||||
return m_contextType;
|
||||
}
|
||||
eglw::EGLContext getEglContext(void) const
|
||||
{
|
||||
return m_eglContext;
|
||||
}
|
||||
const glw::Functions &getFunctions(void) const
|
||||
{
|
||||
return m_glFunctions;
|
||||
}
|
||||
const tcu::RenderTarget &getRenderTarget(void) const
|
||||
{
|
||||
return m_renderTarget;
|
||||
}
|
||||
void postIterate(void);
|
||||
void makeCurrent(void);
|
||||
glu::ContextType getType(void) const { return m_contextType; }
|
||||
eglw::EGLContext getEglContext(void) const { return m_eglContext; }
|
||||
const glw::Functions& getFunctions(void) const { return m_glFunctions; }
|
||||
const tcu::RenderTarget& getRenderTarget(void) const { return m_renderTarget; }
|
||||
void postIterate(void);
|
||||
void makeCurrent(void);
|
||||
|
||||
glw::GenericFuncType getProcAddress(const char *name) const
|
||||
{
|
||||
return (glw::GenericFuncType)m_egl.getProcAddress(name);
|
||||
}
|
||||
glw::GenericFuncType getProcAddress(const char* name) const {
|
||||
return (glw::GenericFuncType)m_egl.getProcAddress(name);
|
||||
}
|
||||
|
||||
private:
|
||||
const eglw::DefaultLibrary m_egl;
|
||||
const glu::ContextType m_contextType;
|
||||
eglw::EGLDisplay m_eglDisplay;
|
||||
eglw::EGLContext m_eglContext;
|
||||
eglw::EGLSurface m_eglSurface;
|
||||
ImageReaderWindow *m_window;
|
||||
glw::Functions m_glFunctions;
|
||||
tcu::RenderTarget m_renderTarget;
|
||||
eglw::EGLContext m_sharedEglContext;
|
||||
};
|
||||
private:
|
||||
const eglw::DefaultLibrary m_egl;
|
||||
const glu::ContextType m_contextType;
|
||||
eglw::EGLDisplay m_eglDisplay;
|
||||
eglw::EGLContext m_eglContext;
|
||||
eglw::EGLSurface m_eglSurface;
|
||||
ImageReaderWindow* m_window;
|
||||
glw::Functions m_glFunctions;
|
||||
tcu::RenderTarget m_renderTarget;
|
||||
eglw::EGLContext m_sharedEglContext;
|
||||
};
|
||||
|
||||
class ContextFactory : public glu::ContextFactory
|
||||
{
|
||||
public:
|
||||
ContextFactory(void) : glu::ContextFactory("default", "MobileGL EGL context")
|
||||
{
|
||||
}
|
||||
class ContextFactory : public glu::ContextFactory {
|
||||
public:
|
||||
ContextFactory(void) : glu::ContextFactory("default", "MobileGL EGL context") {}
|
||||
|
||||
glu::RenderContext *createContext(const glu::RenderConfig &config, const tcu::CommandLine &cmdLine,
|
||||
const glu::RenderContext *sharedContext) const
|
||||
{
|
||||
return new EglRenderContext(config, cmdLine, sharedContext);
|
||||
}
|
||||
};
|
||||
glu::RenderContext* createContext(const glu::RenderConfig& config, const tcu::CommandLine& cmdLine,
|
||||
const glu::RenderContext* sharedContext) const {
|
||||
return new EglRenderContext(config, cmdLine, sharedContext);
|
||||
}
|
||||
};
|
||||
|
||||
class Platform : public tcu::Platform, public glu::Platform
|
||||
{
|
||||
public:
|
||||
Platform(void)
|
||||
{
|
||||
m_contextFactoryRegistry.registerFactory(new ContextFactory());
|
||||
}
|
||||
class Platform : public tcu::Platform, public glu::Platform {
|
||||
public:
|
||||
Platform(void) { m_contextFactoryRegistry.registerFactory(new ContextFactory()); }
|
||||
|
||||
const glu::Platform &getGLPlatform(void) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
const glu::Platform& getGLPlatform(void) const { return *this; }
|
||||
};
|
||||
|
||||
EglRenderContext::EglRenderContext(const glu::RenderConfig &config, const tcu::CommandLine &cmdLine,
|
||||
const glu::RenderContext *sharedContext)
|
||||
: m_egl(getLibraryName().c_str())
|
||||
, m_contextType(config.type)
|
||||
, m_eglDisplay(EGL_NO_DISPLAY)
|
||||
, m_eglContext(EGL_NO_CONTEXT)
|
||||
, m_eglSurface(EGL_NO_SURFACE)
|
||||
, m_window(nullptr)
|
||||
, m_renderTarget(config.width, config.height,
|
||||
tcu::PixelFormat(config.redBits, config.greenBits, config.blueBits, config.alphaBits),
|
||||
config.depthBits, config.stencilBits, config.numSamples)
|
||||
, m_sharedEglContext(EGL_NO_CONTEXT)
|
||||
{
|
||||
DE_UNREF(cmdLine);
|
||||
EglRenderContext::EglRenderContext(const glu::RenderConfig& config, const tcu::CommandLine& cmdLine,
|
||||
const glu::RenderContext* sharedContext)
|
||||
: m_egl(getLibraryName().c_str()), m_contextType(config.type), m_eglDisplay(EGL_NO_DISPLAY),
|
||||
m_eglContext(EGL_NO_CONTEXT), m_eglSurface(EGL_NO_SURFACE), m_window(nullptr),
|
||||
m_renderTarget(config.width, config.height,
|
||||
tcu::PixelFormat(config.redBits, config.greenBits, config.blueBits, config.alphaBits),
|
||||
config.depthBits, config.stencilBits, config.numSamples),
|
||||
m_sharedEglContext(EGL_NO_CONTEXT) {
|
||||
DE_UNREF(cmdLine);
|
||||
|
||||
const glu::ContextType &contextType = config.type;
|
||||
const bool isES = glu::isContextTypeES(contextType);
|
||||
eglw::EGLint eglMajorVersion = 0;
|
||||
eglw::EGLint eglMinorVersion = 0;
|
||||
const glu::ContextType& contextType = config.type;
|
||||
const bool isES = glu::isContextTypeES(contextType);
|
||||
eglw::EGLint eglMajorVersion = 0;
|
||||
eglw::EGLint eglMinorVersion = 0;
|
||||
|
||||
m_eglDisplay = m_egl.getDisplay(EGL_DEFAULT_DISPLAY);
|
||||
EGLU_CHECK_MSG(m_egl, "eglGetDisplay()");
|
||||
if (m_eglDisplay == EGL_NO_DISPLAY)
|
||||
throw tcu::ResourceError("eglGetDisplay() failed");
|
||||
m_eglDisplay = m_egl.getDisplay(EGL_DEFAULT_DISPLAY);
|
||||
EGLU_CHECK_MSG(m_egl, "eglGetDisplay()");
|
||||
if (m_eglDisplay == EGL_NO_DISPLAY) throw tcu::ResourceError("eglGetDisplay() failed");
|
||||
|
||||
EGLU_CHECK_CALL(m_egl, initialize(m_eglDisplay, &eglMajorVersion, &eglMinorVersion));
|
||||
EGLU_CHECK_CALL(m_egl, initialize(m_eglDisplay, &eglMajorVersion, &eglMinorVersion));
|
||||
|
||||
// MobileGL cannot make a context current without a surface, so
|
||||
// SURFACETYPE_DONT_CARE (which is what --deqp-surface-type=fbo requests)
|
||||
// still gets a real one.
|
||||
bool wantWindow = false;
|
||||
switch (config.surfaceType)
|
||||
{
|
||||
case glu::RenderConfig::SURFACETYPE_WINDOW:
|
||||
wantWindow = true;
|
||||
break;
|
||||
case glu::RenderConfig::SURFACETYPE_OFFSCREEN_NATIVE:
|
||||
case glu::RenderConfig::SURFACETYPE_OFFSCREEN_GENERIC:
|
||||
wantWindow = false;
|
||||
break;
|
||||
case glu::RenderConfig::SURFACETYPE_DONT_CARE:
|
||||
wantWindow = useWindowSurface();
|
||||
break;
|
||||
default:
|
||||
TCU_CHECK_INTERNAL(false);
|
||||
}
|
||||
// MobileGL cannot make a context current without a surface, so
|
||||
// SURFACETYPE_DONT_CARE (which is what --deqp-surface-type=fbo requests)
|
||||
// still gets a real one.
|
||||
bool wantWindow = false;
|
||||
switch (config.surfaceType) {
|
||||
case glu::RenderConfig::SURFACETYPE_WINDOW:
|
||||
wantWindow = true;
|
||||
break;
|
||||
case glu::RenderConfig::SURFACETYPE_OFFSCREEN_NATIVE:
|
||||
case glu::RenderConfig::SURFACETYPE_OFFSCREEN_GENERIC:
|
||||
wantWindow = false;
|
||||
break;
|
||||
case glu::RenderConfig::SURFACETYPE_DONT_CARE:
|
||||
wantWindow = useWindowSurface();
|
||||
break;
|
||||
default:
|
||||
TCU_CHECK_INTERNAL(false);
|
||||
}
|
||||
|
||||
const int width = (config.width == glu::RenderConfig::DONT_CARE) ? 256 : config.width;
|
||||
const int height = (config.height == glu::RenderConfig::DONT_CARE) ? 256 : config.height;
|
||||
const int width = (config.width == glu::RenderConfig::DONT_CARE) ? 256 : config.width;
|
||||
const int height = (config.height == glu::RenderConfig::DONT_CARE) ? 256 : config.height;
|
||||
|
||||
vector<eglw::EGLint> cfgAttribs;
|
||||
cfgAttribs.push_back(EGL_RENDERABLE_TYPE);
|
||||
if (isES)
|
||||
{
|
||||
switch (contextType.getMajorVersion())
|
||||
{
|
||||
case 3:
|
||||
cfgAttribs.push_back(EGL_OPENGL_ES3_BIT);
|
||||
break;
|
||||
case 2:
|
||||
cfgAttribs.push_back(EGL_OPENGL_ES2_BIT);
|
||||
break;
|
||||
default:
|
||||
cfgAttribs.push_back(EGL_OPENGL_ES_BIT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Desktop GL, which is the whole point of this port.
|
||||
cfgAttribs.push_back(EGL_OPENGL_BIT);
|
||||
}
|
||||
vector<eglw::EGLint> cfgAttribs;
|
||||
cfgAttribs.push_back(EGL_RENDERABLE_TYPE);
|
||||
if (isES) {
|
||||
switch (contextType.getMajorVersion()) {
|
||||
case 3:
|
||||
cfgAttribs.push_back(EGL_OPENGL_ES3_BIT);
|
||||
break;
|
||||
case 2:
|
||||
cfgAttribs.push_back(EGL_OPENGL_ES2_BIT);
|
||||
break;
|
||||
default:
|
||||
cfgAttribs.push_back(EGL_OPENGL_ES_BIT);
|
||||
}
|
||||
} else {
|
||||
// Desktop GL, which is the whole point of this port.
|
||||
cfgAttribs.push_back(EGL_OPENGL_BIT);
|
||||
}
|
||||
|
||||
cfgAttribs.push_back(EGL_SURFACE_TYPE);
|
||||
cfgAttribs.push_back(wantWindow ? EGL_WINDOW_BIT : EGL_PBUFFER_BIT);
|
||||
cfgAttribs.push_back(EGL_SURFACE_TYPE);
|
||||
cfgAttribs.push_back(wantWindow ? EGL_WINDOW_BIT : EGL_PBUFFER_BIT);
|
||||
|
||||
static const struct
|
||||
{
|
||||
eglw::EGLint attrib;
|
||||
int glu::RenderConfig::*field;
|
||||
} s_sizeAttribs[] = {
|
||||
{EGL_RED_SIZE, &glu::RenderConfig::redBits}, {EGL_GREEN_SIZE, &glu::RenderConfig::greenBits},
|
||||
{EGL_BLUE_SIZE, &glu::RenderConfig::blueBits}, {EGL_ALPHA_SIZE, &glu::RenderConfig::alphaBits},
|
||||
{EGL_DEPTH_SIZE, &glu::RenderConfig::depthBits}, {EGL_STENCIL_SIZE, &glu::RenderConfig::stencilBits},
|
||||
{EGL_SAMPLES, &glu::RenderConfig::numSamples},
|
||||
};
|
||||
for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_sizeAttribs); ndx++)
|
||||
{
|
||||
const int value = config.*(s_sizeAttribs[ndx].field);
|
||||
if (value != glu::RenderConfig::DONT_CARE)
|
||||
{
|
||||
cfgAttribs.push_back(s_sizeAttribs[ndx].attrib);
|
||||
cfgAttribs.push_back(value);
|
||||
}
|
||||
}
|
||||
cfgAttribs.push_back(EGL_NONE);
|
||||
static const struct {
|
||||
eglw::EGLint attrib;
|
||||
int glu::RenderConfig::* field;
|
||||
} s_sizeAttribs[] = {
|
||||
{EGL_RED_SIZE, &glu::RenderConfig::redBits}, {EGL_GREEN_SIZE, &glu::RenderConfig::greenBits},
|
||||
{EGL_BLUE_SIZE, &glu::RenderConfig::blueBits}, {EGL_ALPHA_SIZE, &glu::RenderConfig::alphaBits},
|
||||
{EGL_DEPTH_SIZE, &glu::RenderConfig::depthBits}, {EGL_STENCIL_SIZE, &glu::RenderConfig::stencilBits},
|
||||
{EGL_SAMPLES, &glu::RenderConfig::numSamples},
|
||||
};
|
||||
for (size_t ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_sizeAttribs); ndx++) {
|
||||
const int value = config.*(s_sizeAttribs[ndx].field);
|
||||
if (value != glu::RenderConfig::DONT_CARE) {
|
||||
cfgAttribs.push_back(s_sizeAttribs[ndx].attrib);
|
||||
cfgAttribs.push_back(value);
|
||||
}
|
||||
}
|
||||
cfgAttribs.push_back(EGL_NONE);
|
||||
|
||||
eglw::EGLConfig eglConfig = nullptr;
|
||||
eglw::EGLint numConfigs = 0;
|
||||
EGLU_CHECK_CALL(m_egl, chooseConfig(m_eglDisplay, &cfgAttribs[0], &eglConfig, 1, &numConfigs));
|
||||
if (numConfigs < 1)
|
||||
throw tcu::NotSupportedError("No matching EGL config for the requested context");
|
||||
eglw::EGLConfig eglConfig = nullptr;
|
||||
eglw::EGLint numConfigs = 0;
|
||||
EGLU_CHECK_CALL(m_egl, chooseConfig(m_eglDisplay, &cfgAttribs[0], &eglConfig, 1, &numConfigs));
|
||||
if (numConfigs < 1) throw tcu::NotSupportedError("No matching EGL config for the requested context");
|
||||
|
||||
if (wantWindow)
|
||||
{
|
||||
if (wantWindow) {
|
||||
#if defined(__ANDROID__)
|
||||
m_window = new ImageReaderWindow(width, height);
|
||||
m_window = new ImageReaderWindow(width, height);
|
||||
|
||||
eglw::EGLint visualId = 0;
|
||||
if (m_egl.getConfigAttrib(m_eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, &visualId) && visualId != 0)
|
||||
ANativeWindow_setBuffersGeometry(m_window->getWindow(), width, height, visualId);
|
||||
eglw::EGLint visualId = 0;
|
||||
if (m_egl.getConfigAttrib(m_eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, &visualId) && visualId != 0)
|
||||
ANativeWindow_setBuffersGeometry(m_window->getWindow(), width, height, visualId);
|
||||
|
||||
m_eglSurface = m_egl.createWindowSurface(m_eglDisplay, eglConfig,
|
||||
(eglw::EGLNativeWindowType)m_window->getWindow(), nullptr);
|
||||
EGLU_CHECK_MSG(m_egl, "eglCreateWindowSurface()");
|
||||
m_eglSurface = m_egl.createWindowSurface(m_eglDisplay, eglConfig,
|
||||
(eglw::EGLNativeWindowType)m_window->getWindow(), nullptr);
|
||||
EGLU_CHECK_MSG(m_egl, "eglCreateWindowSurface()");
|
||||
#else
|
||||
throw tcu::NotSupportedError("Window surfaces are not supported by the desktop MobileGL platform");
|
||||
throw tcu::NotSupportedError("Window surfaces are not supported by the desktop MobileGL platform");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
const eglw::EGLint surfaceAttribs[] = {EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE};
|
||||
m_eglSurface = m_egl.createPbufferSurface(m_eglDisplay, eglConfig, surfaceAttribs);
|
||||
EGLU_CHECK_MSG(m_egl, "eglCreatePbufferSurface()");
|
||||
}
|
||||
} else {
|
||||
const eglw::EGLint surfaceAttribs[] = {EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE};
|
||||
m_eglSurface = m_egl.createPbufferSurface(m_eglDisplay, eglConfig, surfaceAttribs);
|
||||
EGLU_CHECK_MSG(m_egl, "eglCreatePbufferSurface()");
|
||||
}
|
||||
|
||||
if (m_eglSurface == EGL_NO_SURFACE)
|
||||
throw tcu::ResourceError("Failed to create EGL surface");
|
||||
if (m_eglSurface == EGL_NO_SURFACE) throw tcu::ResourceError("Failed to create EGL surface");
|
||||
|
||||
vector<eglw::EGLint> ctxAttribs;
|
||||
ctxAttribs.push_back(EGL_CONTEXT_MAJOR_VERSION_KHR);
|
||||
ctxAttribs.push_back(contextType.getMajorVersion());
|
||||
ctxAttribs.push_back(EGL_CONTEXT_MINOR_VERSION_KHR);
|
||||
ctxAttribs.push_back(contextType.getMinorVersion());
|
||||
vector<eglw::EGLint> ctxAttribs;
|
||||
ctxAttribs.push_back(EGL_CONTEXT_MAJOR_VERSION_KHR);
|
||||
ctxAttribs.push_back(contextType.getMajorVersion());
|
||||
ctxAttribs.push_back(EGL_CONTEXT_MINOR_VERSION_KHR);
|
||||
ctxAttribs.push_back(contextType.getMinorVersion());
|
||||
|
||||
switch (contextType.getProfile())
|
||||
{
|
||||
case glu::PROFILE_ES:
|
||||
EGLU_CHECK_CALL(m_egl, bindAPI(EGL_OPENGL_ES_API));
|
||||
break;
|
||||
case glu::PROFILE_CORE:
|
||||
EGLU_CHECK_CALL(m_egl, bindAPI(EGL_OPENGL_API));
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR);
|
||||
break;
|
||||
case glu::PROFILE_COMPATIBILITY:
|
||||
EGLU_CHECK_CALL(m_egl, bindAPI(EGL_OPENGL_API));
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR);
|
||||
break;
|
||||
default:
|
||||
TCU_CHECK_INTERNAL(false);
|
||||
}
|
||||
switch (contextType.getProfile()) {
|
||||
case glu::PROFILE_ES:
|
||||
EGLU_CHECK_CALL(m_egl, bindAPI(EGL_OPENGL_ES_API));
|
||||
break;
|
||||
case glu::PROFILE_CORE:
|
||||
EGLU_CHECK_CALL(m_egl, bindAPI(EGL_OPENGL_API));
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR);
|
||||
break;
|
||||
case glu::PROFILE_COMPATIBILITY:
|
||||
EGLU_CHECK_CALL(m_egl, bindAPI(EGL_OPENGL_API));
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
|
||||
ctxAttribs.push_back(EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR);
|
||||
break;
|
||||
default:
|
||||
TCU_CHECK_INTERNAL(false);
|
||||
}
|
||||
|
||||
eglw::EGLint flags = 0;
|
||||
if ((contextType.getFlags() & glu::CONTEXT_DEBUG) != 0)
|
||||
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||
if ((contextType.getFlags() & glu::CONTEXT_ROBUST) != 0)
|
||||
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||
if ((contextType.getFlags() & glu::CONTEXT_FORWARD_COMPATIBLE) != 0)
|
||||
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||
if (flags != 0)
|
||||
{
|
||||
ctxAttribs.push_back(EGL_CONTEXT_FLAGS_KHR);
|
||||
ctxAttribs.push_back(flags);
|
||||
}
|
||||
ctxAttribs.push_back(EGL_NONE);
|
||||
eglw::EGLint flags = 0;
|
||||
if ((contextType.getFlags() & glu::CONTEXT_DEBUG) != 0) flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||
if ((contextType.getFlags() & glu::CONTEXT_ROBUST) != 0) flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||
if ((contextType.getFlags() & glu::CONTEXT_FORWARD_COMPATIBLE) != 0)
|
||||
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||
if (flags != 0) {
|
||||
ctxAttribs.push_back(EGL_CONTEXT_FLAGS_KHR);
|
||||
ctxAttribs.push_back(flags);
|
||||
}
|
||||
ctxAttribs.push_back(EGL_NONE);
|
||||
|
||||
const EglRenderContext *sharedEglRenderContext = dynamic_cast<const EglRenderContext *>(sharedContext);
|
||||
m_sharedEglContext = sharedEglRenderContext ? sharedEglRenderContext->getEglContext() : EGL_NO_CONTEXT;
|
||||
const EglRenderContext* sharedEglRenderContext = dynamic_cast<const EglRenderContext*>(sharedContext);
|
||||
m_sharedEglContext = sharedEglRenderContext ? sharedEglRenderContext->getEglContext() : EGL_NO_CONTEXT;
|
||||
|
||||
m_eglContext = m_egl.createContext(m_eglDisplay, eglConfig, m_sharedEglContext, &ctxAttribs[0]);
|
||||
EGLU_CHECK_MSG(m_egl, "eglCreateContext()");
|
||||
if (!m_eglContext)
|
||||
throw tcu::ResourceError("eglCreateContext() failed");
|
||||
m_eglContext = m_egl.createContext(m_eglDisplay, eglConfig, m_sharedEglContext, &ctxAttribs[0]);
|
||||
EGLU_CHECK_MSG(m_egl, "eglCreateContext()");
|
||||
if (!m_eglContext) throw tcu::ResourceError("eglCreateContext() failed");
|
||||
|
||||
// MobileGL requires draw == read.
|
||||
EGLU_CHECK_CALL(m_egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
|
||||
// MobileGL requires draw == read.
|
||||
EGLU_CHECK_CALL(m_egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
|
||||
|
||||
// MobileGL advertises EGL 1.5, so eglGetProcAddress resolves core entry
|
||||
// points too; there is no separate GL library to dlopen.
|
||||
GetProcFuncLoader funcLoader(m_egl);
|
||||
glu::initCoreFunctions(&m_glFunctions, &funcLoader, contextType.getAPI());
|
||||
glu::initExtensionFunctions(&m_glFunctions, &funcLoader, contextType.getAPI());
|
||||
}
|
||||
|
||||
EglRenderContext::~EglRenderContext(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_eglDisplay != EGL_NO_DISPLAY)
|
||||
{
|
||||
m_egl.makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
if (m_eglContext != EGL_NO_CONTEXT)
|
||||
m_egl.destroyContext(m_eglDisplay, m_eglContext);
|
||||
|
||||
if (m_eglSurface != EGL_NO_SURFACE)
|
||||
m_egl.destroySurface(m_eglDisplay, m_eglSurface);
|
||||
|
||||
if (m_sharedEglContext == EGL_NO_CONTEXT)
|
||||
m_egl.terminate(m_eglDisplay);
|
||||
// MobileGL advertises EGL 1.5, so eglGetProcAddress resolves core entry
|
||||
// points too; there is no separate GL library to dlopen.
|
||||
GetProcFuncLoader funcLoader(m_egl);
|
||||
glu::initCoreFunctions(&m_glFunctions, &funcLoader, contextType.getAPI());
|
||||
glu::initExtensionFunctions(&m_glFunctions, &funcLoader, contextType.getAPI());
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
delete m_window;
|
||||
}
|
||||
EglRenderContext::~EglRenderContext(void) {
|
||||
try {
|
||||
if (m_eglDisplay != EGL_NO_DISPLAY) {
|
||||
m_egl.makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
void EglRenderContext::makeCurrent(void)
|
||||
{
|
||||
EGLU_CHECK_CALL(m_egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
|
||||
}
|
||||
if (m_eglContext != EGL_NO_CONTEXT) m_egl.destroyContext(m_eglDisplay, m_eglContext);
|
||||
|
||||
void EglRenderContext::postIterate(void)
|
||||
{
|
||||
m_glFunctions.finish();
|
||||
}
|
||||
if (m_eglSurface != EGL_NO_SURFACE) m_egl.destroySurface(m_eglDisplay, m_eglSurface);
|
||||
|
||||
} // namespace mobilegl
|
||||
if (m_sharedEglContext == EGL_NO_CONTEXT) m_egl.terminate(m_eglDisplay);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
|
||||
delete m_window;
|
||||
}
|
||||
|
||||
void EglRenderContext::makeCurrent(void) {
|
||||
EGLU_CHECK_CALL(m_egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
|
||||
}
|
||||
|
||||
void EglRenderContext::postIterate(void) {
|
||||
m_glFunctions.finish();
|
||||
}
|
||||
|
||||
} // namespace mobilegl
|
||||
} // namespace tcu
|
||||
|
||||
tcu::Platform *createPlatform(void)
|
||||
{
|
||||
tcu::Platform* createPlatform(void) {
|
||||
return new tcu::mobilegl::Platform();
|
||||
}
|
||||
|
||||
@@ -23,11 +23,10 @@
|
||||
|
||||
#include "tcuDefs.hpp"
|
||||
|
||||
namespace tcu
|
||||
{
|
||||
class Platform;
|
||||
}
|
||||
namespace tcu {
|
||||
class Platform;
|
||||
} // namespace tcu
|
||||
|
||||
tcu::Platform *createPlatform(void);
|
||||
tcu::Platform* createPlatform(void);
|
||||
|
||||
#endif // _TCUMOBILEGLPLATFORM_HPP
|
||||
|
||||
+76
-63
@@ -33,15 +33,15 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef void *EGLDisplay;
|
||||
typedef void *EGLConfig;
|
||||
typedef void *EGLSurface;
|
||||
typedef void *EGLContext;
|
||||
typedef void* EGLDisplay;
|
||||
typedef void* EGLConfig;
|
||||
typedef void* EGLSurface;
|
||||
typedef void* EGLContext;
|
||||
typedef int EGLint;
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef unsigned int EGLenum;
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
typedef void* EGLNativeDisplayType;
|
||||
typedef void* EGLNativeWindowType;
|
||||
|
||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
||||
#define EGL_NO_CONTEXT ((EGLContext)0)
|
||||
@@ -88,43 +88,45 @@ typedef void *EGLNativeWindowType;
|
||||
#define GL_RENDERBUFFER 0x8D41
|
||||
|
||||
typedef EGLDisplay (*P_getDisplay)(EGLNativeDisplayType);
|
||||
typedef EGLBoolean (*P_initialize)(EGLDisplay, EGLint *, EGLint *);
|
||||
typedef EGLBoolean (*P_initialize)(EGLDisplay, EGLint*, EGLint*);
|
||||
typedef EGLBoolean (*P_bindAPI)(EGLenum);
|
||||
typedef EGLBoolean (*P_chooseConfig)(EGLDisplay, const EGLint *, EGLConfig *, EGLint, EGLint *);
|
||||
typedef EGLBoolean (*P_getConfigAttrib)(EGLDisplay, EGLConfig, EGLint, EGLint *);
|
||||
typedef EGLSurface (*P_createWindowSurface)(EGLDisplay, EGLConfig, EGLNativeWindowType, const EGLint *);
|
||||
typedef EGLSurface (*P_createPbufferSurface)(EGLDisplay, EGLConfig, const EGLint *);
|
||||
typedef EGLContext (*P_createContext)(EGLDisplay, EGLConfig, EGLContext, const EGLint *);
|
||||
typedef EGLBoolean (*P_chooseConfig)(EGLDisplay, const EGLint*, EGLConfig*, EGLint, EGLint*);
|
||||
typedef EGLBoolean (*P_getConfigAttrib)(EGLDisplay, EGLConfig, EGLint, EGLint*);
|
||||
typedef EGLSurface (*P_createWindowSurface)(EGLDisplay, EGLConfig, EGLNativeWindowType, const EGLint*);
|
||||
typedef EGLSurface (*P_createPbufferSurface)(EGLDisplay, EGLConfig, const EGLint*);
|
||||
typedef EGLContext (*P_createContext)(EGLDisplay, EGLConfig, EGLContext, const EGLint*);
|
||||
typedef EGLBoolean (*P_makeCurrent)(EGLDisplay, EGLSurface, EGLSurface, EGLContext);
|
||||
typedef EGLint (*P_getError)(void);
|
||||
|
||||
typedef const unsigned char *(*P_glGetString)(unsigned int);
|
||||
typedef void (*P_glGetIntegerv)(unsigned int, int *);
|
||||
typedef const unsigned char* (*P_glGetString)(unsigned int);
|
||||
typedef void (*P_glGetIntegerv)(unsigned int, int*);
|
||||
typedef void (*P_glClearColor)(float, float, float, float);
|
||||
typedef void (*P_glClear)(unsigned int);
|
||||
typedef void (*P_glFinish)(void);
|
||||
typedef void (*P_glReadPixels)(int, int, int, int, unsigned int, unsigned int, void *);
|
||||
typedef void (*P_glReadPixels)(int, int, int, int, unsigned int, unsigned int, void*);
|
||||
typedef unsigned int (*P_glGetError)(void);
|
||||
typedef void (*P_glGenTextures)(int, unsigned int *);
|
||||
typedef void (*P_glGenTextures)(int, unsigned int*);
|
||||
typedef void (*P_glBindTexture)(unsigned int, unsigned int);
|
||||
typedef void (*P_glTexImage2D)(unsigned int, int, int, int, int, int, unsigned int, unsigned int, const void *);
|
||||
typedef void (*P_glTexImage2D)(unsigned int, int, int, int, int, int, unsigned int, unsigned int, const void*);
|
||||
typedef void (*P_glTexParameteri)(unsigned int, unsigned int, int);
|
||||
typedef void (*P_glGenFramebuffers)(int, unsigned int *);
|
||||
typedef void (*P_glGenFramebuffers)(int, unsigned int*);
|
||||
typedef void (*P_glBindFramebuffer)(unsigned int, unsigned int);
|
||||
typedef void (*P_glFramebufferTexture2D)(unsigned int, unsigned int, unsigned int, unsigned int, int);
|
||||
typedef unsigned int (*P_glCheckFramebufferStatus)(unsigned int);
|
||||
typedef void (*P_glViewport)(int, int, int, int);
|
||||
typedef void (*P_glGenRenderbuffers)(int, unsigned int *);
|
||||
typedef void (*P_glGenRenderbuffers)(int, unsigned int*);
|
||||
typedef void (*P_glBindRenderbuffer)(unsigned int, unsigned int);
|
||||
typedef void (*P_glRenderbufferStorage)(unsigned int, unsigned int, int, int);
|
||||
typedef void (*P_glFramebufferRenderbuffer)(unsigned int, unsigned int, unsigned int, unsigned int);
|
||||
|
||||
static void *g_lib;
|
||||
static void *S(const char *n) { return dlsym(g_lib, n); }
|
||||
static void* g_lib;
|
||||
static void* S(const char* n) {
|
||||
return dlsym(g_lib, n);
|
||||
}
|
||||
|
||||
static void on_image(void *ctx, AImageReader *r) {
|
||||
static void on_image(void* ctx, AImageReader* r) {
|
||||
(void)ctx;
|
||||
AImage *img = NULL;
|
||||
AImage* img = NULL;
|
||||
/* Drain the queue, or the producer blocks once maxImages are in flight. */
|
||||
if (AImageReader_acquireNextImage(r, &img) == AMEDIA_OK && img) AImage_delete(img);
|
||||
}
|
||||
@@ -136,18 +138,23 @@ static int near8(unsigned got, int want, int tol) {
|
||||
return d <= tol && d >= -tol;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char *backend = "DirectGLES";
|
||||
const char *surface = "pbuffer";
|
||||
const char *libpath = "libMobileGL.so";
|
||||
int main(int argc, char** argv) {
|
||||
const char* backend = "DirectGLES";
|
||||
const char* surface = "pbuffer";
|
||||
const char* libpath = "libMobileGL.so";
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!strcmp(argv[i], "--backend") && i + 1 < argc) backend = argv[++i];
|
||||
else if (!strcmp(argv[i], "--surface") && i + 1 < argc) surface = argv[++i];
|
||||
else if (!strcmp(argv[i], "--lib") && i + 1 < argc) libpath = argv[++i];
|
||||
if (!strcmp(argv[i], "--backend") && i + 1 < argc)
|
||||
backend = argv[++i];
|
||||
else if (!strcmp(argv[i], "--surface") && i + 1 < argc)
|
||||
surface = argv[++i];
|
||||
else if (!strcmp(argv[i], "--lib") && i + 1 < argc)
|
||||
libpath = argv[++i];
|
||||
else {
|
||||
fprintf(stderr, "usage: %s [--backend DirectGLES|DirectVulkan]"
|
||||
" [--surface pbuffer|imagereader] [--lib path]\n", argv[0]);
|
||||
fprintf(stderr,
|
||||
"usage: %s [--backend DirectGLES|DirectVulkan]"
|
||||
" [--surface pbuffer|imagereader] [--lib path]\n",
|
||||
argv[0]);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -159,13 +166,13 @@ int main(int argc, char **argv) {
|
||||
printf("mgprobe backend=%s surface=%s lib=%s\n", backend, surface, libpath);
|
||||
|
||||
int useWindow = !strcmp(surface, "imagereader");
|
||||
ANativeWindow *win = NULL;
|
||||
AImageReader *reader = NULL;
|
||||
ANativeWindow* win = NULL;
|
||||
AImageReader* reader = NULL;
|
||||
if (useWindow) {
|
||||
if (AImageReader_newWithUsage(DIM, DIM, AIMAGE_FORMAT_RGBA_8888,
|
||||
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
|
||||
AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT,
|
||||
4, &reader) != AMEDIA_OK || !reader) {
|
||||
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT,
|
||||
4, &reader) != AMEDIA_OK ||
|
||||
!reader) {
|
||||
printf("FAIL AImageReader_newWithUsage\n");
|
||||
return 3;
|
||||
}
|
||||
@@ -210,12 +217,23 @@ int main(int argc, char **argv) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
const EGLint cfgAttribs[] = {
|
||||
EGL_SURFACE_TYPE, useWindow ? EGL_WINDOW_BIT : EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8,
|
||||
EGL_NONE};
|
||||
const EGLint cfgAttribs[] = {EGL_SURFACE_TYPE,
|
||||
useWindow ? EGL_WINDOW_BIT : EGL_PBUFFER_BIT,
|
||||
EGL_RENDERABLE_TYPE,
|
||||
EGL_OPENGL_BIT,
|
||||
EGL_RED_SIZE,
|
||||
8,
|
||||
EGL_GREEN_SIZE,
|
||||
8,
|
||||
EGL_BLUE_SIZE,
|
||||
8,
|
||||
EGL_ALPHA_SIZE,
|
||||
8,
|
||||
EGL_DEPTH_SIZE,
|
||||
24,
|
||||
EGL_STENCIL_SIZE,
|
||||
8,
|
||||
EGL_NONE};
|
||||
EGLConfig cfg = 0;
|
||||
EGLint ncfg = 0;
|
||||
if (!eglChooseConfig_(dpy, cfgAttribs, &cfg, 1, &ncfg) || ncfg < 1) {
|
||||
@@ -234,14 +252,13 @@ int main(int argc, char **argv) {
|
||||
surf = eglCreatePbufferSurface_(dpy, cfg, sa);
|
||||
}
|
||||
if (surf == EGL_NO_SURFACE) {
|
||||
printf("FAIL create%sSurface err=0x%x\n", useWindow ? "Window" : "Pbuffer",
|
||||
eglGetError_ ? eglGetError_() : 0);
|
||||
printf("FAIL create%sSurface err=0x%x\n", useWindow ? "Window" : "Pbuffer", eglGetError_ ? eglGetError_() : 0);
|
||||
return 9;
|
||||
}
|
||||
|
||||
const EGLint ctxAttribs[] = {
|
||||
EGL_CONTEXT_MAJOR_VERSION, 3, EGL_CONTEXT_MINOR_VERSION, 3,
|
||||
EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, EGL_NONE};
|
||||
EGL_CONTEXT_MAJOR_VERSION, 3, EGL_CONTEXT_MINOR_VERSION, 3, EGL_CONTEXT_OPENGL_PROFILE_MASK,
|
||||
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, EGL_NONE};
|
||||
EGLContext ctx = eglCreateContext_(dpy, cfg, EGL_NO_CONTEXT, ctxAttribs);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("FAIL eglCreateContext(3.3 core) err=0x%x\n", eglGetError_ ? eglGetError_() : 0);
|
||||
@@ -272,18 +289,18 @@ int main(int argc, char **argv) {
|
||||
P_glGenRenderbuffers glGenRenderbuffers_ = (P_glGenRenderbuffers)S("glGenRenderbuffers");
|
||||
P_glBindRenderbuffer glBindRenderbuffer_ = (P_glBindRenderbuffer)S("glBindRenderbuffer");
|
||||
P_glRenderbufferStorage glRenderbufferStorage_ = (P_glRenderbufferStorage)S("glRenderbufferStorage");
|
||||
P_glFramebufferRenderbuffer glFramebufferRenderbuffer_ = (P_glFramebufferRenderbuffer)S("glFramebufferRenderbuffer");
|
||||
P_glFramebufferRenderbuffer glFramebufferRenderbuffer_ =
|
||||
(P_glFramebufferRenderbuffer)S("glFramebufferRenderbuffer");
|
||||
|
||||
int major = -1, minor = -1, profile = -1;
|
||||
glGetIntegerv_(GL_MAJOR_VERSION, &major);
|
||||
glGetIntegerv_(GL_MINOR_VERSION, &minor);
|
||||
glGetIntegerv_(GL_CONTEXT_PROFILE_MASK, &profile);
|
||||
printf(" GL_VENDOR %s\n", (const char *)glGetString_(GL_VENDOR));
|
||||
printf(" GL_RENDERER %s\n", (const char *)glGetString_(GL_RENDERER));
|
||||
printf(" GL_VERSION %s\n", (const char *)glGetString_(GL_VERSION));
|
||||
printf(" GLSL %s\n", (const char *)glGetString_(GL_SHADING_LANGUAGE_VERSION));
|
||||
printf(" version %d.%d profile_mask 0x%x %s\n", major, minor, profile,
|
||||
(profile & 1) ? "(core)" : "(NOT CORE)");
|
||||
printf(" GL_VENDOR %s\n", (const char*)glGetString_(GL_VENDOR));
|
||||
printf(" GL_RENDERER %s\n", (const char*)glGetString_(GL_RENDERER));
|
||||
printf(" GL_VERSION %s\n", (const char*)glGetString_(GL_VERSION));
|
||||
printf(" GLSL %s\n", (const char*)glGetString_(GL_SHADING_LANGUAGE_VERSION));
|
||||
printf(" version %d.%d profile_mask 0x%x %s\n", major, minor, profile, (profile & 1) ? "(core)" : "(NOT CORE)");
|
||||
|
||||
unsigned char px[4];
|
||||
|
||||
@@ -294,8 +311,7 @@ int main(int argc, char **argv) {
|
||||
memset(px, 0, sizeof px);
|
||||
glReadPixels_(DIM / 2, DIM / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, px);
|
||||
int defOk = near8(px[0], 64, 10) && near8(px[1], 128, 10) && near8(px[2], 191, 10);
|
||||
printf(" default-FB readback (%u,%u,%u,%u) %s\n", px[0], px[1], px[2], px[3],
|
||||
defOk ? "ok" : "BROKEN");
|
||||
printf(" default-FB readback (%u,%u,%u,%u) %s\n", px[0], px[1], px[2], px[3], defOk ? "ok" : "BROKEN");
|
||||
|
||||
/* User FBO - this is what dEQP uses with --deqp-surface-type=fbo. */
|
||||
unsigned int tex = 0, fbo = 0;
|
||||
@@ -317,8 +333,7 @@ int main(int argc, char **argv) {
|
||||
memset(px, 0, sizeof px);
|
||||
glReadPixels_(DIM / 2, DIM / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, px);
|
||||
fboOk = near8(px[0], 230, 10) && near8(px[1], 51, 10) && near8(px[2], 102, 10);
|
||||
printf(" user-FBO readback (%u,%u,%u,%u) %s\n", px[0], px[1], px[2], px[3],
|
||||
fboOk ? "ok" : "BROKEN");
|
||||
printf(" user-FBO readback (%u,%u,%u,%u) %s\n", px[0], px[1], px[2], px[3], fboOk ? "ok" : "BROKEN");
|
||||
} else {
|
||||
printf(" user-FBO incomplete status=0x%x\n", fbst);
|
||||
}
|
||||
@@ -346,8 +361,7 @@ int main(int argc, char **argv) {
|
||||
memset(px, 0, sizeof px);
|
||||
glReadPixels_(DIM / 2, DIM / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, px);
|
||||
rboOk = near8(px[0], 26, 10) && near8(px[1], 179, 10) && near8(px[2], 77, 10);
|
||||
printf(" rbo-FBO readback (%u,%u,%u,%u) %s\n", px[0], px[1], px[2], px[3],
|
||||
rboOk ? "ok" : "BROKEN");
|
||||
printf(" rbo-FBO readback (%u,%u,%u,%u) %s\n", px[0], px[1], px[2], px[3], rboOk ? "ok" : "BROKEN");
|
||||
} else {
|
||||
printf(" rbo-FBO incomplete status=0x%x\n", rst);
|
||||
}
|
||||
@@ -357,9 +371,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
unsigned glerr = glGetError_ ? glGetError_() : 0;
|
||||
int ok = fboOk && rboOk && (major > 3 || (major == 3 && minor >= 3)) && (profile & 1) && glerr == 0;
|
||||
printf("%s backend=%s surface=%s default_fb=%s user_fbo=%s rbo_fbo=%s glerr=0x%x\n",
|
||||
ok ? "PASS" : "FAIL", backend, surface, defOk ? "ok" : "broken",
|
||||
fboOk ? "ok" : "broken", rboOk ? "ok" : "broken", glerr);
|
||||
printf("%s backend=%s surface=%s default_fb=%s user_fbo=%s rbo_fbo=%s glerr=0x%x\n", ok ? "PASS" : "FAIL", backend,
|
||||
surface, defOk ? "ok" : "broken", fboOk ? "ok" : "broken", rboOk ? "ok" : "broken", glerr);
|
||||
|
||||
fflush(stdout);
|
||||
/* MobileGL aborts in static teardown; leave before that runs. */
|
||||
|
||||
Reference in New Issue
Block a user