[Piglit] [PATCH 2/2] ext_color_buffer_float: check fp32 blend enforcement
Tapani Pälli
tapani.palli at intel.com
Wed Feb 13 12:44:44 UTC 2019
On 2/13/19 9:15 AM, Tapani Pälli wrote:
>
>
> On 2/13/19 5:40 AM, Ilia Mirkin wrote:
>> Without EXT_float_blend, fp32 blending should be disallowed. Ensure that
>> this is the case. If it is supported, ensure that blending works as
>> expected.
>>
>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>> tests/opengl.py | 5 +
>> tests/spec/CMakeLists.txt | 1 +
>> .../CMakeLists.gles3.txt | 3 +
>> .../ext_color_buffer_float/CMakeLists.txt | 1 +
>> tests/spec/ext_color_buffer_float/draw.c | 150 ++++++++++++++++++
>> 5 files changed, 160 insertions(+)
>> create mode 100644
>> tests/spec/ext_color_buffer_float/CMakeLists.gles3.txt
>> create mode 100644 tests/spec/ext_color_buffer_float/CMakeLists.txt
>> create mode 100644 tests/spec/ext_color_buffer_float/draw.c
>>
>> diff --git a/tests/opengl.py b/tests/opengl.py
>> index 97dfbf984..fecb5e69d 100644
>> --- a/tests/opengl.py
>> +++ b/tests/opengl.py
>> @@ -4955,5 +4955,10 @@ with profile.test_list.group_manager(
>> grouptools.join('spec', 'NV_image_formats')) as g:
>> g(['nv_image_formats-gles3'])
>> +with profile.test_list.group_manager(
>> + PiglitGLTest,
>> + grouptools.join('spec', 'EXT_color_buffer_float')) as g:
>> + g(['ext_color_buffer_float-draw_gles3'])
>> +
>> if platform.system() is 'Windows':
>> profile.filters.append(lambda p, _: not p.startswith('glx'))
>> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
>> index 251e9aaa8..e10684442 100644
>> --- a/tests/spec/CMakeLists.txt
>> +++ b/tests/spec/CMakeLists.txt
>> @@ -186,3 +186,4 @@ add_subdirectory (ext_disjoint_timer_query)
>> add_subdirectory (intel_blackhole_render)
>> add_subdirectory (ext_texture_norm16)
>> add_subdirectory (ext_render_snorm)
>> +add_subdirectory (ext_color_buffer_float)
>> diff --git a/tests/spec/ext_color_buffer_float/CMakeLists.gles3.txt
>> b/tests/spec/ext_color_buffer_float/CMakeLists.gles3.txt
>> new file mode 100644
>> index 000000000..da89f5c04
>> --- /dev/null
>> +++ b/tests/spec/ext_color_buffer_float/CMakeLists.gles3.txt
>> @@ -0,0 +1,3 @@
>> +link_libraries(piglitutil_${piglit_target_api})
>> +
>> +piglit_add_executable (ext_color_buffer_float-draw_gles3 draw.c)
>> diff --git a/tests/spec/ext_color_buffer_float/CMakeLists.txt
>> b/tests/spec/ext_color_buffer_float/CMakeLists.txt
>> new file mode 100644
>> index 000000000..144a306f4
>> --- /dev/null
>> +++ b/tests/spec/ext_color_buffer_float/CMakeLists.txt
>> @@ -0,0 +1 @@
>> +piglit_include_target_api()
>> diff --git a/tests/spec/ext_color_buffer_float/draw.c
>> b/tests/spec/ext_color_buffer_float/draw.c
>> new file mode 100644
>> index 000000000..853fdb082
>> --- /dev/null
>> +++ b/tests/spec/ext_color_buffer_float/draw.c
>> @@ -0,0 +1,150 @@
>> +/*
>> + * Copyright (C) 2019 Ilia Mirkin
>> + *
>> + * 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 draw.c
>> + *
>> + * Test that GL_EXT_color_buffer_float's blending restriction is
>> + * properly respected. Either the implementation rejects draws with
>> + * FP32 blending, or it exposes GL_EXT_float_blend.
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> + config.supports_gl_es_version = 30;
>
> glEnablei and glDisablei is only available with ES 3.2
Nevermind, I see you handle it below separately when
GL_OES_draw_buffers_indexed is supported ...
This test LGTM!
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
>> + config.window_visual = PIGLIT_GL_VISUAL_RGB |
>> PIGLIT_GL_VISUAL_DOUBLE;
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +#define SIZE 128
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> + return PIGLIT_SKIP; /* Never reached */
>> +}
>> +
>> +static void
>> +check_draw_success()
>> +{
>> + static const float green[4] = {0, 1, 0, 1};
>> + if (!piglit_check_gl_error(GL_NO_ERROR)) {
>> + printf("FAIL: Basic drawing\n");
>> + piglit_report_result(PIGLIT_FAIL);
>> + }
>> +
>> + if (!piglit_probe_rect_rgba(0, 0, SIZE, SIZE, green)) {
>> + printf("FAIL: Basic draw color\n");
>> + piglit_report_result(PIGLIT_FAIL);
>> + }
>> +
>> + glClearColor(0.2, 0.2, 0.2, 0.2);
>> + glClear(GL_COLOR_BUFFER_BIT);
>> +}
>> +
>> +static void
>> +check_blend(bool float_blend)
>> +{
>> + if (float_blend) {
>> + check_draw_success();
>> + } else if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
>> + printf("FAIL: Unexpected draw success in presence of blend.\n");
>> + piglit_report_result(PIGLIT_FAIL);
>> + }
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + GLint prog;
>> + GLuint fb, rb[2];
>> + GLenum ret;
>> + bool float_blend, indexed;
>> +
>> + piglit_require_extension("GL_EXT_color_buffer_float");
>> + float_blend = piglit_is_extension_supported("GL_EXT_float_blend");
>> + indexed =
>> piglit_is_extension_supported("GL_OES_draw_buffers_indexed");
>> +
>> + prog = piglit_build_simple_program(
>> + "#version 300 es\n"
>> + "in vec4 piglit_vertex;\n"
>> + "void main() { gl_Position = piglit_vertex; }\n",
>> +
>> + "#version 300 es\n"
>> + "precision highp float;\n"
>> + "out vec4 color;\n"
>> + "out vec4 color2;\n"
>> + "void main() { color2 = color = vec4(0, 1, 0, 1); }\n");
>> + glUseProgram(prog);
>> +
>> + glGenRenderbuffers(2, rb);
>> + glBindRenderbuffer(GL_RENDERBUFFER, rb[0]);
>> + glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, SIZE, SIZE);
>> + glBindRenderbuffer(GL_RENDERBUFFER, rb[1]);
>> + glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA16F, SIZE, SIZE);
>> +
>> + glGenFramebuffers(1, &fb);
>> + glBindFramebuffer(GL_FRAMEBUFFER, fb);
>> + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
>> GL_RENDERBUFFER, rb[0]);
>> + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
>> GL_RENDERBUFFER, rb[1]);
>> +
>> + ret = glCheckFramebufferStatus(GL_FRAMEBUFFER);
>> + if (ret != GL_FRAMEBUFFER_COMPLETE) {
>> + printf("FAIL: Framebuffer incomplete\n");
>> + piglit_report_result(PIGLIT_FAIL);
>> + }
>> +
>> + glViewport(0, 0, SIZE, SIZE);
>> +
>> + piglit_draw_rect(-1, -1, 2, 2);
>> + check_draw_success();
>> +
>> + if (!indexed) {
>> + glEnable(GL_BLEND);
>> + piglit_draw_rect(-1, -1, 2, 2);
>> +
>> + check_blend(float_blend);
>> + piglit_report_result(PIGLIT_PASS);
>> + }
>> +
>> + /* RT0 = GL_RGBA32F. Draw should error. */
>> + glEnablei(GL_BLEND, 0);
>> +
>> + piglit_draw_rect(-1, -1, 2, 2);
>> + check_blend(float_blend);
>> +
>> + /* RT1 = GL_RGBA16F. Should draw fine. */
>> + glDisablei(GL_BLEND, 0);
>> + glEnablei(GL_BLEND, 1);
>> +
>> + piglit_draw_rect(-1, -1, 2, 2);
>> + check_draw_success();
>> +
>> + /* Both RT's enabled. Should fail. */
>> + glEnablei(GL_BLEND, 0);
>> +
>> + piglit_draw_rect(-1, -1, 2, 2);
>> + check_blend(float_blend);
>> +
>> + piglit_report_result(PIGLIT_PASS);
>> +}
>>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list