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

Re: [Public WebGL] Index Validation and using the same buffer for both GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER



On Jan 12, 2010, at 3:23 PM, Gregg Tavares wrote:

> I was in the process of writing some index validation code before calling glDrawElements and I found out that apparently some WebGL implementations currently assume that the same buffer will never be used for both a GL_ARARY_BUFFER and a GL_ELEMENT_ARRAY_BUFFER.
> 
> as in
> 
>     buf = ctx.createBuffer();
>     ctx.bindBuffer(ctx.ARRAY_BUFFER, buf);
>     ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, buf);
> 
> The spec does not disallow this. 
> 
> My understanding is the reason some implementations assumed this would never happen was that to efficiently validate the indices, client side shadow copies of the buffer data needed to be kept. If there is an assumption that any buffer bound to GL_ELEMENT_ARRAY_BUFFER will only ever be bound to GL_ELEMENT_ARRAY_BUFFER then only the few buffers that are bound to GL_ELEMENT_ARRAY_BUFFER need to be shadowed.

I will assume you're talking about the WebKit implementation. When I did that, I tried not to make an assumption that they would be different buffers. It tried to keep information about both types separate so a single buffer could represent both. If you use the same buffer for both you'd be shadowing much more than you needed to, but I think it should still work. Let me know what the case is where this will fail if the same buffer is used for both and we can see if it can be fixed. 

>  
> The problem is that makes these implementations fail if the user does use the same buffer for both as in the example above.
> 
> If this optimization is important than it seems like we should make it part of the spec and require that a buffer can only be ever bound to one or the other. That way, we'll get the same results on all implementations. Otherwise, it seems like we need a conformance test to make sure implementations are not taking this shortcut as programs that are spec compliant will only run on some implementations.

If it turns out to be problematic to use the same buffer for both we should talk about disallowing it. But let's make sure we can't make an efficient implementation without that restriction first.

Vlad, have you written this code for Mozilla? Are you having issues with a common buffer and shadowing?

-----
~Chris
cmarrin@apple.com




-----------------------------------------------------------
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: