From patchwork Wed Nov 19 04:06:12 2014 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: 41094 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A9AAE241C9 for ; Wed, 19 Nov 2014 04:06:47 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id k14sf4377666wgh.0 for ; Tue, 18 Nov 2014 20:06:46 -0800 (PST) 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:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :reply-to:content-type:content-transfer-encoding; bh=PZ6QKbdzYOBdryy8VpNT2brCD4WVJ7ZBzVDv034aAQk=; b=RX/IKOgNovqYDLBwj6NYYImp3++pGHZ4IYESJIB/0AwKdVllj5gGD0/kXOTrF1eZ6V no3lyYWg6MFE046tWgJ4TCfkYPlLYGfAZfvkCD4GEup1EIdIf5n8K+tLrew+JbKa9wJM G13ROYPljihxyqezTh+NsGpz0M3NBXBWvxyMnD8r7OmMM5xshGnrGSqxEh+03NSUpKaa 5eoSgsZAsh2q1P2pAmTYZXHee8VKUgV+/8fAVUvnJCn1xAnPUAvIycx7oH4xNivAG4lb ttvi++ojD7TgsDl7kLfrp2fHWAMBUXjk+Q44YfcSZjD6mASjtCJCR5GCqkq9axpVtAel nRgw== X-Gm-Message-State: ALoCoQkl0bgmYOeukGBFKzzij8YsmMEDTKDa/VOiOi4aXpDitBXOq5BgZDBr2zvDmV5BsjkXBucI X-Received: by 10.112.62.226 with SMTP id b2mr14688lbs.11.1416370006515; Tue, 18 Nov 2014 20:06:46 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.200 with SMTP id y8ls1109939lad.14.gmail; Tue, 18 Nov 2014 20:06:46 -0800 (PST) X-Received: by 10.153.7.170 with SMTP id dd10mr3096659lad.44.1416370006242; Tue, 18 Nov 2014 20:06:46 -0800 (PST) Received: from mail-lb0-x22b.google.com (mail-lb0-x22b.google.com. [2a00:1450:4010:c04::22b]) by mx.google.com with ESMTPS id pz8si510118lbb.36.2014.11.18.20.06.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Nov 2014 20:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22b as permitted sender) client-ip=2a00:1450:4010:c04::22b; Received: by mail-lb0-f171.google.com with SMTP id b6so18701224lbj.16 for ; Tue, 18 Nov 2014 20:06:46 -0800 (PST) X-Received: by 10.112.133.138 with SMTP id pc10mr3108940lbb.48.1416370005968; Tue, 18 Nov 2014 20:06:45 -0800 (PST) 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.184.201 with SMTP id ew9csp22901lbc; Tue, 18 Nov 2014 20:06:44 -0800 (PST) X-Received: by 10.70.96.228 with SMTP id dv4mr42458723pdb.105.1416370003909; Tue, 18 Nov 2014 20:06:43 -0800 (PST) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id je3si781527pbd.84.2014.11.18.20.06.43 for ; Tue, 18 Nov 2014 20:06:43 -0800 (PST) Received-SPF: none (google.com: piglit-bounces@lists.freedesktop.org does not designate permitted sender hosts) client-ip=131.252.210.177; Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 006796E78A; Tue, 18 Nov 2014 20:06:43 -0800 (PST) X-Original-To: piglit@lists.freedesktop.org Delivered-To: piglit@lists.freedesktop.org Received: from nm25-vm8.bullet.mail.gq1.yahoo.com (nm25-vm8.bullet.mail.gq1.yahoo.com [98.136.217.119]) by gabe.freedesktop.org (Postfix) with ESMTP id 157336E78A for ; Tue, 18 Nov 2014 20:06:41 -0800 (PST) Received: from [98.137.12.175] by nm25.bullet.mail.gq1.yahoo.com with NNFMP; 19 Nov 2014 04:06:40 -0000 Received: from [98.136.164.64] by tm14.bullet.mail.gq1.yahoo.com with NNFMP; 19 Nov 2014 04:06:40 -0000 Received: from [127.0.0.1] by smtp226.mail.gq1.yahoo.com with NNFMP; 19 Nov 2014 04:06:40 -0000 X-Yahoo-Newman-Id: 586087.90451.bm@smtp226.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: EsZhoz4VM1nBmb6X_Unavwuw1MMQL8S698Fb8QomCMqLO.i R.rQbarEQRvVcKdU3aJn.yH4fAJBJrP0x5jT4xpnKPm0B35Z5dQJxr58ImBx d9PT.EKqscn33gzVcTifgVt6eRQNcIt7rUd4_4s9xoEA5zdZUIijCiwP.C8u ceSdCGfQ7nj7CqvG6uXC7gDh6fIayX8M2k.dR2hBsfyj96fnzQhxnn2QnCIJ cThGBv7_EGGyZJXpX.1bCoVV1HQlivY9zZD8uFIzzT.vJCkG92b.oOu9xNYl ZCx5eeBTeMxFExpwmNiQT5x.YReyr_vEslAsyKScnr_Lok7w1B1FqWsLxCQ4 PcvH5Iga.amR5xlXi9_XQM1T8kYg75OhzuzQCXEPfjfD3kjT6hH9gNJooL6G CYe50q_WdBkQfSRJowmSeuEhzgwlFdKnJKcZ0iL_4wm704yHmp3PNRvLWeEN N0lIV5H7x1D4y6YHR8znpsOEOsofBprTUYQ2OocNQPnuQ3ZWNBA0URGfnFLd 8xu4YQqAH7i7GnxuKvz9jD._zC8sTThE5rUbdhu_2_upFKj_h3yanpCcPxsz 83frnjYRtKyavWetjGfEXyDbNYKTrq2TdpOpWL8SM9ny2IYZhEZsV2qHyJXN oRtj53iiI6RRT4nOcGVMuAdY46t_KV.girEfq3GX.uAWptXh4DU8- X-Yahoo-SMTP: 9BNlx.aswBAkr0D8mG_whiOP1dyU From: "'Timothy Arceri' via Patchwork Forward" To: piglit@lists.freedesktop.org Date: Wed, 19 Nov 2014 15:06:12 +1100 Message-Id: <1416369973-8016-1-git-send-email-t_arceri@yahoo.com.au> X-Mailer: git-send-email 1.9.3 Subject: [Piglit] [PATCH V2 1/2] glsl-1.10: extend to test arrays of arrays 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:c04::22b as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; 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 Extends the varying packing tests to support testing arrays of arrays V2: renamed variables from 'inner' that should have been 'outer' Signed-off-by: Timothy Arceri --- tests/all.py | 2 +- .../glsl-1.10/execution/varying-packing/simple.c | 158 ++++++++++++++------- 2 files changed, 109 insertions(+), 51 deletions(-) This is a resend of a patch from July Can be tested on mesa using this branch: https://github.com/tarceri/Mesa_arrays_of_arrays/tree/linking3 Note: Tests for types (vec4) that are not packed currently fail with the above branch on intel classic driver because of missing arrays of arrays backend support (a simple solution to finish this off quickly might be to have a pass that just flatterns out the arrays before they are passed to the classic drivers, I beleive this is basically what happens in the gallium state tracker and can easily be tested by having lower_packed_varyings.cpp just pack everything). The tests pass fine on gallium. I understand that arrays of arrays is not really a glsl-1.10 test but this test also contains tests for 1.20 and 1.30 so I figured I'd add arrays of arrays too rather than duplicating the code elsewhere. I'm happy to pull this out and make it into a stand alone test though. It would also make it possible to clean it up a bit. The way arrays support works seems a little messy, and my changes for arrays of arrays add to this, but then again its not likely to need to change again much in future. diff --git a/tests/all.py b/tests/all.py index ea652f4..392f39b 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1055,7 +1055,7 @@ spec['glsl-1.10']['execution']['varying-packing'] = {} for type in ['int', 'uint', 'float', 'vec2', 'vec3', 'vec4', 'ivec2', 'ivec3', 'ivec4', 'uvec2', 'uvec3', 'uvec4', 'mat2', 'mat3', 'mat4', 'mat2x3', 'mat2x4', 'mat3x2', 'mat3x4', 'mat4x2', 'mat4x3']: - for arrayspec in ['array', 'separate']: + for arrayspec in ['array', 'separate', 'arrays_of_arrays']: cmdline = 'simple {0} {1}'.format(type, arrayspec) spec['glsl-1.10']['execution']['varying-packing'][cmdline] = \ PiglitGLTest('varying-packing-' + cmdline, run_concurrent=True) diff --git a/tests/spec/glsl-1.10/execution/varying-packing/simple.c b/tests/spec/glsl-1.10/execution/varying-packing/simple.c index 6d07a36..c5ff68e 100644 --- a/tests/spec/glsl-1.10/execution/varying-packing/simple.c +++ b/tests/spec/glsl-1.10/execution/varying-packing/simple.c @@ -97,6 +97,8 @@ */ #include "piglit-util-gl.h" +static const int outer_dim_size = 2; + PIGLIT_GL_TEST_CONFIG_BEGIN config.supports_gl_compat_version = 10; @@ -115,6 +117,14 @@ enum base_type BASE_TYPE_INT, }; +enum test_array_type +{ + SEPARATE, + ARRAY, + ARRAYS_OF_ARRAYS, +}; + + static const char * get_base_type_name(enum base_type t) { @@ -189,7 +199,8 @@ const struct type_desc *all_types[] = { struct varying_desc { const struct type_desc *type; - unsigned array_elems; + unsigned one_dim_array_elems; + unsigned two_dim_array_elems; }; /** @@ -198,12 +209,12 @@ struct varying_desc */ static GLint get_shader(bool is_vs, unsigned glsl_version, int num_varyings, - struct varying_desc *varyings) + struct varying_desc *varyings, enum test_array_type array_type) { GLuint shader; char *full_text = malloc(1000 * 100 + num_varyings); char *text = full_text; - unsigned i, j, k, l; + unsigned i, j, k, l, m; const char *varying_keyword; unsigned offset = 0; GLenum shader_type = is_vs ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER; @@ -218,16 +229,24 @@ get_shader(bool is_vs, unsigned glsl_version, int num_varyings, } text += sprintf(text, "#version %u\n", glsl_version); + if (array_type == ARRAYS_OF_ARRAYS) + text += sprintf(text, "#extension GL_ARB_arrays_of_arrays: enable\n"); text += sprintf(text, "uniform int i;\n"); for (i = 0; i < num_varyings; ++i) { const char *opt_flat_keyword = ""; if (varyings[i].type->base != BASE_TYPE_FLOAT) opt_flat_keyword = "flat "; - if (varyings[i].array_elems != 0) { + if (varyings[i].two_dim_array_elems != 0) { + text += sprintf(text, "%s%s %s var%u[%u][%u];\n", + opt_flat_keyword, varying_keyword, + varyings[i].type->name, i, + outer_dim_size, + varyings[i].two_dim_array_elems); + } else if (varyings[i].one_dim_array_elems != 0) { text += sprintf(text, "%s%s %s var%u[%u];\n", opt_flat_keyword, varying_keyword, varyings[i].type->name, i, - varyings[i].array_elems); + varyings[i].one_dim_array_elems); } else { text += sprintf(text, "%s%s %s var%u;\n", opt_flat_keyword, varying_keyword, @@ -243,37 +262,47 @@ get_shader(bool is_vs, unsigned glsl_version, int num_varyings, else text += sprintf(text, " bool failed = false;\n"); for (i = 0; i < num_varyings; ++i) { - unsigned array_loop_bound = varyings[i].array_elems; + unsigned array_loop_bound; + unsigned outer_array_loop_bound = 1; const char *base_type_name = get_base_type_name(varyings[i].type->base); + if (varyings[i].two_dim_array_elems != 0) { + outer_array_loop_bound = outer_dim_size; + array_loop_bound = varyings[i].two_dim_array_elems; + } else + array_loop_bound = varyings[i].one_dim_array_elems; if (array_loop_bound == 0) array_loop_bound = 1; - for (j = 0; j < array_loop_bound; ++j) { - for (k = 0; k < varyings[i].type->num_cols; ++k) { - for (l = 0; l < varyings[i].type->num_rows; ++l) { - text += sprintf(text, " "); - if (!is_vs) - text += sprintf(text, "if ("); - text += sprintf(text, "var%u", i); - if (varyings[i].array_elems) - text += sprintf(text, "[%u]", j); - if (varyings[i].type->num_cols > 1) - text += sprintf(text, "[%u]", k); - if (varyings[i].type->num_rows > 1) - text += sprintf(text, "[%u]", l); - if (is_vs) - text += sprintf(text, " = "); - else - text += sprintf(text, " != "); - text += sprintf(text, "%s(i + %u)", - base_type_name, - offset++); - if (is_vs) { - text += sprintf(text, ";\n"); - } else { - text += sprintf(text, - ")\n" - " failed = true;\n"); + for (j = 0; j < outer_array_loop_bound; ++j) { + for (k = 0; k < array_loop_bound; ++k) { + for (l = 0; l < varyings[i].type->num_cols; ++l) { + for (m = 0; m < varyings[i].type->num_rows; ++m) { + text += sprintf(text, " "); + if (!is_vs) + text += sprintf(text, "if ("); + text += sprintf(text, "var%u", i); + if (varyings[i].two_dim_array_elems) + text += sprintf(text, "[%u]", j); + if (varyings[i].one_dim_array_elems || varyings[i].two_dim_array_elems) + text += sprintf(text, "[%u]", k); + if (varyings[i].type->num_cols > 1) + text += sprintf(text, "[%u]", l); + if (varyings[i].type->num_rows > 1) + text += sprintf(text, "[%u]", m); + if (is_vs) + text += sprintf(text, " = "); + else + text += sprintf(text, " != "); + text += sprintf(text, "%s(i + %u)", + base_type_name, + offset++); + if (is_vs) { + text += sprintf(text, ";\n"); + } else { + text += sprintf(text, + ")\n" + " failed = true;\n"); + } } } } @@ -302,7 +331,8 @@ get_shader(bool is_vs, unsigned glsl_version, int num_varyings, */ static unsigned choose_varyings(struct varying_desc *varyings, - const struct type_desc *test_type, GLboolean test_array, + const struct type_desc *test_type, + enum test_array_type array_type, unsigned max_varying_floats) { unsigned num_varyings = 0; @@ -310,24 +340,43 @@ choose_varyings(struct varying_desc *varyings, = test_type->num_cols * test_type->num_rows; unsigned num_test_varyings = max_varying_floats / components_in_test_type; + unsigned num_two_dim_test_varyings + = num_test_varyings / outer_dim_size; + unsigned num_extra_arrays = 0; unsigned num_extra_varyings = max_varying_floats - num_test_varyings * components_in_test_type; unsigned i; - if (test_array) { + if (array_type == ARRAYS_OF_ARRAYS) { varyings[num_varyings].type = test_type; - varyings[num_varyings].array_elems = num_test_varyings; + varyings[num_varyings].two_dim_array_elems = num_two_dim_test_varyings; + varyings[num_varyings].one_dim_array_elems = 0; + num_extra_arrays + = num_test_varyings - (num_two_dim_test_varyings * outer_dim_size); + ++num_varyings; + if (num_extra_arrays > 0) { + varyings[num_varyings].type = test_type; + varyings[num_varyings].two_dim_array_elems = 0; + varyings[num_varyings].one_dim_array_elems = num_extra_arrays; + ++num_varyings; + } + } else if (array_type == ARRAY) { + varyings[num_varyings].type = test_type; + varyings[num_varyings].two_dim_array_elems = 0; + varyings[num_varyings].one_dim_array_elems = num_test_varyings; ++num_varyings; } else { for (i = 0; i < num_test_varyings; ++i) { varyings[num_varyings].type = test_type; - varyings[num_varyings].array_elems = 0; + varyings[num_varyings].two_dim_array_elems = 0; + varyings[num_varyings].one_dim_array_elems = 0; ++num_varyings; } } for (i = 0; i < num_extra_varyings; ++i) { varyings[num_varyings].type = &float_type; - varyings[num_varyings].array_elems = 0; + varyings[num_varyings].two_dim_array_elems = 0; + varyings[num_varyings].one_dim_array_elems = 0; ++num_varyings; } @@ -344,6 +393,8 @@ NORETURN print_usage_and_exit(const char *prog_name) printf(" %s\n", all_types[i]->name); printf(" and is one of:\n" " array: test using an array of the above type\n" + " arrays_of_arrays: test using a multidimensional array" + " of the above type\n" " separate: test using separately declared varyings\n"); piglit_report_result(PIGLIT_FAIL); } @@ -353,10 +404,11 @@ piglit_init(int argc, char **argv) { unsigned i; const struct type_desc *test_type; - GLboolean test_array; + enum test_array_type array_type; GLint max_varying_floats; struct varying_desc *varyings; unsigned num_varyings; + unsigned glsl_version; GLuint vs, fs; if (argc != 3) @@ -365,29 +417,35 @@ piglit_init(int argc, char **argv) if (strcmp(argv[1], all_types[i]->name) == 0) break; } - if (all_types[i]) + if (all_types[i]) { test_type = all_types[i]; - else + glsl_version = test_type->glsl_version_required; + } else print_usage_and_exit(argv[0]); if (strcmp(argv[2], "array") == 0) - test_array = GL_TRUE; + array_type = ARRAY; else if (strcmp(argv[2], "separate") == 0) - test_array = GL_FALSE; - else + array_type = SEPARATE; + else if (strcmp(argv[2], "arrays_of_arrays") == 0) { + array_type = ARRAYS_OF_ARRAYS; + piglit_require_extension("GL_ARB_arrays_of_arrays"); + if (glsl_version < 120) + glsl_version = 120; + } else print_usage_and_exit(argv[0]); piglit_require_gl_version(20); - piglit_require_GLSL_version(test_type->glsl_version_required); + piglit_require_GLSL_version(glsl_version); glGetIntegerv(GL_MAX_VARYING_FLOATS, &max_varying_floats); varyings = malloc(sizeof(*varyings) * max_varying_floats); - num_varyings = choose_varyings(varyings, test_type, - test_array, max_varying_floats); + num_varyings = choose_varyings(varyings, test_type, array_type, + max_varying_floats); - vs = get_shader(true, test_type->glsl_version_required, - num_varyings, varyings); - fs = get_shader(false, test_type->glsl_version_required, - num_varyings, varyings); + vs = get_shader(true, glsl_version, + num_varyings, varyings, array_type); + fs = get_shader(false, glsl_version, + num_varyings, varyings, array_type); prog = piglit_link_simple_program(vs, fs); i_location = glGetUniformLocation(prog, "i"); free(varyings);