[Piglit] [PATCH 7/7] nv_fog_distance: Test interactions with GL_FOG_COORDINATE
Ian Romanick
idr at freedesktop.org
Thu Apr 26 21:29:16 UTC 2018
From: Ian Romanick <ian.d.romanick at intel.com>
The issuses section of GL_NV_fog_distance says:
How does this extension interact with the EXT_fog_coord extension?
If FOG_COORDINATE_SOURCE_EXT is set to FOG_COORDINATE_EXT, then
the fog distance mode is ignored. However, the fog distance
mode is used when the FOG_COORDINATE_SOURCE_EXT is set to
FRAGMENT_DEPTH_EXT. Essentially, when the EXT_fog_coord
functionality is enabled, the fog distance is supplied by the
user-supplied fog-coordinate so no automatic fog distance
computation is performed.
A heavily modified version of this test passes on a Geforce3 (NV20)
running NVIDIA's 71.86.15 drivers. These are the last drivers that
support NV10 through NV2x, and they are shipped in 2011.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
tests/all.py | 1 +
tests/spec/nv_fog_distance/CMakeLists.gl.txt | 1 +
tests/spec/nv_fog_distance/fog-coord.c | 104 +++++++++++++++++++++++++++
3 files changed, 106 insertions(+)
create mode 100644 tests/spec/nv_fog_distance/fog-coord.c
diff --git a/tests/all.py b/tests/all.py
index 70698ba10..febe3f79c 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3921,6 +3921,7 @@ with profile.test_list.group_manager(
g(['nv_fog_distance-simple-draw', 'radial'], 'simple draw - GL_EYE_RADIAL_NV')
g(['nv_fog_distance-simple-draw', 'eye-plane'], 'simple draw - GL_EYE_PLANE')
g(['nv_fog_distance-simple-draw', 'eye-plane-absolute'], 'simple draw - GL_EYE_PLANE_ABSOLUTE_NV')
+ g(['nv_fog_distance-fog-coord'], 'GL_FOG_COORDINATE interaction')
with profile.test_list.group_manager(
PiglitGLTest,
diff --git a/tests/spec/nv_fog_distance/CMakeLists.gl.txt b/tests/spec/nv_fog_distance/CMakeLists.gl.txt
index 6a4300e8c..e602a8b06 100644
--- a/tests/spec/nv_fog_distance/CMakeLists.gl.txt
+++ b/tests/spec/nv_fog_distance/CMakeLists.gl.txt
@@ -10,3 +10,4 @@ link_libraries (
piglit_add_executable (nv_fog_distance-coverage coverage.c)
piglit_add_executable (nv_fog_distance-simple-draw simple-draw.c)
+piglit_add_executable (nv_fog_distance-fog-coord fog-coord.c)
diff --git a/tests/spec/nv_fog_distance/fog-coord.c b/tests/spec/nv_fog_distance/fog-coord.c
new file mode 100644
index 000000000..cfbf3ab62
--- /dev/null
+++ b/tests/spec/nv_fog_distance/fog-coord.c
@@ -0,0 +1,104 @@
+/* Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/** @file fog-coord.c
+ * Verify that the GL_FOG_DISTANCE_MODE_NV setting is ignored when
+ * GL_FOG_COORDINATE_SOURCE is set to GL_FOG_COORDINATE.
+ *
+ * The issuses section of GL_NV_fog_distance says:
+ *
+ * How does this extension interact with the EXT_fog_coord extension?
+ *
+ * If FOG_COORDINATE_SOURCE_EXT is set to FOG_COORDINATE_EXT,
+ * then the fog distance mode is ignored. However, the fog
+ * distance mode is used when the FOG_COORDINATE_SOURCE_EXT is
+ * set to FRAGMENT_DEPTH_EXT. Essentially, when the EXT_fog_coord
+ * functionality is enabled, the fog distance is supplied by the
+ * user-supplied fog-coordinate so no automatic fog distance computation
+ * is performed.
+ */
+
+#include "piglit-util-gl.h"
+#include "minmax-test.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+ static const float fog_color[4] = { 0.0, 1.0, 0.0, 1.0 };
+ static const float draw_color[4] = { 1.0, 0.0, 0.0, 1.0 };
+ static const float mix_color[4] = { 0.5, 0.5, 0.0, 1.0 };
+ bool pass = true;
+
+ glViewport(0, 0, piglit_width, piglit_height);
+
+ /* Pick a Z value for the mesh. Select fog start and stop distances
+ * such that the middle of the window (the closest point) will have
+ * zero fog and the corners (the farthest points) will have full fog.
+ */
+ float z = 0.5;
+ float fog_start = z;
+ float fog_end = sqrt(1.0 + 1.0 + (z * z));
+
+ glFogf(GL_FOG_START, fog_start);
+ glFogf(GL_FOG_END, fog_end);
+ glFogfv(GL_FOG_COLOR, fog_color);
+
+ glFogCoordf((fog_end + fog_start) / 2.0);
+ glColor3fv(draw_color);
+
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex3f(-1.0, -1.0, z);
+ glVertex3f(-1.0, 1.0, z);
+ glVertex3f( 1.0, 1.0, z);
+ glVertex3f( 1.0, -1.0, z);
+ glEnd();
+
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+ pass = piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height,
+ mix_color);
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_NV_fog_distance");
+ piglit_require_extension("GL_EXT_fog_coord");
+ piglit_require_extension("GL_ARB_vertex_buffer_object");
+
+ glEnable(GL_FOG);
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+ glFogi(GL_FOG_COORD_SRC, GL_FOG_COORDINATE);
+ glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV);
+}
--
2.14.3
More information about the Piglit
mailing list