[Mesa-dev] [PATCH 05/21] glsl: Pass _mesa_glsl_parse_state into matching_signature and such.

Kenneth Graunke kenneth at whitecape.org
Sun Sep 8 19:49:52 PDT 2013


On 09/08/2013 08:48 AM, Paul Berry wrote:
> On 4 September 2013 15:22, Kenneth Graunke <kenneth at whitecape.org
> <mailto:kenneth at whitecape.org>> wrote:
>
>     During compilation, we'll use this to determine built-in availability.
>     All the prototypes will be available, but we can filter out the ones
>     that aren't actually available.
>
>
> I'm having trouble understanding this sentence because it sounds like
> you're using the word "available" to mean two different things.  Do you
> perhaps mean something like "when looking up the name of a built-in
> function, we'll iterate through a list of all the prototypes that exist
> in all GLSL versions and extensions, but we'll filter out the ones that
> aren't actually available in the current GLSL version with the currently
> enabled extensions"?

Poor wording on my part; your understanding is basically correct.

I've replaced it with this text:
"The plan is to have a single shader containing every built-in in every
version of the language, but filter out the ones that aren't actually
available to the shader being compiled."

>     At link time, we don't actually need this filtering capability, since
>     we've already imported the prototypes and flagged them as "is_builtin."
>
>
> This sentence tripped me up a bit since the last patch removed the
> "is_builtin" flag in favor of a function.  Do you mean to say that we've
> already imported the prototypes and given them a non-null builtin_info
> (so is_builtin() will return true)?

By "is_builtin flag" I meant "the value of the is_builtin() method."

>
>     The linker won't import additional prototypes, so it won't pull in any
>     unavailable built-ins.  Conversely, the is_builtin flag will prevent a
>     shader from defining its own prototype and fooling the linker to import
>     a built-in's body.
>
>
> Similarly, in this case do you mean "conversely, prototypes defined by
> the shader will have builtin_info = null, so they will return false for
> is_builtin() and that will prevent the linker from trying to import a
> built-in's body for those functions"?
>
>       All that to say: we can just pass in NULL.  It'll be
>     fine.

Yes.  I've replaced this text with:

"At link time, we don't actually need this filtering capability: we've
already imported prototypes for every built-in that the shader actually
calls, and they're flagged as is_builtin().  The linker doesn't import
any additional prototypes, so it won't pull in any unavailable
built-ins.  When resolving prototypes to function definitions, the
linker ensures the values of is_builtin() match, which means that a
shader can't trick the linker into importing the body of an unavailable
built-in by defining a suspiciously similar prototype.

In other words, during linking, we can just pass in NULL.  It will work
out fine."


More information about the mesa-dev mailing list