1bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry/*-------------------------------------------------------------------------
2bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * drawElements Quality Program Platform Utilites
3bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * ----------------------------------------------
4bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *
5bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * Copyright 2015 The Android Open Source Project
6bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *
7bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * Licensed under the Apache License, Version 2.0 (the "License");
8bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * you may not use this file except in compliance with the License.
9bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * You may obtain a copy of the License at
10bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *
11bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *      http://www.apache.org/licenses/LICENSE-2.0
12bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *
13bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * Unless required by applicable law or agreed to in writing, software
14bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * distributed under the License is distributed on an "AS IS" BASIS,
15bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * See the License for the specific language governing permissions and
17bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * limitations under the License.
18bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *
19bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *//*!
20bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * \file
21bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry * \brief Android platform capability query JNI component
22bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry *//*--------------------------------------------------------------------*/
23bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
24bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "tcuDefs.hpp"
25bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
26bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "tcuCommandLine.hpp"
27bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "gluRenderConfig.hpp"
28bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "gluRenderContext.hpp"
29bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "eglwLibrary.hpp"
30bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "eglwEnums.hpp"
31bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "egluUtil.hpp"
32bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include "egluGLUtil.hpp"
33bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
34bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry#include <jni.h>
35bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
36bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyrynamespace
37bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
38bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyrynamespace opt
39bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
40bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
41bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko PöyryDE_DECLARE_COMMAND_LINE_OPT(GLMajorVersion, int);
42bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko PöyryDE_DECLARE_COMMAND_LINE_OPT(GLMinorVersion, int);
43bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
44bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry} // opt
45bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
46bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyryclass GLConfigParser : public tcu::CommandLine
47bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
48bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyrypublic:
49bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry					GLConfigParser			(const std::string& argString);
50bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
51bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	bool			hasGLMajorVersion		(void) const;
52bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	bool			hasGLMinorVersion		(void) const;
53bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	int				getGLMajorVersion		(void) const;
54bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	int				getGLMinorVersion		(void) const;
55bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
56bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyryprivate:
57bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	virtual void	registerExtendedOptions	(de::cmdline::Parser& parser);
58bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry};
59bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
60bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko PöyryGLConfigParser::GLConfigParser (const std::string& argString)
61bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
62bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	const std::string execString = "fakebinaryname " + argString; // convert argument list to full command line
63bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
64bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	if (!parse(execString))
65bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
66bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("failed to parse command line");
67bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		TCU_THROW(Exception, "failed to parse command line");
68bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
69bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
70bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
71bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyrybool GLConfigParser::hasGLMajorVersion (void) const
72bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
73bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	return getCommandLine().hasOption<opt::GLMajorVersion>();
74bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
75bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
76bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyrybool GLConfigParser::hasGLMinorVersion (void) const
77bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
78bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	return getCommandLine().hasOption<opt::GLMinorVersion>();
79bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
80bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
81bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyryint GLConfigParser::getGLMajorVersion (void) const
82bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
83bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	DE_ASSERT(hasGLMajorVersion());
84bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	return getCommandLine().getOption<opt::GLMajorVersion>();
85bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
86bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
87bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyryint GLConfigParser::getGLMinorVersion (void) const
88bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
89bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	DE_ASSERT(hasGLMinorVersion());
90bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	return getCommandLine().getOption<opt::GLMinorVersion>();
91bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
92bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
93bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyryvoid GLConfigParser::registerExtendedOptions (de::cmdline::Parser& parser)
94bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
95bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	using de::cmdline::Option;
96bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
97bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	parser
98bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		<< Option<opt::GLMajorVersion>	(DE_NULL, "deqp-gl-major-version", "OpenGL ES Major version")
99bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		<< Option<opt::GLMinorVersion>	(DE_NULL, "deqp-gl-minor-version", "OpenGL ES Minor version");
100bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
101bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
102bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyryglu::RenderConfig parseRenderConfig (const std::string& argsStr)
103bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
104bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	const GLConfigParser parsedCommandLine (argsStr);
105bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
106bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	if (!parsedCommandLine.hasGLMajorVersion() ||
107bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		!parsedCommandLine.hasGLMinorVersion())
108bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
109bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("minor and major version must be supplied");
110bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		TCU_THROW(Exception, "minor and major version must be supplied");
111bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
112bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	else
113bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
114bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		const glu::ContextType	testContextType	(glu::ApiType::es(parsedCommandLine.getGLMajorVersion(), parsedCommandLine.getGLMinorVersion()));
115bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		glu::RenderConfig		renderConfig	(testContextType);
116bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
117bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		glu::parseRenderConfig(&renderConfig, parsedCommandLine);
118bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
119bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		return renderConfig;
120bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
121bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
122bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
123bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyrybool isRenderConfigSupported (const std::string& cmdLineStr)
124bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
125bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	const glu::RenderConfig		renderConfig	= parseRenderConfig(cmdLineStr);
126bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	const eglw::DefaultLibrary	egl;
127bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	const eglw::EGLDisplay		display			= egl.getDisplay(EGL_DEFAULT_DISPLAY);
128bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	eglw::EGLint				eglMajor		= -1;
129bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	eglw::EGLint				eglMinor		= -1;
130bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
131bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	if (display == EGL_NO_DISPLAY)
132bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
133bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("could not get default display");
134bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		TCU_THROW(Exception, "could not get default display");
135bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
136bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
137bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	if (egl.initialize(display, &eglMajor, &eglMinor) != EGL_TRUE)
138bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
139bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("failed to initialize egl");
140bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		TCU_THROW(Exception, "failed to initialize egl");
141bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
142bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	tcu::print("EGL initialized, major=%d, minor=%d", eglMajor, eglMinor);
143bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
144bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	try
145bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
146bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		// ignoring return value
147bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		(void)eglu::chooseConfig(egl, display, renderConfig);
148bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
149bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	catch (const tcu::NotSupportedError&)
150bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
151bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("No matching config");
152bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		egl.terminate(display);
153bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		return false;
154bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
155bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	catch (...)
156bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
157bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		egl.terminate(display);
158bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		throw;
159bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
160bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	egl.terminate(display);
161bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
162bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	return true;
163bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
164bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
165bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry} // anonymous
166bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
167bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
168bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko PöyryDE_BEGIN_EXTERN_C
169bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
170bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko PöyryJNIEXPORT jint JNICALL Java_com_drawelements_deqp_platformutil_DeqpPlatformCapabilityQueryInstrumentation_nativeRenderConfigSupportedQuery (JNIEnv* env, jclass, jstring jCmdLine)
171bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry{
172bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	enum
173bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
174bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		CONFIGQUERYRESULT_SUPPORTED = 0,
175bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		CONFIGQUERYRESULT_NOT_SUPPORTED = 1,
176bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		CONFIGQUERYRESULT_GENERIC_ERROR = -1,
177bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	};
178bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
179bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	std::string			cmdLine;
180bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	const char* const	cmdLineBytes = env->GetStringUTFChars(jCmdLine, DE_NULL);
181bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
182bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	if (cmdLineBytes == DE_NULL)
183bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
184bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		// no command line is not executable
185bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("no command line supplied");
186bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		return CONFIGQUERYRESULT_GENERIC_ERROR;
187bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
188bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
189bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	try
190bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
191bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		// try to copy to local buffer
192bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		cmdLine = std::string(cmdLineBytes);
193bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
194bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	catch (const std::bad_alloc&)
195bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
196bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		env->ReleaseStringUTFChars(jCmdLine, cmdLineBytes);
197bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("failed to copy cmdLine");
198bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		return CONFIGQUERYRESULT_GENERIC_ERROR;
199bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
200bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	env->ReleaseStringUTFChars(jCmdLine, cmdLineBytes);
201bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
202bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	try
203bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
204bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		const bool isSupported = isRenderConfigSupported(cmdLine);
205bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
206bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		return (isSupported) ? (CONFIGQUERYRESULT_SUPPORTED)
207bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		                     : (CONFIGQUERYRESULT_NOT_SUPPORTED);
208bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
209bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	catch (const std::exception& ex)
210bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	{
211bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		// don't bother forwarding the exception to the caller. They cannot do anything with the exception anyway.
212bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		tcu::print("Error: %s", ex.what());
213bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry		return CONFIGQUERYRESULT_GENERIC_ERROR;
214bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry	}
215bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry}
216bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko Pöyry
217bf44c5c30440b0c7a8c7c87f2b7c3ff984e77018Jarkko PöyryDE_END_EXTERN_C
218