From patchwork Wed Jun 17 12:14:22 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: 49978 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 D2B24228CC for ; Wed, 17 Jun 2015 12:14:51 +0000 (UTC) Received: by wgez8 with SMTP id z8sf11889124wge.2 for ; Wed, 17 Jun 2015 05:14:51 -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=DqZbT6Is2Dh0BF2V/POu9gxsvVkYd+aNBcehm9/DfVc=; b=YpZbCRN6ZVgwNDbIK22Egih6yHVY/ptACb2vFSvFIi0IHDB60JSAxEBJpEGcMS69TY MVfVUnvQCCbbBWkvD2wfDwIgx2y2nhXwYM/r8+SGkhXRyfTG0E45DoRoPYoEcvtRMFhz MbWUDlGDNm3nn+tJ0TBb50SW+aK+Lnz7QNFeXXZE69n6b/aLpHNS61eCnBBe6wxuWkPd uMAzQCNQ+mWHcHyfN/6VOPRGyv2XpgoUNnLK6513vL+jdqNwf4ytFqf1R7YaffkHwV3w HFU3CECZ0R+0pO7Y2YXpkW3Yt+IMnyp3MTO7yEAfCDCrP6x6fwPA07xnS6BOuOP2ETZB KVBg== X-Gm-Message-State: ALoCoQkNiR5ZQqkgMlwDrgM72Uv5J78481iiKnQVEb4qsBq56q9kS9ojnSgs+mcwBP5xE6HDgKhR X-Received: by 10.180.11.101 with SMTP id p5mr8105514wib.3.1434543291127; Wed, 17 Jun 2015 05:14:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.103 with SMTP id m7ls314997lae.79.gmail; Wed, 17 Jun 2015 05:14:51 -0700 (PDT) X-Received: by 10.112.43.36 with SMTP id t4mr3520957lbl.100.1434543290990; Wed, 17 Jun 2015 05:14:50 -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 e7si3431180lbc.62.2015.06.17.05.14.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 05:14:50 -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 lbbqq2 with SMTP id qq2so30250215lbb.3 for ; Wed, 17 Jun 2015 05:14:50 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr7591774lae.19.1434543290885; Wed, 17 Jun 2015 05:14:50 -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 hn6csp429158lbb; Wed, 17 Jun 2015 05:14:49 -0700 (PDT) X-Received: by 10.66.66.65 with SMTP id d1mr10361510pat.22.1434543288795; Wed, 17 Jun 2015 05:14:48 -0700 (PDT) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id yw5si6030177pbb.105.2015.06.17.05.14.47; Wed, 17 Jun 2015 05:14:48 -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 B38D26E575; Wed, 17 Jun 2015 05:14:47 -0700 (PDT) X-Original-To: piglit@lists.freedesktop.org Delivered-To: piglit@lists.freedesktop.org Received: from nm29-vm8.bullet.mail.gq1.yahoo.com (nm29-vm8.bullet.mail.gq1.yahoo.com [98.136.216.183]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EB4C6E575 for ; Wed, 17 Jun 2015 05:14:46 -0700 (PDT) Received: from [98.137.12.55] by nm29.bullet.mail.gq1.yahoo.com with NNFMP; 17 Jun 2015 12:14:45 -0000 Received: from [208.71.42.201] by tm15.bullet.mail.gq1.yahoo.com with NNFMP; 17 Jun 2015 12:14:45 -0000 Received: from [127.0.0.1] by smtp212.mail.gq1.yahoo.com with NNFMP; 17 Jun 2015 12:14:45 -0000 X-Yahoo-Newman-Id: 890912.78452.bm@smtp212.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: GxSvgBQVM1ng6FbgjfJPJZJnUwP2FD0Sw9HihmDaaHz_I0k rOGzSRYKBRGOn9roqXMlpxXlDJ4osP96A3BkKEbQan_rK5Vo3omj3x0DpE.K fUkTUcSqmGUyDlS5DHN14p3I2QQW5HnKLCRLZWSUpBEm3UG4omm8zqJQqClF 8dlhtSb4qkSFN79dtitWrzy9S0EFLiJ8b.gcodRmOaQU9mRDIZo0Tmj1CexR 7ydZqt4KBQ04F7egXJSzZsEt3tsefUPSJ2zZzBOEQh4O6u34RZvr5zvcSDU2 3fwyi0BAd7vummgWvLiMRC9Gj_z0B5DEu4SgqwRFj2I7ie.wXDCQzAfuMdfq h4zOrSKgj23BcduQocfLVEG4amaUeIXSs9IfZkTXPNZobmDjgkWlC47ouSNC 7Da.2zmHWeEadPwMUGOjPAMv3ROfZkqmp0BFizNVfu7QvSvZATYjnGVpZHp6 6qx.VPyHBMjMI23p6mJOdpDtKrsQwNQC2fkpmLl.kgaD_Rhh0LSH_zPg__wd GGBENlLapc9fJymqB6Lb1D1NhGXodNLFkv48- X-Yahoo-SMTP: 9BNlx.aswBAkr0D8mG_whiOP1dyU From: "'Timothy Arceri' via Patchwork Forward" To: piglit@lists.freedesktop.org Date: Wed, 17 Jun 2015 22:14:22 +1000 Message-Id: <1434543262-21147-1-git-send-email-t_arceri@yahoo.com.au> X-Mailer: git-send-email 2.1.0 Subject: [Piglit] [PATCH] arb_separate_shader_objects: extend active sampler conflict to test 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::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 --- .../active-sampler-conflict.c | 187 ++++++++++++++++----- 1 file changed, 143 insertions(+), 44 deletions(-) diff --git a/tests/spec/arb_separate_shader_objects/active-sampler-conflict.c b/tests/spec/arb_separate_shader_objects/active-sampler-conflict.c index 5388449..a9b87ab 100644 --- a/tests/spec/arb_separate_shader_objects/active-sampler-conflict.c +++ b/tests/spec/arb_separate_shader_objects/active-sampler-conflict.c @@ -81,56 +81,108 @@ static const char *fs_code = "}\n" ; +static const char *fs_arrays_code = + "#version 130\n" + "#extension GL_ARB_separate_shader_objects: require\n" + "\n" + "out vec4 out_color;\n" + "\n" + "uniform sampler2D s2[2];\n" + "uniform sampler3D s3[2];\n" + "\n" + "void main()\n" + "{\n" + " out_color = texture(s2[1], vec2(0)) + texture(s3[1], vec3(0));\n" + "}\n" + ; + +static const char *fs_arrays_of_arrays_code = + "#version 130\n" + "#extension GL_ARB_separate_shader_objects: require\n" + "#extension GL_ARB_arrays_of_arrays: require\n" + "\n" + "out vec4 out_color;\n" + "\n" + "uniform sampler2D s2[2][2];\n" + "uniform sampler3D s3[2][2];\n" + "\n" + "void main()\n" + "{\n" + " out_color = texture(s2[1][1], vec2(0)) + texture(s3[1][1], vec3(0));\n" + "}\n" + ; + static const float vert[2] = { 0.0, 0.0 }; -void piglit_init(int argc, char **argv) +static bool +setup_program(GLuint *prog, GLuint *pipe, GLuint *vao, + GLuint *bo, const char **fs_code) { - GLuint prog; - GLint s2_loc; - GLint s3_loc; - GLuint pipe; - GLuint vao; - GLuint bo; bool pass = true; - piglit_require_extension("GL_ARB_separate_shader_objects"); - - prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, - (const GLchar *const *) &fs_code); - piglit_link_check_status(prog); - - s2_loc = glGetUniformLocation(prog, "s2"); - if (s2_loc == -1) { - fprintf(stderr, "Failed to get uniform location for s2.\n"); - pass = false; - } - - s3_loc = glGetUniformLocation(prog, "s3"); - if (s3_loc == -1) { - fprintf(stderr, "Failed to get uniform location for s3.\n"); - pass = false; - } + *prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, + (const GLchar *const *) fs_code); + piglit_link_check_status(*prog); - glGenProgramPipelines(1, &pipe); - glUseProgramStages(pipe, + glGenProgramPipelines(1, pipe); + glUseProgramStages(*pipe, GL_FRAGMENT_SHADER_BIT, - prog); - glActiveShaderProgram(pipe, prog); - glBindProgramPipeline(pipe); + *prog); + glActiveShaderProgram(*pipe, *prog); + glBindProgramPipeline(*pipe); - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); + glGenVertexArrays(1, vao); + glBindVertexArray(*vao); /* Configure a vertex array object and buffer object that will * be used for drawing later. */ - glGenBuffers(1, &bo); - glBindBuffer(GL_ARRAY_BUFFER, bo); + glGenBuffers(1, bo); + glBindBuffer(GL_ARRAY_BUFFER, *bo); glBufferData(GL_ARRAY_BUFFER, sizeof(vert), vert, GL_STATIC_DRAW); - pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + return piglit_check_gl_error(GL_NO_ERROR) && pass; +} + +static void +cleanup(GLuint prog, GLuint *pipe, GLuint *vao, GLuint *bo) +{ + glBindProgramPipeline(0); + glDeleteProgram(prog); + glDeleteProgramPipelines(1, pipe); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); + + glDeleteBuffers(1, bo); + glDeleteVertexArrays(1, vao); +} + +static bool +get_uniform_location(GLuint prog, GLint *loc, char *uni_name) +{ + bool pass = true; + *loc = glGetUniformLocation(prog, uni_name); + if (*loc == -1) { + fprintf(stderr, "Failed to get uniform location for %s.\n", + uni_name); + pass = false; + } + return pass; +} + +static bool +test_sampler_conflict(GLuint prog, GLuint pipe, + char *s2_uni_name, char *s3_uni_name) +{ + GLint s2_loc; + GLint s3_loc; + bool pass = true; + + pass = get_uniform_location(prog, &s2_loc, s2_uni_name); + pass = get_uniform_location(prog, &s3_loc, s3_uni_name); /* First, try an invalid configuration. */ @@ -187,17 +239,64 @@ void piglit_init(int argc, char **argv) pass = piglit_check_gl_error(GL_NO_ERROR) && pass; - /* Clean up. - */ - glBindProgramPipeline(0); - glDeleteProgram(prog); - glDeleteProgramPipelines(1, &pipe); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); + return pass; +} + +void piglit_init(int argc, char **argv) +{ + GLuint prog; + GLuint pipe; + GLuint vao; + GLuint bo; + GLint s_loc; + char *s2_uni_name = "s2"; + char *s3_uni_name = "s3"; + char *s2_uni_array_name = "s2[1]"; + char *s3_uni_array_name = "s3[1]"; + bool pass; + + piglit_require_extension("GL_ARB_separate_shader_objects"); + + pass = setup_program(&prog, &pipe, &vao, &bo, &fs_code); + pass = test_sampler_conflict(prog, pipe, + s2_uni_name, s3_uni_name) && pass; + cleanup(prog, &pipe, &vao, &bo); + + pass = setup_program(&prog, &pipe, &vao, &bo, &fs_arrays_code); + /* Initialise all sampler array elements with a unique texture unit*/ + get_uniform_location(prog, &s_loc, "s2[0]"); + glUniform1i(s_loc, 3); + get_uniform_location(prog, &s_loc, "s3[0]"); + glUniform1i(s_loc, 4); + pass = test_sampler_conflict(prog, pipe, s2_uni_array_name, + s3_uni_array_name) && pass; + cleanup(prog, &pipe, &vao, &bo); - glDeleteBuffers(1, &bo); - glDeleteVertexArrays(1, &vao); + if (piglit_is_extension_supported("GL_ARB_arrays_of_arrays")) { + char *s2_uni_aoa_name = "s2[1][1]"; + char *s3_uni_aoa_name = "s3[1][1]"; + + pass = setup_program(&prog, &pipe, &vao, &bo, + &fs_arrays_of_arrays_code); + /* Initialise all sampler array elements + * with a unique texture unit. + */ + get_uniform_location(prog, &s_loc, "s2[0][0]"); + glUniform1i(s_loc, 3); + get_uniform_location(prog, &s_loc, "s3[0][0]"); + glUniform1i(s_loc, 4); + get_uniform_location(prog, &s_loc, "s2[0][1]"); + glUniform1i(s_loc, 5); + get_uniform_location(prog, &s_loc, "s3[0][1]"); + glUniform1i(s_loc, 6); + get_uniform_location(prog, &s_loc, "s2[1][0]"); + glUniform1i(s_loc, 7); + get_uniform_location(prog, &s_loc, "s3[1][0]"); + glUniform1i(s_loc, 8); + pass = test_sampler_conflict(prog, pipe, s2_uni_aoa_name, + s3_uni_aoa_name) && pass; + cleanup(prog, &pipe, &vao, &bo); + } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }