W3C home > Mailing lists > Public > public-fx@w3.org > October to December 2011

Re: [css-shaders] GLSL implementation defined limits

From: Chris Marrin <cmarrin@apple.com>
Date: Mon, 14 Nov 2011 11:11:28 -0800
Cc: Gregg Tavares <gman@google.com>, "public-fx@w3.org" <public-fx@w3.org>
Message-id: <8E25E056-7676-4F92-9A44-5A8C5E8068B2@apple.com>
To: Vincent Hardy <vhardy@adobe.com>

On Nov 14, 2011, at 7:36 AM, Vincent Hardy wrote:

>>> ...
>>> So, If a developer makes a page that uses 3 valid shaders and on some hardware out there 1 of them fails because of that hardware's limitations, how is the developer supposed to deal with this? It's especially an issue if the effect the developer is trying to achieve requires that all effects 3 work together. The developer needs a way to either check that all 3 worked, or a way to say check if any one of them failed they should all fail so the page goes back to its non-shader fallback for all 3 effects.
>> 
>> I think the only thing we can do is to preload the shader programs and fallback, either with a @supports mechanism or with passing multiple programs as I've shown.
> 
> Yes, as we discussed earlier in this thread, we need a clear definition of what failure means, and the one you have above (failure to load) makes sense to me. Slow running shaders, do not fit in the failing category. They are in the same boat as slow filter effects (you can write a nasty filter graph that can run well on high end desktop and will be slow on lower end hw) and to some extent in the same boat as slow scripts or pages in general, where the behavior will vary depending on the target hw (granted shaders are a bit different in that they run on the GPU).
> 
> @chris: is your suggestion to tighten up the definition of 'failure' to load in section 3.2? (https://dvcs.w3.org/hg/FXTF/raw-file/tip/custom/index.html, see the description of vertexShader and fragmentShader). The current text is:
> 
> " If the shader cannot be retrieved, or if the shader cannot be loaded or compiled because it contains erroneous code, the shader is a pass through."
> 
> What I would propose is something like this:
> 
> "If the shader cannot be retrieved and run, for any reason (e.g., failure to compile or link), then the custom() function becomes a pass through filter."

I don't think we should mention "and run". A shader may run, but run so slowly that it causes a GPU reset. we can't deal with that. I think a better statement would be:

"If either the vertex or fragment cannot be loaded, a shader fails to compile, or the shader program fails to link, then the custom() function becomes a pass through filter."

I think that covers all the cases of a shader program "failing". I believe that if the link is successful it means you haven't blown any resources. 

> 
> This makes it clearer that the failures can be anything that prevents the shader to run and also adds that a failure in one of the shaders invalidates the whole custom() effect.

Should we mention anything about how failures might be handled? In reading the @supports documentation (http://dev.w3.org/csswg/css3-conditional/), that might be a fine approach. If you say:

@supports ( filter: shader(url(shader.vs) url(shader.fs) ...) ) {
	.myfilter { filter: shader(url(shader.vs) url(shader.fs) ...); }
}

@supports not ( filter: shader(url(shader.vs) url(shader.fs) ...) ) {
	.myfilter { filter: shader(url(fallback.vs) url(fallback.fs) ...); }
}

then you can compile and link the shader in the @supports statement, and know at that point whether or not it can be used. This is pretty wordy, requiring the shader to be stated 3 times. It would be nice if @supports had the ability to have an else clause, like:

@supports ( filter: shader(url(shader.vs) url(shader.fs) ...) ) {
	.myfilter { filter: shader(url(shader.vs) url(shader.fs) ...); }
}
@else {
	.myfilter { filter: shader(url(fallback.vs) url(fallback.fs) ...); }
}

to cut out one of those. But maybe that's overkill. either way, you'd need to encapsulate the shader program and make it possible to compare programs to avoid needless reconstruction of the shader.

-----
~Chris
cmarrin@apple.com
Received on Monday, 14 November 2011 19:12:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 14 November 2011 19:12:09 GMT