From 41f7e5b6a1ec1bb404402f240b7b69030fca11d0 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Fri, 13 Jan 2017 16:41:27 +0100 Subject: [PATCH] Add ability to have legacy-specific tests. --- .../shaders/legacy/vert/transpose.legacy.vert | 22 +++++++++++++++++++ shaders/legacy/vert/transpose.legacy.vert | 20 +++++++++++++++++ test_shaders.py | 16 ++++++++++---- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 reference/shaders/legacy/vert/transpose.legacy.vert create mode 100644 shaders/legacy/vert/transpose.legacy.vert diff --git a/reference/shaders/legacy/vert/transpose.legacy.vert b/reference/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 00000000..c73d1a11 --- /dev/null +++ b/reference/shaders/legacy/vert/transpose.legacy.vert @@ -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; +} + diff --git a/shaders/legacy/vert/transpose.legacy.vert b/shaders/legacy/vert/transpose.legacy.vert new file mode 100644 index 00000000..84f61826 --- /dev/null +++ b/shaders/legacy/vert/transpose.legacy.vert @@ -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; +} + diff --git a/test_shaders.py b/test_shaders.py index daac82a6..701dcad8 100755 --- a/test_shaders.py +++ b/test_shaders.py @@ -66,7 +66,7 @@ def validate_shader(shader, vulkan): else: 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() glsl_f, glsl_path = tempfile.mkstemp(suffix = os.path.basename(shader)) os.close(spirv_f) @@ -84,11 +84,15 @@ def cross_compile(shader, vulkan, spirv, eliminate, invalid_spirv): if not invalid_spirv: subprocess.check_call(['spirv-val', spirv_path]) + legacy_cmd = [] + if is_legacy: + legacy_cmd = ['--version', '100', '--es'] + spirv_cross_path = './spirv-cross' 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: - 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. if (not ('nocompat' in glsl_path)) and (not spirv): @@ -171,6 +175,9 @@ def shader_is_spirv(shader): def shader_is_invalid_spirv(shader): return '.invalid.' in shader +def shader_is_legacy(shader): + return '.legacy.' in shader + def test_shader(stats, shader, update, keep): joined_path = os.path.join(shader[0], 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]) is_spirv = shader_is_spirv(shader[1]) invalid_spirv = shader_is_invalid_spirv(shader[1]) + is_legacy = shader_is_legacy(shader[1]) 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. if stats and (not vulkan) and (not is_spirv) and (not desktop):