[Piglit] [PATCH 1/5] Basic tests of fast color clear functionality on i965/gen7+.

Paul Berry stereotype441 at gmail.com
Wed May 22 10:20:23 PDT 2013


Fast color clears are a hardware feature in i965/gen7+ which allows
the memory writes associated with clearing a color buffer to be
deferred until the buffer is later written to or read from; in most
cases this allows the clear writes to be write-combined with later
rendering operations.

For fast color clears to work correctly, the driver must maintain a
state machine for each buffer to indicate whether there are deferred
clears pending, and if so what the clear value was.  This patch
introduces simple shader_runner tests to validate corner cases of that
state machine.
---
 tests/all.tests                                    |   5 +
 tests/fast_color_clear/all-colors.shader_test      | 140 +++++++++++++++++++++
 .../fast-slow-clear-interaction.shader_test        |  39 ++++++
 .../non-redundant-clear.shader_test                |  46 +++++++
 tests/fast_color_clear/redundant-clear.shader_test |  50 ++++++++
 5 files changed, 280 insertions(+)
 create mode 100644 tests/fast_color_clear/all-colors.shader_test
 create mode 100644 tests/fast_color_clear/fast-slow-clear-interaction.shader_test
 create mode 100644 tests/fast_color_clear/non-redundant-clear.shader_test
 create mode 100644 tests/fast_color_clear/redundant-clear.shader_test

diff --git a/tests/all.tests b/tests/all.tests
index 0f80e0b..267e769 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2326,6 +2326,10 @@ add_plain_test(hiz, 'hiz-stencil-test-fbo-d24s8')
 add_plain_test(hiz, 'hiz-stencil-test-window-depth0')
 add_plain_test(hiz, 'hiz-stencil-test-window-depth1')
 
+fast_color_clear = Group()
+add_shader_test_dir(fast_color_clear, testsDir + '/fast_color_clear',
+                    recursive=True)
+
 asmparsertest = Group()
 def add_asmparsertest(group, shader):
 	test = PlainExecTest(['asmparsertest', '-auto', group, testsDir + '/asmparsertest/shaders/' + group + '/' + shader])
@@ -2852,6 +2856,7 @@ add_shader_test_dir(spec, os.path.join(generatedTestDir, 'spec'),
 import_glsl_parser_tests(profile.tests, generatedTestDir, ['spec'])
 
 profile.tests['hiz'] = hiz
+profile.tests['fast_color_clear'] = fast_color_clear
 profile.tests['glean'] = glean
 profile.tests['glslparsertest'] = glslparsertest
 profile.tests['asmparsertest'] = asmparsertest
diff --git a/tests/fast_color_clear/all-colors.shader_test b/tests/fast_color_clear/all-colors.shader_test
new file mode 100644
index 0000000..f4b8e87
--- /dev/null
+++ b/tests/fast_color_clear/all-colors.shader_test
@@ -0,0 +1,140 @@
+# Test the "fast clear" functionality of i965/gen7+ for all supported
+# clear colors.
+#
+# Fast clear functionality on i965/gen7+ operates by deferring the
+# memory writes that would normally be done during a buffer clear so
+# that they happen either during rendering or at the time buffer data
+# is read (e.g. by glReadPixels).  It supports clearing to any color
+# where each component is either 0.0 or 1.0.
+#
+# This test validates each supported clear color by (a) setting the
+# clear color, (b) doing a clear, (c) making a draw call that touches
+# a small number of pixels and outputs the same color, and then (d)
+# reading the entire buffer to verify that it contains the desired
+# color.
+#
+# The purpose of step (c) is to ensure that some writes are deferred
+# to rendering time and others are deferred until glReadPixels time,
+# so that we verify that correct data is written in both
+# circumstances.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+attribute vec4 pos;
+
+void main()
+{
+  gl_Position = pos;
+}
+
+[fragment shader]
+uniform vec4 color;
+
+void main()
+{
+  gl_FragColor = color;
+}
+
+[vertex data]
+pos/float/4
+0.0 0.0 0.0 1.0
+1.0 1.0 0.0 1.0
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+uniform vec4 color 0.0 0.0 0.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 0.0 0.0 0.0
+
+clear color 0.0 0.0 0.0 1.0
+clear
+uniform vec4 color 0.0 0.0 0.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 0.0 0.0 1.0
+
+clear color 0.0 0.0 1.0 0.0
+clear
+uniform vec4 color 0.0 0.0 1.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 0.0 1.0 0.0
+
+clear color 0.0 0.0 1.0 1.0
+clear
+uniform vec4 color 0.0 0.0 1.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 0.0 1.0 1.0
+
+clear color 0.0 1.0 0.0 0.0
+clear
+uniform vec4 color 0.0 1.0 0.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 1.0 0.0 0.0
+
+clear color 0.0 1.0 0.0 1.0
+clear
+uniform vec4 color 0.0 1.0 0.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+clear color 0.0 1.0 1.0 0.0
+clear
+uniform vec4 color 0.0 1.0 1.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 1.0 1.0 0.0
+
+clear color 0.0 1.0 1.0 1.0
+clear
+uniform vec4 color 0.0 1.0 1.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 1.0 1.0 1.0
+
+clear color 1.0 0.0 0.0 0.0
+clear
+uniform vec4 color 1.0 0.0 0.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 0.0 0.0 0.0
+
+clear color 1.0 0.0 0.0 1.0
+clear
+uniform vec4 color 1.0 0.0 0.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 0.0 0.0 1.0
+
+clear color 1.0 0.0 1.0 0.0
+clear
+uniform vec4 color 1.0 0.0 1.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 0.0 1.0 0.0
+
+clear color 1.0 0.0 1.0 1.0
+clear
+uniform vec4 color 1.0 0.0 1.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 0.0 1.0 1.0
+
+clear color 1.0 1.0 0.0 0.0
+clear
+uniform vec4 color 1.0 1.0 0.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 1.0 0.0 0.0
+
+clear color 1.0 1.0 0.0 1.0
+clear
+uniform vec4 color 1.0 1.0 0.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 1.0 0.0 1.0
+
+clear color 1.0 1.0 1.0 0.0
+clear
+uniform vec4 color 1.0 1.0 1.0 0.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 1.0 1.0 0.0
+
+clear color 1.0 1.0 1.0 1.0
+clear
+uniform vec4 color 1.0 1.0 1.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 1.0 1.0 1.0 1.0
diff --git a/tests/fast_color_clear/fast-slow-clear-interaction.shader_test b/tests/fast_color_clear/fast-slow-clear-interaction.shader_test
new file mode 100644
index 0000000..e3a724c
--- /dev/null
+++ b/tests/fast_color_clear/fast-slow-clear-interaction.shader_test
@@ -0,0 +1,39 @@
+# Test the "fast clear" functionality of i965/gen7+ when two clears
+# are done to the same buffer, but with drawing in between (so the
+# second clear is not redundant).
+#
+# Fast clear functionality on i965/gen7+ operates by deferring the
+# memory writes that would normally be done during a buffer clear so
+# that they happen either during rendering or at the time buffer data
+# is read (e.g. by glReadPixels).  If two fast clears appear in a row,
+# the second clear can be elided.  But if other rendering (in this
+# case a slow clear) occurrs between the two fast clears, the second
+# fast clear is necessary, since some of the first fast clear's writes
+# may already have been performed.
+#
+# In this test, we accomplish the slow clear by clearing to a color
+# which is not supported by fast clear (0.5, 0.0, 0.0, 1.0).
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+void main()
+{
+  gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+  gl_FragColor = vec4(0.0);
+}
+
+[test]
+clear color 0.0 1.0 0.0 1.0
+clear
+clear color 0.5 0.0 0.0 1.0
+clear
+clear color 0.0 1.0 0.0 1.0
+clear
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/fast_color_clear/non-redundant-clear.shader_test b/tests/fast_color_clear/non-redundant-clear.shader_test
new file mode 100644
index 0000000..208091f
--- /dev/null
+++ b/tests/fast_color_clear/non-redundant-clear.shader_test
@@ -0,0 +1,46 @@
+# Test the "fast clear" functionality of i965/gen7+ when two clears
+# are done to the same buffer, but with drawing in between (so the
+# second clear is not redundant).
+#
+# Fast clear functionality on i965/gen7+ operates by deferring the
+# memory writes that would normally be done during a buffer clear so
+# that they happen either during rendering or at the time buffer data
+# is read (e.g. by glReadPixels).  If two fast clears appear in a row,
+# the second clear can be elided.  But if rendering occurrs between
+# the two fast clears, the second clear is necessary, since some of
+# the first clear's writes may already have been performed.
+#
+# This test verifies that in the case where two fast clears are
+# separated by rendering, the second clear is actually performed.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+attribute vec4 pos;
+
+void main()
+{
+  gl_Position = pos;
+}
+
+[fragment shader]
+uniform vec4 color;
+
+void main()
+{
+  gl_FragColor = color;
+}
+
+[vertex data]
+pos/float/4
+0.0 0.0 0.0 1.0
+1.0 1.0 0.0 1.0
+
+[test]
+clear color 0.0 1.0 0.0 1.0
+clear
+uniform vec4 color 1.0 0.0 0.0 1.0
+draw arrays GL_LINES 0 2
+clear
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/fast_color_clear/redundant-clear.shader_test b/tests/fast_color_clear/redundant-clear.shader_test
new file mode 100644
index 0000000..ade0973
--- /dev/null
+++ b/tests/fast_color_clear/redundant-clear.shader_test
@@ -0,0 +1,50 @@
+# Test the "fast clear" functionality of i965/gen7+ when a redundant
+# clear is done, but to a different clear color.
+#
+# Fast clear functionality on i965/gen7+ operates by deferring the
+# memory writes that would normally be done during a buffer clear so
+# that they happen either during rendering or at the time buffer data
+# is read (e.g. by glReadPixels).  If two fast clears appear in a row,
+# the second clear can be elided (even if it clears to a different
+# color, since none of the color writes have occurred yet).
+#
+# This test verifies that if two fast clears are performed in a row,
+# the color that takes effect is the color from the second clear.  As
+# with fast-clear-all-colors.shader_test, we also make a draw call
+# that touches a small number of pixels and outputs the same color.
+# This is to ensure that some writes are deferred to rendering time
+# and others are deferred until glReadPixels time, so that we verify
+# that correct data is written in both circumstances.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+attribute vec4 pos;
+
+void main()
+{
+  gl_Position = pos;
+}
+
+[fragment shader]
+uniform vec4 color;
+
+void main()
+{
+  gl_FragColor = color;
+}
+
+[vertex data]
+pos/float/4
+0.0 0.0 0.0 1.0
+1.0 1.0 0.0 1.0
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+clear color 0.0 1.0 0.0 1.0
+clear
+uniform vec4 color 0.0 1.0 0.0 1.0
+draw arrays GL_LINES 0 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.8.2.3



More information about the Piglit mailing list