From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8043CBC6B for ; Mon, 3 Sep 2007 03:37:54 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l831bqT5028466 for ; Mon, 3 Sep 2007 03:37:53 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id l831bomY010943; Mon, 3 Sep 2007 10:37:50 +0900 (JST) Date: Mon, 03 Sep 2007 10:37:41 +0900 (JST) Message-Id: <20070903.103741.77043601.garrigue@math.nagoya-u.ac.jp> To: bhurt@spnz.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] LablGL question From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 46DB6570.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lablgl:01 mli:01 datatype:01 unboxed:01 unboxed:01 unboxing:01 ocaml:01 vectors:01 arrays:01 arrays:01 ocaml:01 alignment:01 caml-list:01 functions:01 tuple:02 From: Brian Hurt > Is there a reason why, in gl.mli, point3 is defined as a tuple, and not a > structure or array or other datatype that holds floats unboxed? Having it > an unboxed type would be a double advantage- unboxing in Ocaml, and the > ability to call the vector vectors on the openGL side of things without > having to copy the data. No deep reason. Just that performance of function calls was not the main motivation, but rather ease of use. Note also that * boxing in caml does not matter that much, as functions using point3 take only one argument of this type, and there are no arrays of points in the API (in that case raw arrays are used, which are unboxed). * ocaml arrays and structures are indeed unboxed, but on some architectures you cannot cast them to (double*) because of alignment restrictions. So at least on those architectures copying is needed. (Well, looking at the glx code in Mesa this seems unnecessary with X11, because it doesn't load those values to registers, but being optimal would be complex indeed.) If performance is you concern, you can use GlArray.vertex to draw a full array of unboxed vertices in one step. Jacques Garrigue