From patchwork Tue Sep 29 02:54:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 'Timothy Arceri' via Patchwork Forward X-Patchwork-Id: 54216 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 9412C22DEE for ; Tue, 29 Sep 2015 02:54:22 +0000 (UTC) Received: by labnm6 with SMTP id nm6sf7798953lab.1 for ; Mon, 28 Sep 2015 19:54:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list:reply-to; bh=UlLGHWj5pnVrYhtYAaVTc9aTT/Zbe51wJsVBybqVit8=; b=RQMq06cY50VtIr2pslOjG0gI9Y7Cr5dqYR6+664FgKwde1N9TqRRU9PMC4NJsXjAuZ eFP9xX3dwoR4p2rrgrRgxUn3QW86yfewxXvCUuPNSgwnaaEK3NJpAhe+fD4kZnLKJQwK fv74cqE2Otv8acQag95kB5PEJInFvJJQH5BEmtqZedGxzqgaOovqSqnoJun1g/qSDwSK PE81SSmEz79/k90FfM9u/OYIojs0jmW/3q9q4ZAjpY+KbczG0BhSxlDcaPxckXBa2SB3 NKPH9XwMyNXCOutqlu/Yer6g6dBu+eF11WRuhewBnwrD2O0MaLjSK4qk4ulAHAgZ2R+R 9zOA== X-Gm-Message-State: ALoCoQnyTnKTC5DlzmOrBPFqeXHYvEP8DWORJiTaQ9XVJ546sFdITqhVnB2+0EiaQno7G/aK49GN X-Received: by 10.180.9.104 with SMTP id y8mr3378290wia.7.1443495261103; Mon, 28 Sep 2015 19:54:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.194 with SMTP id e2ls337089lae.49.gmail; Mon, 28 Sep 2015 19:54:20 -0700 (PDT) X-Received: by 10.112.169.98 with SMTP id ad2mr3488811lbc.2.1443495260970; Mon, 28 Sep 2015 19:54:20 -0700 (PDT) Received: from mail-la0-x233.google.com (mail-la0-x233.google.com. [2a00:1450:4010:c03::233]) by mx.google.com with ESMTPS id d9si9818710laf.139.2015.09.28.19.54.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 19:54:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::233 as permitted sender) client-ip=2a00:1450:4010:c03::233; Received: by lahh2 with SMTP id h2so181140200lah.0 for ; Mon, 28 Sep 2015 19:54:20 -0700 (PDT) X-Received: by 10.25.211.201 with SMTP id k192mr4413866lfg.32.1443495260761; Mon, 28 Sep 2015 19:54:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1880127lbq; Mon, 28 Sep 2015 19:54:19 -0700 (PDT) X-Received: by 10.66.144.199 with SMTP id so7mr30413607pab.42.1443495259224; Mon, 28 Sep 2015 19:54:19 -0700 (PDT) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id zj1si33551992pbb.30.2015.09.28.19.54.18; Mon, 28 Sep 2015 19:54:19 -0700 (PDT) Received-SPF: pass (google.com: domain of piglit-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E8C66E49A; Mon, 28 Sep 2015 19:54:18 -0700 (PDT) X-Original-To: piglit@lists.freedesktop.org Delivered-To: piglit@lists.freedesktop.org Received: from nm22-vm7.bullet.mail.gq1.yahoo.com (nm22-vm7.bullet.mail.gq1.yahoo.com [98.136.217.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A5DF6E49A for ; Mon, 28 Sep 2015 19:54:17 -0700 (PDT) Received: from [98.137.12.188] by nm22.bullet.mail.gq1.yahoo.com with NNFMP; 29 Sep 2015 02:54:17 -0000 Received: from [98.136.164.77] by tm9.bullet.mail.gq1.yahoo.com with NNFMP; 29 Sep 2015 02:54:17 -0000 Received: from [127.0.0.1] by smtp239.mail.gq1.yahoo.com with NNFMP; 29 Sep 2015 02:54:16 -0000 X-Yahoo-Newman-Id: 993344.24398.bm@smtp239.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: f2dSS3gVM1kMvpdMobeu2RNSXS4t0YnzNXiami2Xy4WwKZb bJFIVeSmM_NftMCmkmYUPlMGZczBoCD2y1fKL.sT_VzgrlTu4DN1ZrKmx2f8 r9YBpDShjb8.agONij9Cx1LdmeaaInQ5PTU6tGgjJe0ytfxP5eCpTeC4N.c. _SbEtGUdxANhRhAIiOjcTc1Z4pNhOGu.xzk6m3KfhJoDvKzPAzsGieu7G6Re AW.N8KaxpbxETFNUE.gdRHhjOJfc4CmefyEjEJCiB1AIj_q2V0DIy6csEKFL cQSi.6UPqJtoHA6H9d4DX5lx7rkPW50cRV1RT4o4AeCrMbxdshQzVJJXiuDq HvCNh7QEgtFebko.kgYo2rh9psGP4l3vYOERytTTC.G2XEf2h6I.ai91xjdC KPiqM5ceqzWzCsiybxu8E1xxBd6VH5kQ1Fn7lLUY0NGimwDyufN1CVsmYNUV N3nf0IrignrpjNwIHt5Z2WwlSjW4AANyfSAfsLIOY9zxBDc2wzVcabMp_6yA EiA9p58z25JnHDS.boJrSb18qgbdfm0oYCI0- X-Yahoo-SMTP: 9BNlx.aswBAkr0D8mG_whiOP1dyU From: "'Timothy Arceri' via Patchwork Forward" To: piglit@lists.freedesktop.org Date: Tue, 29 Sep 2015 12:54:10 +1000 Message-Id: <1443495250-13373-1-git-send-email-t_arceri@yahoo.com.au> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443489992-26586-1-git-send-email-t_arceri@yahoo.com.au> References: <1443489992-26586-1-git-send-email-t_arceri@yahoo.com.au> Subject: [Piglit] [PATCH V2 1/2] ext_transform_feedback: add arrays of arrays test to max-varying X-BeenThere: piglit@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: piglit-bounces@lists.freedesktop.org Sender: "Piglit" X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::233 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@yahoo.com.au; dmarc=fail (p=NONE dis=NONE) header.from=yahoo.com.au Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 X-Original-From: Timothy Arceri Reply-To: Timothy Arceri V2: report subtest results on pass as well as fail --- tests/spec/ext_transform_feedback/max-varyings.c | 213 +++++++++++++++++++---- 1 file changed, 175 insertions(+), 38 deletions(-) diff --git a/tests/spec/ext_transform_feedback/max-varyings.c b/tests/spec/ext_transform_feedback/max-varyings.c index 497e432..04dea26 100644 --- a/tests/spec/ext_transform_feedback/max-varyings.c +++ b/tests/spec/ext_transform_feedback/max-varyings.c @@ -40,6 +40,7 @@ #include "piglit-util-gl.h" #define MAX_VARYING 32 +#define AOA_OUTER_DIM 2 /* 10x10 rectangles with 2 pixels of pad. Deal with up to 32 varyings. */ @@ -54,6 +55,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END static const char *xfb_varying_array[MAX_VARYING]; +static const char *xfb_varying_aoa[MAX_VARYING]; static GLuint xfb_buf; /* Generate a VS that writes to a varying vec4[num_varyings] called @@ -84,6 +86,49 @@ get_vs(int num_varyings) return shader; } +static GLint +get_vs_aoa(int num_varyings) +{ + GLuint shader; + char vstext[2048]; + int inner_dim = num_varyings / AOA_OUTER_DIM; + + /* If there is an odd number of varyings add one more */ + char *extra_varying; + char *extra_statement; + if (num_varyings % 2 != 0) { + extra_varying = "varying vec4 y;"; + extra_statement = "y = 4.0*(offset+j) + vec4(0.0, 1.0, 2.0, 3.0);"; + } else { + extra_varying = ""; + extra_statement = ""; + } + + sprintf(vstext, + "#version 120\n" + "#extension GL_ARB_arrays_of_arrays : enable\n" + "varying vec4[%d][%d] v;\n" + "%s\n" + "\n" + "void main()\n" + "{\n" + " int offset;\n" + " int j;\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " for (int i = 0; i < v.length(); ++i) {\n" + " offset = i * v[i].length();\n" + " for (j = 0; j < v[i].length(); ++j) {\n" + " v[i][j] = 4.0*(offset+j) + vec4(0.0, 1.0, 2.0, 3.0);\n" + " }\n" + " }\n" + " %s\n" + "}\n", AOA_OUTER_DIM, inner_dim, extra_varying, extra_statement); + + shader = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext); + + return shader; +} + /* Generate a FS that checks all the varyings written by the VS, and * outputs green if they are all correct. */ @@ -111,14 +156,77 @@ get_fs(int num_varyings) return shader; } +static GLint +get_fs_aoa(int num_varyings) +{ + GLuint shader; + char fstext[2048]; + int inner_dim = num_varyings / AOA_OUTER_DIM; + + /* If there is an odd number of varyings add one more */ + char *extra_varying; + char *extra_statement; + if (num_varyings % 2 != 0) { + extra_varying = "varying vec4 y;"; + extra_statement = "failed = failed || (y != 4.0*(offset+j) + vec4(0.0, 1.0, 2.0, 3.0));"; + + } else { + extra_varying = ""; + extra_statement = ""; + } + + sprintf(fstext, + "#version 120\n" + "#extension GL_ARB_arrays_of_arrays : enable\n" + "varying vec4[%d][%d] v;\n" + "%s\n" + "\n" + "void main()\n" + "{\n" + " bool failed = false;\n" + " int offset;\n" + " int j;\n" + " for(int i = 0; i < v.length(); ++i) {\n" + " offset = i * v[i].length();\n" + " for (j = 0; j < v[i].length(); ++j) {\n" + " failed = failed || (v[i][j] != 4.0*(offset+j) + vec4(0.0, 1.0, 2.0, 3.0));\n" + " }\n" + " }\n" + " %s\n" + " gl_FragColor = vec4(float(failed), 1.0 - float(failed), 0.0, 1.0);\n" + "}\n", AOA_OUTER_DIM, inner_dim, extra_varying, extra_statement); + + shader = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext); + + return shader; +} + /** * Initialize xfb_varying_array to contain the names of the varyings * used by get_vs and get_fs. */ static void -init_xfb_varying_array() +init_xfb_varyings(int max_varyings) { - int i; + int i, j; + int inner_dim = max_varyings / AOA_OUTER_DIM; + int count = 0; + + /* Initialise arrays of arrays */ + for (i = 0; i < AOA_OUTER_DIM; ++i) { + for (j = 0; j < inner_dim; ++j) { + char *buf = malloc(8); + sprintf(buf, "v[%d][%d]", i, j); + xfb_varying_aoa[count++] = buf; + } + } + if (max_varyings % 2 != 0) { + char *buf = malloc(8); + sprintf(buf, "y"); + xfb_varying_aoa[count++] = buf; + } + + /* Initialise singlie dimension array */ for (i = 0; i < MAX_VARYING; ++i) { char *buf = malloc(6); sprintf(buf, "v[%d]", i); @@ -173,7 +281,8 @@ check_xfb_output(int max_varyings, int num_xfb_varyings, int offset) } static GLboolean -draw(GLuint vs, GLuint fs, int num_xfb_varyings, int max_varyings) +draw(GLuint vs, GLuint fs, int num_xfb_varyings, + int max_varyings, const char **xfb_varyings) { GLboolean pass = GL_TRUE; int offset; @@ -187,7 +296,7 @@ draw(GLuint vs, GLuint fs, int num_xfb_varyings, int max_varyings) glAttachShader(prog, fs); glTransformFeedbackVaryings(prog, num_xfb_varyings, - xfb_varying_array + offset, + xfb_varyings + offset, GL_INTERLEAVED_ATTRIBS); glLinkProgram(prog); @@ -219,20 +328,58 @@ draw(GLuint vs, GLuint fs, int num_xfb_varyings, int max_varyings) return pass; } +static GLboolean +run_subtest(GLuint vs, GLuint fs, int max_xfb_varyings, + int max_varyings, const char **xfb_varyings) +{ + GLboolean pass = GL_TRUE; + int row, col; + + glClearColor(0.5, 0.5, 0.5, 0.5); + glClear(GL_COLOR_BUFFER_BIT); + + for (row = 0; row < max_xfb_varyings; row++) { + pass = draw(vs, fs, row + 1, max_varyings, xfb_varyings) && + pass; + } + + for (row = 0; row < max_xfb_varyings; row++) { + for (col = 0; col < max_varyings - row; col++) { + GLboolean ok; + float green[3] = {0.0, 1.0, 0.0}; + + ok = piglit_probe_rect_rgb(coord_from_index(col), + coord_from_index(row), + 10, 10, + green); + if (!ok) { + printf(" Failure with %d vec4 varyings" + " captured and offset %d\n", + row + 1, col); + pass = GL_FALSE; + break; + } + } + } + return pass; +} + enum piglit_result piglit_display(void) { GLint max_components; - int max_varyings, row, col; + int max_varyings; int max_xfb_varyings = 0; GLint max_xfb_components; - GLboolean pass = GL_TRUE, warned = GL_FALSE; + GLboolean pass; + enum piglit_result status = PIGLIT_PASS; GLuint vs, fs; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); glGetIntegerv(GL_MAX_VARYING_FLOATS, &max_components); max_varyings = max_components / 4; + init_xfb_varyings(max_varyings); printf("GL_MAX_VARYING_FLOATS = %i\n", max_components); @@ -241,7 +388,7 @@ piglit_display(void) "(implementation reports %d components)\n", max_components, MAX_VARYING); max_varyings = MAX_VARYING; - warned = GL_TRUE; + status = PIGLIT_WARN; } glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, @@ -251,43 +398,34 @@ piglit_display(void) printf("GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = %i\n", max_xfb_components); + /* Test single dimension array */ vs = get_vs(max_varyings); fs = get_fs(max_varyings); - - glClearColor(0.5, 0.5, 0.5, 0.5); - glClear(GL_COLOR_BUFFER_BIT); - - for (row = 0; row < max_xfb_varyings; row++) { - pass = draw(vs, fs, row + 1, max_varyings) && pass; + pass = run_subtest(vs, fs, max_xfb_varyings, + max_varyings, xfb_varying_array); + if (!pass) { + status = PIGLIT_FAIL; } - - for (row = 0; row < max_xfb_varyings; row++) { - for (col = 0; col < max_varyings - row; col++) { - GLboolean ok; - float green[3] = {0.0, 1.0, 0.0}; - - ok = piglit_probe_rect_rgb(coord_from_index(col), - coord_from_index(row), - 10, 10, - green); - if (!ok) { - printf(" Failure with %d vec4 varyings" - " captured and offset %d\n", - row + 1, col); - pass = GL_FALSE; - break; - } + piglit_report_subtest_result(status, + "max-varying-single-dimension-array"); + + /* Test arrays of arrays */ + if (piglit_is_extension_supported("GL_ARB_arrays_of_arrays")) { + bool subtest_result; + vs = get_vs_aoa(max_varyings); + fs = get_fs_aoa(max_varyings); + subtest_result = run_subtest(vs, fs, max_xfb_varyings, + max_varyings, xfb_varying_aoa); + if (!subtest_result) { + status = PIGLIT_FAIL; + pass = false; } + piglit_report_subtest_result(status, + "max-varying-arrays-of-arrays"); } - piglit_present_results(); - if (!pass) - return PIGLIT_FAIL; - if (warned) - return PIGLIT_WARN; - else - return PIGLIT_PASS; + return status; } void piglit_init(int argc, char **argv) @@ -295,7 +433,6 @@ void piglit_init(int argc, char **argv) piglit_require_gl_version(20); piglit_require_GLSL_version(120); piglit_require_transform_feedback(); - init_xfb_varying_array(); glGenBuffers(1, &xfb_buf); printf("Vertical axis: Increasing numbers of varyings captured by "