diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/test/glsl_parser_test.py | 54 | ||||
-rw-r--r-- | framework/test/opengl.py | 185 | ||||
-rw-r--r-- | framework/test/shader_test.py | 84 |
3 files changed, 150 insertions, 173 deletions
diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py index 21879739c..1cce65036 100644 --- a/framework/test/glsl_parser_test.py +++ b/framework/test/glsl_parser_test.py @@ -95,9 +95,9 @@ class Parser(object): def __init__(self, filepath, installpath=None): # a set that stores a list of keys that have been found already self.__found_keys = set() - self.gl_required = set() - self.glsl_es_version = None - self.glsl_version = None + self.api = None + self.extensions = set() + self.shader_version = None abs_filepath = os.path.join(ROOT_DIR, filepath) try: @@ -115,29 +115,39 @@ class Parser(object): """Set OpenGL and OpenGL ES fast skipping conditions.""" glsl = self.config['glsl_version'] if _is_gles_version(glsl): - self.glsl_es_version = float(glsl[:3]) + self.shader_version = float(glsl[:3]) + if self.shader_version >= 3.0: + self.api = 'gles3' + else: + self.api = 'gles2' elif glsl.endswith('compatibility'): - self.glsl_version = float(glsl[:3]) + self.shader_version = float(glsl[:3]) + self.api = 'compat' else: - self.glsl_version = float(glsl) + self.shader_version = float(glsl) + self.api = 'core' req = self.config['require_extensions'] - self.gl_required = set(r for r in req.split() if not r.startswith('!')) + self.extensions = set(r for r in req.split() if not r.startswith('!')) + + if self.api != 'compat' and 'GL_ARB_compatibility' in self.extensions: + assert self.api == 'core', 'arb_compat with gles?' + self.api = 'compat' # If GLES is requested, but piglit was not built with a gles version, # then ARB_ES3<ver>_compatibility is required. Add it to - # self.gl_required - if self.glsl_es_version and _FORCE_DESKTOP_VERSION: - if self.glsl_es_version == 1.0: + # self.extensions + if self.api.startswith('gles') and _FORCE_DESKTOP_VERSION: + if self.shader_version == 1.0: ver = '2' - elif self.glsl_es_version == 3.0: + elif self.shader_version == 3.0: ver = '3' - elif self.glsl_es_version == 3.1: + elif self.shader_version == 3.1: ver = '3_1' - elif self.glsl_es_version == 3.2: + elif self.shader_version == 3.2: ver = '3_2' ext = 'ARB_ES{}_compatibility'.format(ver) - self.gl_required.add(ext) + self.extensions.add(ext) self.command.append(ext) @staticmethod @@ -274,11 +284,13 @@ class GLSLParserTest(FastSkipMixin, PiglitBaseTest): .tesc, .tese, .geom or .frag """ - def __init__(self, command, gl_required=set(), glsl_version=None, - glsl_es_version=None, **kwargs): + def __init__(self, command, api=None, extensions=set(), + shader_version=None, **kwargs): super(GLSLParserTest, self).__init__( - command, run_concurrent=True, gl_required=gl_required, - glsl_version=glsl_version, glsl_es_version=glsl_es_version) + command, run_concurrent=True, + api=api, + extensions=extensions, + shader_version=shader_version) @PiglitBaseTest.command.getter def command(self): @@ -298,9 +310,9 @@ class GLSLParserTest(FastSkipMixin, PiglitBaseTest): parsed = Parser(filepath, installpath) return cls( parsed.command, - gl_required=parsed.gl_required, - glsl_version=parsed.glsl_version, - glsl_es_version=parsed.glsl_es_version) + api=parsed.api, + extensions=parsed.extensions, + shader_version=parsed.shader_version) def is_skip(self): if os.path.basename(self.command[0]) == 'glslparsertest' and not _HAS_GL_BIN: diff --git a/framework/test/opengl.py b/framework/test/opengl.py index 4941d8ce8..3c8460e28 100644 --- a/framework/test/opengl.py +++ b/framework/test/opengl.py @@ -53,29 +53,22 @@ class FastSkip(object): all the tests that could have, but also a few that should have run. Keyword Arguments: - gl_required -- This is a set of extensions that are required for - running the test. - gl_version -- A float that is the required version number for an - OpenGL test. - gles_version -- A float that is the required version number for an - OpenGL ES test - glsl_version -- A float that is the required version number of OpenGL - Shader Language for a test - glsl_es_version -- A float that is the required version number of OpenGL ES - Shader Language for a test + api -- The API required. + One of [gles1, gles2, gles3, core, compat] + extensions -- A set of extensions required + api_version -- The version of the API required + shader_version -- The versoin of the shader language required """ - __slots__ = ['gl_required', 'gl_version', 'gles_version', 'glsl_version', - 'glsl_es_version'] + __slots__ = ['api', 'extensions', 'api_version', 'shader_version'] info = wflinfo.WflInfo() - def __init__(self, gl_required=None, gl_version=None, gles_version=None, - glsl_version=None, glsl_es_version=None): - self.gl_required = gl_required or set() - self.gl_version = gl_version - self.gles_version = gles_version - self.glsl_version = glsl_version - self.glsl_es_version = glsl_es_version + def __init__(self, api=None, extensions=None, api_version=None, + shader_version=None): + self.extensions = extensions or set() + self.api = api + self.api_version = api_version + self.shader_version = shader_version def test(self): """Skip this test if any of its feature requirements are unmet. @@ -86,48 +79,39 @@ class FastSkip(object): Raises: TestIsSkip -- if any of the conditions passed to self are false """ - if self.info.gl_extensions: - for extension in self.gl_required: - if extension not in self.info.gl_extensions: + if not self.api: + check = self.info.compat + elif self.api in ['gles2', 'gles3']: + check = self.info.es2 + elif self.api == 'gles1': + check = self.info.es1 + else: + check = getattr(self.info, self.api) + + if check.extensions: + for extension in self.extensions: + if extension not in check.extensions: raise TestIsSkip( 'Test requires extension {} ' 'which is not available'.format(extension)) # TODO: Be able to handle any operator - if (self.info.gl_version is not None - and self.gl_version is not None - and self.gl_version > self.info.gl_version): + if (check.api_version is not None + and self.api_version is not None + and self.api_version > check.api_version): raise TestIsSkip( - 'Test requires OpenGL version {}, ' + 'Test requires OpenGL {} version {}, ' 'but only {} is available'.format( - self.gl_version, self.info.gl_version)) + self.api, self.api_version, check.api_version)) # TODO: Be able to handle any operator - if (self.info.gles_version is not None - and self.gles_version is not None - and self.gles_version > self.info.gles_version): + if (check.shader_version is not None + and self.shader_version is not None + and self.shader_version > check.shader_version): raise TestIsSkip( - 'Test requires OpenGL ES version {}, ' + 'Test requires OpenGL {} Shader Language version {}, ' 'but only {} is available'.format( - self.gles_version, self.info.gles_version)) - - # TODO: Be able to handle any operator - if (self.info.glsl_version is not None - and self.glsl_version is not None - and self.glsl_version > self.info.glsl_version): - raise TestIsSkip( - 'Test requires OpenGL Shader Language version {}, ' - 'but only {} is available'.format( - self.glsl_version, self.info.glsl_version)) - - # TODO: Be able to handle any operator - if (self.info.glsl_es_version is not None - and self.glsl_es_version is not None - and self.glsl_es_version > self.info.glsl_es_version): - raise TestIsSkip( - 'Test requires OpenGL ES Shader Language version {}, ' - 'but only {} is available'.format( - self.glsl_es_version, self.info.glsl_es_version)) + self.api, self.shader_version, check.shader_version)) class FastSkipMixin(object): @@ -141,67 +125,36 @@ class FastSkipMixin(object): has all of the same requirements as that class. It also provides new attributes: - gl_required -- This is a set of extensions that are required for - running the test. - gl_version -- A float that is the required version number for an - OpenGL test. - gles_version -- A float that is the required version number for an - OpenGL ES test - glsl_version -- A float that is the required version number of OpenGL - Shader Language for a test - glsl_es_version -- A float that is the required version number of OpenGL ES - Shader Language for a test + require_extensions -- A set of extensions that are requuired for running + this test. + require_shader -- The shader language version required. + reqiure_version -- The API version required. + require_api -- The API required. """ - def __init__(self, command, gl_required=None, gl_version=None, - gles_version=None, glsl_version=None, glsl_es_version=None, - **kwargs): # pylint: disable=too-many-arguments + def __init__(self, command, api=None, extensions=None, api_version=None, + shader_version=None, **kwargs): super(FastSkipMixin, self).__init__(command, **kwargs) - self.__skiper = FastSkip(gl_required=gl_required, - gl_version=gl_version, - gles_version=gles_version, - glsl_version=glsl_version, - glsl_es_version=glsl_es_version) + self.__skiper = FastSkip(api=api, + extensions=extensions, + api_version=api_version, + shader_version=shader_version) @property - def gl_required(self): - return self.__skiper.gl_required - - @gl_required.setter - def gl_required(self, new): - self.__skiper.gl_required = new + def require_extensions(self): + return self.__skiper.extensions @property - def gl_version(self): - return self.__skiper.gl_version - - @gl_version.setter - def gl_version(self, new): - self.__skiper.gl_version = new - - @property - def gles_version(self): - return self.__skiper.gles_version - - @gles_version.setter - def gles_version(self, new): - self.__skiper.gles_version = new + def require_api(self): + return self.__skiper.api @property - def glsl_version(self): - return self.__skiper.glsl_version - - @glsl_version.setter - def glsl_version(self, new): - self.__skiper.glsl_version = new + def require_shader(self): + return self.__skiper.shader_version @property - def glsl_es_version(self): - return self.__skiper.glsl_es_version - - @glsl_es_version.setter - def glsl_es_version(self, new): - self.__skiper.glsl_es_version = new + def require_version(self): + return self.__skiper.api_version def is_skip(self): """Skip this test if any of its feature requirements are unmet. @@ -217,32 +170,30 @@ class FastSkipMixin(object): class FastSkipDisabled(object): """A no-op version of FastSkip.""" - __slots__ = ['gl_required', 'gl_version', 'gles_version', 'glsl_version', - 'glsl_es_version'] + __slots__ = ['api', 'extensions', 'api_version', 'shader_version'] + + info = wflinfo.WflInfo() - def __init__(self, gl_required=None, gl_version=None, gles_version=None, - glsl_version=None, glsl_es_version=None): - self.gl_required = gl_required or set() - self.gl_version = gl_version - self.gles_version = gles_version - self.glsl_version = glsl_version - self.glsl_es_version = glsl_es_version + def __init__(self, api=None, extensions=None, api_version=None, + shader_version=None): + self.extensions = set() + self.api = api + self.api_version = api_version + self.shader_version = shader_version def test(self): pass class FastSkipMixinDisabled(object): - def __init__(self, command, gl_required=None, gl_version=None, - gles_version=None, glsl_version=None, glsl_es_version=None, - **kwargs): # pylint: disable=too-many-arguments + def __init__(self, command, api=None, extensions=None, api_version=None, + shader_version=None, **kwargs): # Tests that implement the FastSkipMixin expect to have these values # set, so just fill them in with the default values. - self.gl_required = set() - self.gl_version = None - self.gles_version = None - self.glsl_version = None - self.glsl_es_version = None + self.require_extensions = set() + self.require_shader = None + self.reqiure_version = None + self.require_api = None super(FastSkipMixinDisabled, self).__init__(command, **kwargs) diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py index 8ecc1808d..67d131577 100644 --- a/framework/test/shader_test.py +++ b/framework/test/shader_test.py @@ -47,17 +47,16 @@ class Parser(object): _is_gl = re.compile(r'GL (<|<=|=|>=|>) \d\.\d') _match_gl_version = re.compile( - r'^GL\s+(?P<es>ES)?\s*(?P<op>(<|<=|=|>=|>))\s*(?P<ver>\d\.\d)') + r'^GL\s+(?P<profile>(ES|CORE|COMPAT))?\s*(?P<op>(<|<=|=|>=|>))\s*(?P<ver>\d\.\d)') _match_glsl_version = re.compile( r'^GLSL\s+(?P<es>ES)?\s*(?P<op>(<|<=|=|>=|>))\s*(?P<ver>\d\.\d+)') def __init__(self, filename): self.filename = filename - self.gl_required = set() - self._gl_version = None - self._gles_version = None - self._glsl_version = None - self._glsl_es_version = None + self.extensions = set() + self.api_version = 0.0 + self.shader_version = 0.0 + self.api = None self.prog = None self.__op = None self.__sl_op = None @@ -88,39 +87,58 @@ class Parser(object): line = line.strip() if not (line.startswith('GL_MAX') or line.startswith('GL_NUM')): self.extensions.add(line) + if line == 'GL_ARB_compatibility': + assert self.api is None or self.api == 'compat' + self.api = 'compat' continue # Find any GLES requirements. - if not (self._gl_version or self._gles_version): + if not self.api_version: m = self._match_gl_version.match(line) if m: self.__op = m.group('op') - if m.group('es'): - self._gles_version = float(m.group('ver')) - else: - self._gl_version = float(m.group('ver')) + self.api_version = float(m.group('ver')) + if m.group('profile') == 'ES': + assert self.api is None or self.api == 'gles2' + self.api = 'gles2' + elif m.group('profile') == 'COMPAT': + assert self.api is None or self.api == 'compat' + self.api = 'compat' + elif self.api_version >= 3.1: + assert self.api is None or self.api == 'core' + self.api = 'core' continue - if not (self._glsl_version or self._glsl_es_version): + if not self.shader_version: # Find any GLSL requirements m = self._match_glsl_version.match(line) if m: self.__sl_op = m.group('op') + self.shader_version = float(m.group('ver')) if m.group('es'): - self._glsl_es_version = float(m.group('ver')) - else: - self._glsl_version = float(m.group('ver')) + assert self.api is None or self.api == 'gles2' + self.api = 'gles2' continue if line.startswith('['): + if not self.api: + # Because this is inferred rather than explicitly declared + # check this after al other requirements are parsed. It's + # possible that a test can declare glsl >= 1.30 and GL >= + # 4.0 + if self.shader_version < 1.4: + self.api = 'compat' + else: + self.api = 'core' break # Select the correct binary to run the test, but be as conservative as # possible by always selecting the lowest version that meets the # criteria. - if self._gles_version: + if self.api == 'gles2': if self.__op in ['<', '<='] or ( - self.__op in ['=', '>='] and self._gles_version < 3): + self.__op in ['=', '>='] and self.api_version is not None + and self.api_version < 3): self.prog = 'shader_runner_gles2' else: self.prog = 'shader_runner_gles3' @@ -155,17 +173,15 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest): """ - def __init__(self, command, gl_required=set(), gl_version=None, - gles_version=None, glsl_version=None, glsl_es_version=None, - **kwargs): + def __init__(self, command, api=None, extensions=set(), + shader_version=None, api_version=None, **kwargs): super(ShaderTest, self).__init__( command, run_concurrent=True, - gl_required=gl_required, - gl_version=gl_version, - gles_version=gles_version, - glsl_version=glsl_version, - glsl_es_version=glsl_es_version) + api=api, + extensions=extensions, + shader_version=shader_version, + api_version=api_version) @classmethod def new(cls, filename, installed_name=None): @@ -181,11 +197,10 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest): return cls( [parser.prog, installed_name or filename], run_concurrent=True, - gl_required=parser.gl_required, - gl_version=parser.gl_version, - gles_version=parser.gles_version, - glsl_version=parser.glsl_version, - glsl_es_version=parser.glsl_es_version) + api=parser.api, + extensions=parser.extensions, + shader_version=parser.shader_version, + api_version=parser.api_version) @PiglitBaseTest.command.getter def command(self): @@ -263,11 +278,10 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest): prog = parser.prog skips.append({ - 'gl_required': parser.gl_required, - 'gl_version': parser.gl_version, - 'glsl_version': parser.glsl_version, - 'gles_version': parser.gles_version, - 'glsl_es_version': parser.glsl_es_version, + 'extensions': parser.extensions, + 'api_version': parser.api_version, + 'shader_version': parser.shader_version, + 'api': parser.api, }) return cls(prog, installednames or filenames, subtests, skips) |