def main(): """Main function.""" for ext, ver in EXTENSIONS: # Lower ext in the path name, but keep it capitalized for the generated # tests path = os.path.join('spec', ext[3:].lower(), 'preprocessor') utils.safe_makedirs(path) for stage in ['vert', 'frag', 'geom', 'tesc', 'tese', 'comp']: # Calculate the minimum version for the stage, with extensions. # This makes the maximum number of tests run on the widest swath of # hardware. version, extra_ext = glsl.MinVersion.for_stage_with_ext(stage, ver) if extra_ext is not None: extra_extensions = [extra_ext] else: extra_extensions = [] if not version.is_es: # if the actual version is less than 140 make a compat test and # a core test, otherwise just make a core test if version < 140: _gen_tests(ext, version, stage, path, 'compat', extra_extensions) _gen_tests(ext, glsl.Version('140'), stage, path, 'core', extra_extensions) else: _gen_tests(ext, version, stage, path, 'core', extra_extensions) else: _gen_tests(ext, version, stage, path, 'es', extra_extensions)
def __init__(self, mode, array_dim, matrix_dim, index_value, col, value_type, glsl_version): # pylint: disable=too-many-arguments assert array_dim in [0, 3] assert matrix_dim in [2, 3, 4] self.mode = mode self.array_dim = array_dim self.matrix_dim = matrix_dim self.index_value = index_value self.col = '[{}]'.format(col) self.value_type = value_type self.version = glsl.Version(glsl_version)
def test_opengles_comp(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: TES (OpenGL ES)""" self._test('comp', glsl.Version('320 es'), (glsl.Version('320 es'), None)) self._test('comp', glsl.Version('100'), (glsl.Version('310 es'), None)) self._test('comp', glsl.Version('310 es'), (glsl.Version('310 es'), None))
def test_opengl_tese(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: TES (OpenGL)""" self._test('tese', glsl.Version('410'), (glsl.Version('410'), None)) self._test('tese', glsl.Version('140'), (glsl.Version('140'), 'GL_ARB_tessellation_shader')) self._test('tese', glsl.Version('110'), (glsl.Version('140'), 'GL_ARB_tessellation_shader'))
def test_opengl_comp(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: CS (OpenGL)""" self._test('comp', glsl.Version('430'), (glsl.Version('430'), None)) self._test('comp', glsl.Version('140'), (glsl.Version('140'), 'GL_ARB_compute_shader')) self._test('comp', glsl.Version('110'), (glsl.Version('140'), 'GL_ARB_compute_shader'))
def test_opengles_geom(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: GS (OpenGL ES)""" self._test('geom', glsl.Version('100'), (glsl.Version('310 es'), 'GL_OES_geometry_shader')) self._test('geom', glsl.Version('310 es'), (glsl.Version('310 es'), 'GL_OES_geometry_shader')) self._test('geom', glsl.Version('320 es'), (glsl.Version('320 es'), None))
def test_opengles_tese(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: TES (OpenGL ES)""" self._test('tese', glsl.Version('320 es'), (glsl.Version('320 es'), None)) self._test('tese', glsl.Version('310 es'), (glsl.Version('310 es'), 'GL_OES_tessellation_shader')) self._test('tese', glsl.Version('100'), (glsl.Version('310 es'), 'GL_OES_tessellation_shader'))
def test_opengl_geom(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: GS (OpenGL)""" self._test('geom', glsl.Version('330'), (glsl.Version('330'), None)) self._test('geom', glsl.Version('110'), (glsl.Version('150'), None)) self._test('geom', glsl.Version('150'), (glsl.Version('150'), None))
def test_compare_glsl_to_int(op, first, second): """Test GLSLVersion <cmp> GLSLVersion.""" actual = op(glsl.Version(first), int(second)) assert actual == op(int(first), int(second))
def test_compare_glsl_to_float(op, first, second): """Test GLSLVersion <cmp> GLSLVersion.""" actual = op(glsl.Version(first), float(second) / 100) expected = op(float(first), float(second)) assert actual == expected
def test_GLSLESVersion_str(): """generated_tests.modules.glsl.GLSLESVersion: str()""" assert six.text_type(glsl.Version('100')) == '100'
def test_opengl_tese(self): """generated_tests.modules.glsl.MinVersion.for_stage: TES (OpenGL)""" self._test('tese', glsl.Version('410'), glsl.Version('410')) self._test('tese', glsl.Version('400'), glsl.Version('400')) self._test('tese', glsl.Version('140'), glsl.Version('400'))
def test_opengl_vert(self): """generated_tests.modules.glsl.MinVersion.for_stage: VS (OpenGL)""" self._test('vert', glsl.Version('150'), glsl.Version('150')) self._test('vert', glsl.Version('110'), glsl.Version('110'))
def test_GLSLESVersion_print_float_es(): """generated_tests.modules.glsl.GLSLESVersion: print_float() (es version)""" assert glsl.Version('300 es').print_float() == '3.00 es'
def test_GLSLESVersion_print_float(): """generated_tests.modules.glsl.GLSLESVersion: print_float()""" assert glsl.Version('100').print_float() == '1.00'
def test_GLSLESVersion_float(): """generated_tests.modules.glsl.GLSLESVersion: float()""" assert float(glsl.Version('100')) == 1.00
def test_GLSLESVersion_int(): """generated_tests.modules.glsl.GLSLESVersion: int()""" assert int(glsl.Version('100')) == 100
def test_opengles_vert(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: VS (OpenGL ES)""" self._test('vert', glsl.Version('300 es'), (glsl.Version('300 es'), None)) self._test('vert', glsl.Version('100'), (glsl.Version('100'), None))
def test_factory_glsles(): """generated_tests.modules.glsl.Version: provides a GLSLESVersion.""" test = glsl.Version('100') assert isinstance(test, glsl.GLSLESVersion)
def test_compare_glsles_to_glsles(op, first, second): """Test GLSLESVersion <cmp> GLSLESVersion.""" actual = op(glsl.Version(first), glsl.Version(second)) assert actual == op(int(first[:3]), int(second[:3]))
def test_opengl_comp(self): """generated_tests.modules.glsl.MinVersion.for_stage: CS (OpenGL)""" self._test('comp', glsl.Version('440'), glsl.Version('440')) self._test('comp', glsl.Version('430'), glsl.Version('430')) self._test('comp', glsl.Version('140'), glsl.Version('430'))
def test_compare_glsles_to_float(op, first, second): """Test GLSLESVersion <cmp> GLSLESVersion.""" actual = op(glsl.Version(first), float(second[:3]) / 100) assert actual == op(float(first[:3]), float(second[:3]))
def test_factory_cache(): """generated_tests.modules.glsl.Version: caches objects.""" test1 = glsl.Version('100') test2 = glsl.Version('100') assert test1 is test2
def test_opengles_frag(self): """generated_tests.modules.glsl.MinVersion.for_stage: FS (OpenGL ES)""" self._test('frag', glsl.Version('300 es'), glsl.Version('300 es')) self._test('frag', glsl.Version('100'), glsl.Version('100'))
("GL_OES_texture_storage_multisample_2d_array", "310 es"), ("GL_OES_blend_func_extended", "100"), ("GL_OES_shader_image_atomic", "310 es"), ("GL_OES_shader_io_blocks", "310 es"), ("GL_EXT_shader_io_blocks", "310 es"), ("GL_OES_geometry_shader", "310 es"), ("GL_EXT_geometry_shader", "310 es"), ("GL_OES_geometry_point_size", "310 es"), ("GL_EXT_geometry_point_size", "310 es"), ("GL_EXT_gpu_shader5", "310 es"), ("GL_OES_gpu_shader5", "310 es"), ("GL_EXT_texture_buffer", "310 es"), ("GL_OES_texture_buffer", "310 es"), ("GL_EXT_clip_cull_distance", "300 es"), ] EXTENSIONS = [(n, glsl.Version(v)) for n, v in EXTENSIONS] def _gen_tests(ext, version, stage, path, extra_name, extra_extensions): """Generate the actual test files. This generates both a disabled test for both disabled and enabled configurations. Arguments: ext -- the extension to be tested version -- the minimum required version stage -- the shader stage to test path -- the path to put the test in, without the test name extra_name -- An extra string to put in the test name. extra_extensions -- Any extra extensions requires.
def test_opengles_tese(self): """generated_tests.modules.glsl.MinVersion.for_stage: TES (OpenGL ES)""" self._test('tese', glsl.Version('320 es'), glsl.Version('320 es')) self._test('tese', glsl.Version('100'), glsl.Version('320 es'))
def test_opengl_frag(self): """generated_tests.modules.glsl.MinVersion.for_stage_with_ext: FS (OpenGL)""" self._test('frag', glsl.Version('150'), (glsl.Version('150'), None)) self._test('frag', glsl.Version('110'), (glsl.Version('110'), None))
def test_glsles_glsl_exception(): """generated_tests.modules.glsl: GLSLESVersion <cmp> GLSLVersion.""" return glsl.Version('100') < glsl.Version('110')