Add ability to have legacy-specific tests.

This commit is contained in:
Hans-Kristian Arntzen 2017-01-13 16:41:27 +01:00
Родитель 27f4f75513
Коммит 41f7e5b6a1
3 изменённых файлов: 54 добавлений и 4 удалений

Просмотреть файл

@ -0,0 +1,22 @@
#version 100
struct Buffer
{
mat4 MVPRowMajor;
mat4 MVPColMajor;
mat4 M;
};
uniform Buffer _13;
attribute vec4 Position;
void main()
{
vec4 c0 = _13.M * (Position * _13.MVPRowMajor);
vec4 c1 = _13.M * (_13.MVPColMajor * Position);
vec4 c2 = _13.M * (_13.MVPRowMajor * Position);
vec4 c3 = _13.M * (Position * _13.MVPColMajor);
gl_Position = ((c0 + c1) + c2) + c3;
}

Просмотреть файл

@ -0,0 +1,20 @@
#version 310 es
uniform Buffer
{
layout(row_major) mat4 MVPRowMajor;
layout(column_major) mat4 MVPColMajor;
mat4 M;
};
layout(location = 0) in vec4 Position;
void main()
{
vec4 c0 = M * (MVPRowMajor * Position);
vec4 c1 = M * (MVPColMajor * Position);
vec4 c2 = M * (Position * MVPRowMajor);
vec4 c3 = M * (Position * MVPColMajor);
gl_Position = c0 + c1 + c2 + c3;
}

Просмотреть файл

@ -66,7 +66,7 @@ def validate_shader(shader, vulkan):
else: else:
subprocess.check_call(['glslangValidator', shader]) subprocess.check_call(['glslangValidator', shader])
def cross_compile(shader, vulkan, spirv, eliminate, invalid_spirv): def cross_compile(shader, vulkan, spirv, eliminate, invalid_spirv, is_legacy):
spirv_f, spirv_path = tempfile.mkstemp() spirv_f, spirv_path = tempfile.mkstemp()
glsl_f, glsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) glsl_f, glsl_path = tempfile.mkstemp(suffix = os.path.basename(shader))
os.close(spirv_f) os.close(spirv_f)
@ -84,11 +84,15 @@ def cross_compile(shader, vulkan, spirv, eliminate, invalid_spirv):
if not invalid_spirv: if not invalid_spirv:
subprocess.check_call(['spirv-val', spirv_path]) subprocess.check_call(['spirv-val', spirv_path])
legacy_cmd = []
if is_legacy:
legacy_cmd = ['--version', '100', '--es']
spirv_cross_path = './spirv-cross' spirv_cross_path = './spirv-cross'
if eliminate: if eliminate:
subprocess.check_call([spirv_cross_path, '--remove-unused-variables', '--entry', 'main', '--output', glsl_path, spirv_path]) subprocess.check_call([spirv_cross_path, '--remove-unused-variables', '--entry', 'main', '--output', glsl_path, spirv_path] + legacy_cmd)
else: else:
subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', glsl_path, spirv_path]) subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', glsl_path, spirv_path] + legacy_cmd)
# A shader might not be possible to make valid GLSL from, skip validation for this case. # A shader might not be possible to make valid GLSL from, skip validation for this case.
if (not ('nocompat' in glsl_path)) and (not spirv): if (not ('nocompat' in glsl_path)) and (not spirv):
@ -171,6 +175,9 @@ def shader_is_spirv(shader):
def shader_is_invalid_spirv(shader): def shader_is_invalid_spirv(shader):
return '.invalid.' in shader return '.invalid.' in shader
def shader_is_legacy(shader):
return '.legacy.' in shader
def test_shader(stats, shader, update, keep): def test_shader(stats, shader, update, keep):
joined_path = os.path.join(shader[0], shader[1]) joined_path = os.path.join(shader[0], shader[1])
vulkan = shader_is_vulkan(shader[1]) vulkan = shader_is_vulkan(shader[1])
@ -178,9 +185,10 @@ def test_shader(stats, shader, update, keep):
eliminate = shader_is_eliminate_dead_variables(shader[1]) eliminate = shader_is_eliminate_dead_variables(shader[1])
is_spirv = shader_is_spirv(shader[1]) is_spirv = shader_is_spirv(shader[1])
invalid_spirv = shader_is_invalid_spirv(shader[1]) invalid_spirv = shader_is_invalid_spirv(shader[1])
is_legacy = shader_is_legacy(shader[1])
print('Testing shader:', joined_path) print('Testing shader:', joined_path)
spirv, glsl, vulkan_glsl = cross_compile(joined_path, vulkan, is_spirv, eliminate, invalid_spirv) spirv, glsl, vulkan_glsl = cross_compile(joined_path, vulkan, is_spirv, eliminate, invalid_spirv, is_legacy)
# Only test GLSL stats if we have a shader following GL semantics. # Only test GLSL stats if we have a shader following GL semantics.
if stats and (not vulkan) and (not is_spirv) and (not desktop): if stats and (not vulkan) and (not is_spirv) and (not desktop):