From patchwork Tue Apr 2 19:58:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Gall X-Patchwork-Id: 15824 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 448D823E00 for ; Tue, 2 Apr 2013 19:58:53 +0000 (UTC) Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by fiordland.canonical.com (Postfix) with ESMTP id 1E2CBA18973 for ; Tue, 2 Apr 2013 19:58:53 +0000 (UTC) Received: by mail-we0-f198.google.com with SMTP id k14sf1024807wer.1 for ; Tue, 02 Apr 2013 12:58:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=8m1FCqtfBphxVq8EPcTFNeE7STKzeBcqRRrJJtPOZ1M=; b=YfFhIiWTwM6eL6rOCrjWMB+EHHnDrStkRrff/UweNr6ub+CFXi1wV5DS3Qq7HSTneZ GK3+Epf5DPoFG02d/vUAYcMWDYoUvxk5j1ifjGyVhTR/HrCb3dGvYaoHpP/UYbK/L4K6 ntW160HWEIiESF62RBMCTaXi81aM7TkakeLWEjyGLsm4pAEAV6Fv1B8P/P77mHKgq2xL jrzEQcZ3zqvOTSNwaSCpL/Bh/9NR9QN4nipUz3qX8kxT/u0Ib3DtwLtA7ek7bPlFYIkT EdJUeGOqGZ2ctiX4EhpqW4jqLiTTg/H8iYJC2QmBr9Jk3k89fkoNjEO84yUFJ1MWXXr4 aQzQ== X-Received: by 10.180.10.230 with SMTP id l6mr3406615wib.3.1364932732965; Tue, 02 Apr 2013 12:58:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.81.67 with SMTP id y3ls370038wix.51.gmail; Tue, 02 Apr 2013 12:58:52 -0700 (PDT) X-Received: by 10.180.181.72 with SMTP id du8mr18295671wic.27.1364932732907; Tue, 02 Apr 2013 12:58:52 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id co4si1235313wib.15.2013.04.02.12.58.52 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Apr 2013 12:58:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id jw11so1011933veb.22 for ; Tue, 02 Apr 2013 12:58:51 -0700 (PDT) X-Received: by 10.52.20.239 with SMTP id q15mr11825556vde.73.1364932731696; Tue, 02 Apr 2013 12:58:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp140793ved; Tue, 2 Apr 2013 12:58:51 -0700 (PDT) X-Received: by 10.236.121.161 with SMTP id r21mr16065281yhh.2.1364932730906; Tue, 02 Apr 2013 12:58:50 -0700 (PDT) Received: from mail-gg0-x229.google.com (mail-gg0-x229.google.com [2607:f8b0:4002:c02::229]) by mx.google.com with ESMTPS id u50si2627645yhk.273.2013.04.02.12.58.50 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Apr 2013 12:58:50 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:4002:c02::229 is neither permitted nor denied by best guess record for domain of tom.gall@linaro.org) client-ip=2607:f8b0:4002:c02::229; Received: by mail-gg0-f169.google.com with SMTP id j5so123062ggn.14 for ; Tue, 02 Apr 2013 12:58:50 -0700 (PDT) X-Received: by 10.236.31.232 with SMTP id m68mr16248713yha.19.1364932730548; Tue, 02 Apr 2013 12:58:50 -0700 (PDT) Received: from localhost.localdomain ([70.35.96.184]) by mx.google.com with ESMTPS id s16sm5141567yhj.13.2013.04.02.12.58.48 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Apr 2013 12:58:49 -0700 (PDT) From: Tom Gall To: piglit@lists.freedesktop.org Cc: patches@linaro.org, Tom Gall Subject: =?UTF-8?q?=5BPATCH=202/3=5D=20add=20generated=5Ftests/gen=5Fnon-lvalue=5Fes-tests=2Epy?= Date: Tue, 2 Apr 2013 14:58:32 -0500 Message-Id: <1364932713-8221-2-git-send-email-tom.gall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364932713-8221-1-git-send-email-tom.gall@linaro.org> References: <1364932713-8221-1-git-send-email-tom.gall@linaro.org> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQntpYtNSOn2PttIHMpnleXOCoVHL/43nlYew80Rh/lKIDONj7PA9/Q25ypGMRtLtF1bXE0a X-Original-Sender: tom.gall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This adds a series l-value tests for glslparsertest. This new python code creates glsl es versions of the tests. This "new" code was directly based on generated_tests/gen_non-lvalue_tests.py. The new es version outputs to generated_tests/spec/glsl-es-1.00. Signed-off-by: Tom Gall --- generated_tests/gen_non-lvalue_es-tests.py | 174 ++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 generated_tests/gen_non-lvalue_es-tests.py diff --git a/generated_tests/gen_non-lvalue_es-tests.py b/generated_tests/gen_non-lvalue_es-tests.py new file mode 100644 index 0000000..cc254fd --- /dev/null +++ b/generated_tests/gen_non-lvalue_es-tests.py @@ -0,0 +1,174 @@ +# coding=utf-8 +# +# Copyright © 2012 Intel Corporation +# Copyright © 2013 Linaro Inc +# +# 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. + +import os + + +class TestES1(object): + def __init__(self, type_name, op, usage, shader_target): + self.type_name = type_name + self.op = op + self.usage = usage + self.shader_target = shader_target + + def filename(self): + if self.op == "++t": + name_base = "preincrement" + elif self.op == "--t": + name_base = "predecrement" + elif self.op == "t++": + name_base = "postincrement" + elif self.op == "t--": + name_base = "postdecrement" + + return os.path.join('spec', + 'glsl-es-1.00', + 'compiler', + 'expressions', + '{0}-{1}-non-lvalue-for-{2}.{3}'.format( + name_base, self.type_name, self.usage, + self.shader_target)) + + def generate(self): + if self.usage == 'assignment': + test = """/* [config] + * expect_result: fail + * glsl_version: 1.00 + * [end config] + * + * Page 46, Section 5.8 of the GLSL ES 1.00.17 spec says: + * + * "Variables that are built-in types, entire structures, structure + * fields, l-values with the field selector ( . ) applied to select + * components or swizzles without repeated fields, l-values within + * parentheses and and l-values dereferenced with the array subscript + * operator ( [ ] ) are all l-values. Other unary, binary, ternary + * expressions, are not l-values. This includes assignments, function + * names, swizzles with repeated fields and constants. + * + * Array variables are l-values and maybe passed to parameters declared as + * out or inout. However, they may not be used as the target of assignment. + * Similiarly, structures containing arrays may be passed to parameters + * declared as out or inout but may not be used as the target of an + * assignment. + */ +uniform {self.type_name} u; +{mode} vec4 v; + +void main() +{{ + {self.type_name} t = u; + + {self.op} = {self.type_name}(v{components}); + {dest} = {var_as_vec4}; +}} +""" + else: + test = """/* [config] + * expect_result: fail + * glsl_version: 1.00 + * [end config] + * + * Page 46, Section 5.8 of the GLSL ES 1.00.17 spec says: + * + * "Variables that are built-in types, entire structures, structure + * fields, l-values with the field selector ( . ) applied to select + * components or swizzles without repeated fields, l-values within + * parentheses and and l-values dereferenced with the array subscript + * operator ( [ ] ) are all l-values. Other unary, binary, ternary + * expressions, are not l-values. This includes assignments, function + * names, swizzles with repeated fields and constants. + * + * Array variables are l-values and maybe passed to parameters declared as + * out or inout. However, they may not be used as the target of assignment. + * Similiarly, structures containing arrays may be passed to parameters + * declared as out or inout but may not be used as the target of an + * assignment. + */ +uniform {self.type_name} u; +{mode} vec4 v; + +void f(out {self.type_name} p) +{{ + p = {self.type_name}(v{components}); +}} + +void main() +{{ + {self.type_name} t = u; + + f({self.op}); + {dest} = {var_as_vec4}; +}} +""" + if '2' in self.type_name: + var_as_vec4 = 'vec4(t.xyxy)' + components = '.xy' + elif '3' in self.type_name: + var_as_vec4 = 'vec4(t.xyzx)' + components = '.xyz' + elif '4' in self.type_name: + var_as_vec4 = 'vec4(t)' + components = '' + else: + var_as_vec4 = 'vec4(t)' + components = '.x' + + if self.shader_target == 'vert': + dest = "gl_Position" + mode = 'attribute' + else: + mode = 'varying' + dest = "gl_FragColor" + + test = test.format(self = self, + components = components, + dest = dest, + var_as_vec4 = var_as_vec4, + mode = mode) + + filename = self.filename() + dirname = os.path.dirname(filename) + if not os.path.exists(dirname): + os.makedirs(dirname) + with open(filename, 'w') as f: + f.write(test) + + +def all_tests(): + for type_name in ['float', 'vec2', 'vec3', 'vec4', + 'int', 'ivec2', 'ivec3', 'ivec4']: + for op in ["++t", "--t", "t++", "t--"]: + for usage in ['assignment', 'out-parameter']: + for shader_target in ['vert', 'frag']: + yield TestES1(type_name, op, usage, shader_target) + +def main(): + for test in all_tests(): + test.generate() + print test.filename() + + +if __name__ == '__main__': + main()