[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] typed array convenience

On Tue, Oct 28, 2014 at 2:42 PM, Jussi Kalliokoski <jussi.kalliokoski@gmail.com> wrote:
On Tue, Oct 28, 2014 at 3:15 PM, Mark Callow <khronos@callow.im> wrote:

On Oct 28, 2014, at 8:04 PM, Florian Bösch <pyalot@gmail.com> wrote:

I propose an addition to the typed array specification that introduces these methods like
  • argcpy(uint dstOffset, arguments...)
  • arrcpy(uint dstOffset, Array|TypedArrayView someArray)
dst.set(someArray, dstOffset);

dst.set(0, 1, 2, 3, 4) --> invalid argument errort, not a substitute for argcpy suggestion.

dst.set([1,2,3,4], dstOffset) is substantially slower than one at a time assignment (it's the second slowest method in fact). Updated jsperf http://jsperf.com/typed-array-fast-filling, attached screenshot http://codeflow.org/pictures/typed-array-test.png, blue on the bottom is array.set.
  • memcpy(uint dstByteOffset, TypedArray[View] origin, uint srcByteOffset, uint srcByteCount)
dst.set(src.subarray(srcOffset, srcOffset + srcByteCount), dstOffset);

You do not want to allocate an object a million times if you can avoid it in an on-line preprocessing step to copy memory from one array to another. Likewise, you do not want to allocate a GCed object oftentime at runtime for fairly obvious reasons.

Attachment: typed-array-test.png
Description: PNG image