From patchwork Sat Jun 20 12:14:28 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: 50122 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 82D2921594 for ; Sat, 20 Jun 2015 12:15:02 +0000 (UTC) Received: by laka10 with SMTP id a10sf35219100lak.2 for ; Sat, 20 Jun 2015 05:15:00 -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: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=qdki49LRGJj2HWH4nX17/CjqmsC8caLIpgdaPUxg5x4=; b=WfFNjl1D5PfuhgXEu7JRkgAZ61UWQggpYC53laAaOZ7FlfPSHbeJAHPDp5L8EfblBl lvLWzNzwFRzv29wPMIZV5gahSD150JzRza06nHVjBqjVlUHMSmqCK3ULWZWRUxP0c4x1 HJbjqEOC1lbCugy7zXKNWtIGu4O8ZmZ1x8ZYgkaijhSCJJztU1aCg0ZkzUmuGmqcwN8J yFxn6BWsYmv41BFCI5Y9nQheYvGZ1H5SmNhRXEyHLlNC8k15TwzYOo5liql5LI5xXNbE xNbsZ8T2hF0OF08xnZNitqXxzww3/T1rzqDGQSQs1iZb+THCJDt7HuhE+ERTaiN7/dA2 mkew== X-Gm-Message-State: ALoCoQmcW4wAezzRbaDz+bdNmQI82FKFaMaHry5XKBLMSH/TRShIV0C0v0BghmGu/eLe1IU7zceH X-Received: by 10.194.158.134 with SMTP id wu6mr16894595wjb.6.1434802500670; Sat, 20 Jun 2015 05:15:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.39 with SMTP id dd7ls739432lac.60.gmail; Sat, 20 Jun 2015 05:15:00 -0700 (PDT) X-Received: by 10.112.199.10 with SMTP id jg10mr21886770lbc.24.1434802500528; Sat, 20 Jun 2015 05:15:00 -0700 (PDT) Received: from mail-lb0-x22d.google.com (mail-lb0-x22d.google.com. [2a00:1450:4010:c04::22d]) by mx.google.com with ESMTPS id kl13si1688794lbb.9.2015.06.20.05.15.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Jun 2015 05:15:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22d as permitted sender) client-ip=2a00:1450:4010:c04::22d; Received: by lbbwc1 with SMTP id wc1so85814758lbb.2 for ; Sat, 20 Jun 2015 05:15:00 -0700 (PDT) X-Received: by 10.152.87.33 with SMTP id u1mr22367624laz.35.1434802500045; Sat, 20 Jun 2015 05:15:00 -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.108.230 with SMTP id hn6csp1209367lbb; Sat, 20 Jun 2015 05:14:58 -0700 (PDT) X-Received: by 10.68.204.133 with SMTP id ky5mr41042338pbc.67.1434802497839; Sat, 20 Jun 2015 05:14:57 -0700 (PDT) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id pf6si20936740pbb.67.2015.06.20.05.14.57; Sat, 20 Jun 2015 05:14:57 -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 BA1356E701; Sat, 20 Jun 2015 05:14:56 -0700 (PDT) X-Original-To: piglit@lists.freedesktop.org Delivered-To: piglit@lists.freedesktop.org Received: from nm28-vm1.bullet.mail.gq1.yahoo.com (nm28-vm1.bullet.mail.gq1.yahoo.com [98.136.216.160]) by gabe.freedesktop.org (Postfix) with ESMTP id DA5FD6E701 for ; Sat, 20 Jun 2015 05:14:54 -0700 (PDT) Received: from [98.137.12.56] by nm28.bullet.mail.gq1.yahoo.com with NNFMP; 20 Jun 2015 12:14:54 -0000 Received: from [208.71.42.199] by tm1.bullet.mail.gq1.yahoo.com with NNFMP; 20 Jun 2015 12:14:54 -0000 Received: from [127.0.0.1] by smtp210.mail.gq1.yahoo.com with NNFMP; 20 Jun 2015 12:14:54 -0000 X-Yahoo-Newman-Id: 350440.61572.bm@smtp210.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: GYqMKdcVM1kmMj1D2Xd1MqcsuYerAgkNhQLODSqc3N_YsgP soOREHyTOW38E4s9LdGY9PWTByQCOwAK66BlhJV9Qy0fZ_IqzYDD.aZjhOui FMb9bSf.pwAzj67HvlWRetX2T_x1xLEsHFZxEN2Rc5rcIs3KUpLEv9zrkf6p fVOWj4MkGBSKHRbQ31FlzB2FoeFb8XWt1VkcezyuZTXGUe0LcoIVgGIKtNlW ereriAvawotpSqQFcVEqkCh7W3IELtdnMB10a8endFwaKcGkC8K1Cnb8l66L k46yC4vF1IijYkis2WWeuhez4itHkeib.YeBcM48gKxMpz_ixywYSRzG9E.7 v.lzqqw487F97t4Nw_Q__pcVEXVke31_Z0UtrKMxq3rlhV5wTbaUE91AQLRD wAEU2BQJtVDTfsRMpbD0e2fXY_FBgxxGtbQr0bACfgv1o26L0Fuy.ETkQl7q UK1nKgToE5NNvm5QEJSPmsz5RvQOuw6Nr04ADPbrsmLLhYzZVPSbVnr8wooW x6kjNO3KxIm9Y2gGYhXlhEHU_eOcKeg75tzVAWYQ- X-Yahoo-SMTP: 9BNlx.aswBAkr0D8mG_whiOP1dyU From: "'Timothy Arceri' via Patchwork Forward" To: piglit@lists.freedesktop.org Date: Sat, 20 Jun 2015 22:14:28 +1000 Message-Id: <1434802475-4020-1-git-send-email-t_arceri@yahoo.com.au> X-Mailer: git-send-email 2.1.0 Subject: [Piglit] [PATCH 1/8] varying-packing: add arrays of arrays support 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::22d as permitted sender) smtp.mail=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 V3: rebase and test double types V2: renamed variables from 'inner' that should have been 'outer' --- To see some shaders generated by these changes see here: http://lists.freedesktop.org/archives/piglit/2015-May/015955.html tests/all.py | 4 +- .../glsl-1.10/execution/varying-packing/simple.c | 137 +++++++++++++++------ 2 files changed, 100 insertions(+), 41 deletions(-) diff --git a/tests/all.py b/tests/all.py index e658f5e..905047f 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1296,7 +1296,7 @@ with profile.group_manager( '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']: g(['varying-packing-simple', type_, arrayspec], 'simple {} {}'.format(type_, arrayspec)) @@ -2061,7 +2061,7 @@ with profile.group_manager( for type in ['double', 'dvec2', 'dvec3', 'dvec4', 'dmat2', 'dmat3', 'dmat4', 'dmat2x3', 'dmat2x4', 'dmat3x2', 'dmat3x4', 'dmat4x2', 'dmat4x3']: - for arrayspec in ['array', 'separate']: + for arrayspec in ['array', 'separate', 'arrays_of_arrays']: g(['varying-packing-simple', type, arrayspec], 'simple {0} {1}'.format(type, arrayspec)) 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 e9935c7..2b1c010 100644 --- a/tests/spec/glsl-1.10/execution/varying-packing/simple.c +++ b/tests/spec/glsl-1.10/execution/varying-packing/simple.c @@ -100,6 +100,8 @@ static void parse_args(int argc, char *argv[], struct piglit_gl_test_config *config); +static const int outer_dim_size = 2; + PIGLIT_GL_TEST_CONFIG_BEGIN config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; @@ -118,6 +120,13 @@ enum base_type BASE_TYPE_DOUBLE, }; +enum test_array_type +{ + SEPARATE, + ARRAY, + ARRAYS_OF_ARRAYS, +}; + static const char * get_base_type_name(enum base_type t) { @@ -219,7 +228,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; }; /** @@ -228,12 +238,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; @@ -249,6 +259,8 @@ 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"); for (i = 0; i < num_varyings; ++i) { const char *opt_flat_keyword = ""; if (!fp64 && varyings[i].type->base == BASE_TYPE_DOUBLE) { @@ -257,11 +269,17 @@ get_shader(bool is_vs, unsigned glsl_version, int num_varyings, } 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%03u[%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%03u[%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%03u;\n", opt_flat_keyword, varying_keyword, @@ -282,31 +300,42 @@ 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, "failed = failed || "); - text += sprintf(text, "var%03u", 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);\n", - base_type_name, - offset++); + 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, "failed = failed || "); + text += sprintf(text, "var%03u", 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);\n", + base_type_name, + offset++); + } } } } @@ -334,7 +363,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; @@ -343,24 +373,43 @@ choose_varyings(struct varying_desc *varyings, = test_type->num_cols * test_type->num_rows * element_size; 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; } @@ -377,6 +426,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); } @@ -414,36 +465,44 @@ parse_args(int argc, char *argv[], struct piglit_gl_test_config *config) void piglit_init(int argc, char **argv) { - 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) print_usage_and_exit(argv[0]); + glsl_version = test_type->glsl_version_required; + 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); if (test_type->base == BASE_TYPE_DOUBLE) piglit_require_extension("GL_ARB_gpu_shader_fp64"); 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); + array_type, max_varying_floats); vs = get_shader(true, test_type->glsl_version_required, - num_varyings, varyings); + num_varyings, varyings, array_type); fs = get_shader(false, test_type->glsl_version_required, - num_varyings, varyings); + num_varyings, varyings, array_type); prog = piglit_link_simple_program(vs, fs); i_location = glGetUniformLocation(prog, "i"); free(varyings);