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

Re: [Public WebGL] Re: ReadPixels



On Wed, Mar 24, 2010 at 1:07 AM, Gregg Tavares <gman@google.com> wrote:
>
>
> On Fri, Mar 19, 2010 at 10:30 AM, Gregg Tavares <gman@google.com> wrote:
>>
>> A couple of readPixels issues
>>
>> 1)  I noticed today that apparently some drivers require a glFlush before
>> calling glReadPixels.
>>
>> That's seem like a bug in the driver. The question though is do we want to
>> do or say anything in the spec about this? Like a recommendation that an
>> implementation call glFlush (or glFinish?) before calling glReadPixels just
>> so we don't get inconsistent results across systems?
>>
>> 2) the WebGL readPixels spec doesn't say what the effect of
>> pixelStorei(gl.PACK_ALIGNMENT, ...) has on the buffer returned.
>
>  No comments by anyone on this?

Sorry, I was swamped for the last couple of weeks.

PACK_ALIGNMENT should implicitly change the size of the returned
buffer. In the WebKit WebGL implementation there are a lot of cases
currently unimplemented (basically only RGBA readbacks with
PACK_ALIGNMENT <= 4 are correct) but basically it should honor both
the pack alignment and the requested format. There's no other reason
to support PACK_ALIGNMENT as an argument to pixelStorei.

The last row should not be padded. Row starts are rounded up to the
pack alignment.

-Ken

>> Does the buffer returned have rows padded to the current PACK_ALIGNMENT
>> setting?
>> If so, is the last row of the buffer padded?
>>
>> In otherwords,
>>
>> gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
>> var w = 5;
>> var h = 3;
>> var buf = gl.readPixels(0, 0, w, h, gl.RGB, gl.UNSIGNED_BYTE);
>> var bytesPerPixel = 3;  // RGB
>>
>> buf.length == w * bytesPerPixel * h ?  (each row is 15 bytes)
>>
>> or
>>
>> buf.length == (w * bytesPerPixel + 1) * h ?  (each row is 16 bytes,
>> padded)
>>
>> or
>>
>> buf.length == (w * bytesPerPixel + 1) * (h - 1) + (w * bytesPerPixel) ?
>> (all but the last row is padded)
>>
>> Off the top of my head I feel like since unlike C the user is not passing
>> in the buffer then I'd prefer the rows to be unpadded always but maybe
>> someone else has a good reason to keep them padded?
>>
>>
>
>

-----------------------------------------------------------
You are currently subscribe to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: