[Mesa-dev] [PATCH 1/2] mesa: Extract is_active_attrib() in shaderapi
Kenneth Graunke
kenneth at whitecape.org
Sat Apr 12 23:56:34 PDT 2014
On 04/12/2014 02:20 AM, Chris Forbes wrote:
> The rules are about to get a bit more complex to account for
> gl_InstanceID and gl_VertexID, which are system values.
>
> Extracting this first avoids introducing duplication.
>
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
> src/mesa/main/shader_query.cpp | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
> index e1afe53..c6e7342 100644
> --- a/src/mesa/main/shader_query.cpp
> +++ b/src/mesa/main/shader_query.cpp
> @@ -76,6 +76,20 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index,
> */
> }
>
> +static bool
> +is_active_attrib(const ir_variable *var) {
{ goes on its own line.
With that fixed, these two get:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
I like the refactor here. Nice catch in patch 2.
> + if (!var)
> + return false;
> +
> + switch (var->data.mode) {
> + case ir_var_shader_in:
> + return var->data.location != -1;
> +
> + default:
> + return false;
> + }
> +}
> +
> void GLAPIENTRY
> _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
> GLsizei maxLength, GLsizei * length, GLint * size,
> @@ -105,10 +119,8 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
> foreach_list(node, ir) {
> const ir_variable *const var = ((ir_instruction *) node)->as_variable();
>
> - if (var == NULL
> - || var->data.mode != ir_var_shader_in
> - || var->data.location == -1)
> - continue;
> + if (!is_active_attrib(var))
> + continue;
>
> if (current_index == desired_index) {
> _mesa_copy_string(name, maxLength, length, var->name);
> @@ -196,10 +208,8 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg)
> foreach_list(node, ir) {
> const ir_variable *const var = ((ir_instruction *) node)->as_variable();
>
> - if (var == NULL
> - || var->data.mode != ir_var_shader_in
> - || var->data.location == -1)
> - continue;
> + if (!is_active_attrib(var))
> + continue;
>
> i++;
> }
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140412/8ce98d97/attachment.sig>
More information about the mesa-dev
mailing list