There is a fail path in r300g that has been working very well for us. If shader compilation fails, a dummy shader emitting one instruction is used (usually outputting (0,0,0,1) into the first output). This approach allows the applications with failing shaders to run with misrendering on specific objects (in case of a fragment shader failure) or with missing objects (in case of a vertex shader failure). The fact there is no crash or abort or anything preventing the apps from running makes some of them usable. It also makes debugging easier, because all failing shaders must go through the r300 compiler and we can analyze whether the compiler is doing a good job in reducing the number of instructions and temporaries, and whether we can do something about it to make it better.<br>
<br>If we are about to introduce new shader error enums, I'd like to preserve the current r300g behavior for OpenGL apps, because it appears to be a win in most cases.<br><br>Marek<br><br><div class="gmail_quote">On Tue, Mar 15, 2011 at 1:31 AM, Brian Paul <span dir="ltr"><<a href="mailto:brian.e.paul@gmail.com" target="_blank">brian.e.paul@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div>On Mon, Mar 14, 2011 at 1:07 PM, José Fonseca <<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a>> wrote:<br>
> On Mon, 2011-03-14 at 11:23 -0700, Brian Paul wrote:<br>
>> On 03/12/2011 07:44 PM, Marek Olšák wrote:<br>
>> > The r300 compiler can eliminate unused uniforms and remap uniform locations<br>
>> > if their number surpasses hardware limits, so the limit is actually<br>
>> > NumParameters + NumUnusedParameters. This is important for some apps<br>
>> > under Wine to run.<br>
>> ><br>
>> > Wine sometimes declares a uniform array of 256 vec4's and some Wine-specific<br>
>> > constants on top of that, so in total there is more uniforms than r300 can<br>
>> > handle. This was the main motivation for implementing the elimination<br>
>> > of unused constants.<br>
>> ><br>
>> > We should allow drivers to implement fail& recovery paths where it makes<br>
>> > sense, so giving up too early especially when comes to uniforms is not<br>
>> > so good idea, though I agree there should be some hard limit for all drivers.<br>
>><br>
>> I added the check_resources() code to fix an issue with the SVGA<br>
>> driver. If we can't do resource checking against the<br>
>> ctx->Const.Vertex/FragmentProgram limits we need something else.<br>
>><br>
>> In Gallium we have the PIPE_SHADER_CAP_MAX_x queries. Are you saying<br>
>> we shouldn't check shaders against those limits either?<br>
>><br>
>> If we were to push all the shader resource checking down into the<br>
>> Gallium drivers we'll need a new way to propagate error messages back<br>
>> to the user (we can only return NULL from create_X_state() now).<br>
>> Another other problem would be instituting consistant error reporting<br>
>> across all the drivers.<br>
>><br>
>> We've kind of tiptoed around this issue in the past. It's probably<br>
>> time to come up with some real solutions.<br>
><br>
> Not only some drivers are able to optimize away declared-yet-unused<br>
> registers; but other drivers drivers may actually need to add extra<br>
> temps/const regs to implement certain opcodes/state. Both issues make it<br>
> difficult to make guarantees around PIPE_SHADER_CAP_MAX_x, as we can<br>
> easily end up advertising too little or too much.<br>
><br>
> It looks there's not much alternative to mimicking GLSL here, i.e.,<br>
> advertise these as limits but allow concrete shaders to pass/fail to<br>
> compile on a case-by-case basis.<br>
><br>
> I'm not sure what's the best what to convey errors from the drivers: to<br>
> return pipe_error and extend it to include things like<br>
> PIPE_ERROR_TOO_MANY_CONSTS<br>
> PIPE_ERROR_TOO_MANY_TEMPS<br>
> PIPE_ERROR_TOO_MANY_INSTRUCTIONS<br>
> etc.<br>
> and translate them in the state tracker; or use message strings. At a<br>
> glance, it looks like an error enum would be expressive enough for most<br>
> stuff.<br>
<br>
</div></div>That would probably be a good first step. We should probably think a<br>
bit more to see if we could get by with a simple set of enumerated<br>
error codes or if we need a way to convey details.<br>
<br>
Probably the least Gallium interface change would be to add a simple<br>
pipe->get_shader_error() that would return PIPE_ERROR_x if the<br>
previous create_fs/vs/gs_state() call returned NULL.<br>
<br>
I think we can still do some resource checking at a high level in Mesa<br>
and the state tracker. For example, the number of texture units and<br>
the number of constant buffers seem to be pretty solid limits.<br>
<font color="#888888"><br>
-Brian<br>
</font><div><div></div><div>_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br>