mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
tests: Load either 120 or 150 GLSL shaders depending on capabilities
Addresses part of #804
This commit is contained in:
parent
a111bb4442
commit
979f194f49
@ -1,4 +1,4 @@
|
||||
#version 130
|
||||
#version 150
|
||||
|
||||
// Uniform inputs
|
||||
uniform mat4 p3d_ModelViewProjectionMatrix;
|
||||
|
12
tests/display/glsl_bad_legacy.vert
Normal file
12
tests/display/glsl_bad_legacy.vert
Normal file
@ -0,0 +1,12 @@
|
||||
#version 120
|
||||
|
||||
// Uniform inputs
|
||||
uniform mat4 p3d_ModelViewProjectionMatrix;
|
||||
|
||||
// Vertex inputs
|
||||
attribute vec4 p3d_Vertex;
|
||||
|
||||
void main() {
|
||||
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
|
||||
does_not_exist = p3d_Vertex;
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
#version 130
|
||||
#version 150
|
||||
|
||||
#pragma include "glsl_include_inputs.vert"
|
||||
#pragma include "glsl_include_inputs.glsl"
|
||||
|
||||
// Vertex inputs
|
||||
in vec4 p3d_Vertex;
|
||||
|
||||
void main() {
|
||||
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
|
||||
|
@ -1,5 +1,2 @@
|
||||
// Uniform inputs
|
||||
uniform mat4 p3d_ModelViewProjectionMatrix;
|
||||
|
||||
// Vertex inputs
|
||||
in vec4 p3d_Vertex;
|
10
tests/display/glsl_include_legacy.vert
Normal file
10
tests/display/glsl_include_legacy.vert
Normal file
@ -0,0 +1,10 @@
|
||||
#version 120
|
||||
|
||||
#pragma include "glsl_include_inputs.glsl"
|
||||
|
||||
// Vertex inputs
|
||||
attribute vec4 p3d_Vertex;
|
||||
|
||||
void main() {
|
||||
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
#version 130
|
||||
#version 150
|
||||
|
||||
out vec4 p3d_FragColor;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(0, 0, 0, 1);
|
||||
p3d_FragColor = vec4(0, 0, 0, 1);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#version 130
|
||||
#version 150
|
||||
|
||||
// Uniform inputs
|
||||
uniform mat4 p3d_ModelViewProjectionMatrix;
|
||||
|
5
tests/display/glsl_simple_legacy.frag
Normal file
5
tests/display/glsl_simple_legacy.frag
Normal file
@ -0,0 +1,5 @@
|
||||
#version 120
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(0, 0, 0, 1);
|
||||
}
|
11
tests/display/glsl_simple_legacy.vert
Normal file
11
tests/display/glsl_simple_legacy.vert
Normal file
@ -0,0 +1,11 @@
|
||||
#version 120
|
||||
|
||||
// Uniform inputs
|
||||
uniform mat4 p3d_ModelViewProjectionMatrix;
|
||||
|
||||
// Vertex inputs
|
||||
attribute vec4 p3d_Vertex;
|
||||
|
||||
void main() {
|
||||
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
|
||||
}
|
@ -111,6 +111,9 @@ def run_glsl_compile_check(gsg, vert_path, frag_path, expect_fail=False):
|
||||
shader = core.Shader.load(core.Shader.SL_GLSL, vert_path, frag_path)
|
||||
assert shader is not None
|
||||
|
||||
if not gsg.supports_glsl:
|
||||
expect_fail = True
|
||||
|
||||
shader.prepare_now(gsg.prepared_objects, gsg)
|
||||
assert shader.is_prepared(gsg.prepared_objects)
|
||||
if expect_fail:
|
||||
@ -468,20 +471,29 @@ def test_glsl_write_extract_image_buffer(gsg):
|
||||
|
||||
def test_glsl_compile_error(gsg):
|
||||
"""Test getting compile errors from bad shaders"""
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_bad.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple.frag')
|
||||
suffix = ''
|
||||
if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50):
|
||||
suffix = '_legacy'
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_bad' + suffix + '.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag')
|
||||
run_glsl_compile_check(gsg, vert_path, frag_path, expect_fail=True)
|
||||
|
||||
|
||||
def test_glsl_from_file(gsg):
|
||||
"""Test compiling GLSL shaders from files"""
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_simple.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple.frag')
|
||||
suffix = ''
|
||||
if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50):
|
||||
suffix = '_legacy'
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag')
|
||||
run_glsl_compile_check(gsg, vert_path, frag_path)
|
||||
|
||||
|
||||
def test_glsl_includes(gsg):
|
||||
"""Test preprocessing includes in GLSL shaders"""
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_include.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple.frag')
|
||||
suffix = ''
|
||||
if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50):
|
||||
suffix = '_legacy'
|
||||
vert_path = core.Filename(SHADERS_DIR, 'glsl_include' + suffix + '.vert')
|
||||
frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag')
|
||||
run_glsl_compile_check(gsg, vert_path, frag_path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user