From ee3da89b197fa0aa063be6fcabddec284cc00bec Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 24 Nov 2008 08:33:49 -0700 Subject: [PATCH] mesa: add Flags field to gl_program_parameter Only one flag defined so far: PROG_PARAM_CENTROID_BIT (cherry picked from commit 0f228d7ab3b7c03328df369b8db50c469ac5dcd6) --- src/mesa/shader/prog_parameter.c | 31 +++++++++++++++------------ src/mesa/shader/prog_parameter.h | 24 ++++++++++++++------- src/mesa/shader/slang/slang_codegen.c | 4 +++- src/mesa/shader/slang/slang_link.c | 3 ++- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index e1729c7bff2..5d8f3a5330f 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.3 * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -80,7 +80,8 @@ GLint _mesa_add_parameter(struct gl_program_parameter_list *paramList, enum register_file type, const char *name, GLuint size, GLenum datatype, const GLfloat *values, - const gl_state_index state[STATE_LENGTH]) + const gl_state_index state[STATE_LENGTH], + GLbitfield flags) { const GLuint oldNum = paramList->NumParameters; const GLuint sz4 = (size + 3) / 4; /* no. of new param slots needed */ @@ -125,6 +126,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, p->Type = type; p->Size = size; p->DataType = datatype; + p->Flags = flags; if (values) { COPY_4V(paramList->ParameterValues[oldNum + i], values); values += 4; @@ -156,7 +158,7 @@ _mesa_add_named_parameter(struct gl_program_parameter_list *paramList, const char *name, const GLfloat values[4]) { return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name, - 4, GL_NONE, values, NULL); + 4, GL_NONE, values, NULL, 0x0); } @@ -187,7 +189,7 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList, #endif size = 4; /** XXX fix */ return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, name, - size, GL_NONE, values, NULL); + size, GL_NONE, values, NULL, 0x0); } @@ -239,7 +241,7 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, /* add a new parameter to store this constant */ pos = _mesa_add_parameter(paramList, PROGRAM_CONSTANT, NULL, - size, GL_NONE, values, NULL); + size, GL_NONE, values, NULL, 0x0); if (pos >= 0 && swizzleOut) { if (size == 1) *swizzleOut = SWIZZLE_XXXX; @@ -273,7 +275,7 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList, } else { i = _mesa_add_parameter(paramList, PROGRAM_UNIFORM, name, - size, datatype, values, NULL); + size, datatype, values, NULL, 0x0); return i; } } @@ -328,7 +330,7 @@ _mesa_add_sampler(struct gl_program_parameter_list *paramList, } value = (GLfloat) numSamplers; (void) _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name, - size, datatype, &value, NULL); + size, datatype, &value, NULL, 0x0); return numSamplers; } } @@ -339,7 +341,7 @@ _mesa_add_sampler(struct gl_program_parameter_list *paramList, */ GLint _mesa_add_varying(struct gl_program_parameter_list *paramList, - const char *name, GLuint size) + const char *name, GLuint size, GLbitfield flags) { GLint i = _mesa_lookup_parameter_index(paramList, -1, name); if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_VARYING) { @@ -349,7 +351,7 @@ _mesa_add_varying(struct gl_program_parameter_list *paramList, else { /*assert(size == 4);*/ i = _mesa_add_parameter(paramList, PROGRAM_VARYING, name, - size, GL_NONE, NULL, NULL); + size, GL_NONE, NULL, NULL, flags); return i; } } @@ -378,7 +380,7 @@ _mesa_add_attribute(struct gl_program_parameter_list *paramList, if (size < 0) size = 4; i = _mesa_add_parameter(paramList, PROGRAM_INPUT, name, - size, datatype, NULL, state); + size, datatype, NULL, state, 0x0); } return i; } @@ -445,7 +447,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList, name = _mesa_program_state_string(stateTokens); index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name, size, GL_NONE, - NULL, (gl_state_index *) stateTokens); + NULL, (gl_state_index *) stateTokens, 0x0); paramList->StateFlags |= _mesa_program_state_flags(stateTokens); /* free name string here since we duplicated it in add_parameter() */ @@ -616,7 +618,7 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list) struct gl_program_parameter *pCopy; GLuint size = MIN2(p->Size, 4); GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType, - list->ParameterValues[i], NULL); + list->ParameterValues[i], NULL, 0x0); ASSERT(j >= 0); pCopy = clone->Parameters + j; pCopy->Used = p->Used; @@ -657,7 +659,8 @@ _mesa_combine_parameter_lists(const struct gl_program_parameter_list *listA, _mesa_add_parameter(list, param->Type, param->Name, param->Size, param->DataType, listB->ParameterValues[i], - param->StateIndexes); + param->StateIndexes, + param->Flags); } } } diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h index 0c35198de7e..829fd25d55f 100644 --- a/src/mesa/shader/prog_parameter.h +++ b/src/mesa/shader/prog_parameter.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.3 * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -35,12 +35,18 @@ #include "prog_statevars.h" +/** + * Program parameter flags + */ +/*@{*/ +#define PROG_PARAM_CENTROID_BIT 0x1 +/*@}*/ + + + /** * Program parameter. - * Used for NV_fragment_program for "DEFINE"d constants and "DECLARE"d - * parameters. - * Also used by ARB_vertex/fragment_programs for state variables, etc. - * Used by shaders for uniforms, constants, varying vars, etc. + * Used by shaders/programs for uniforms, constants, varying vars, etc. */ struct gl_program_parameter { @@ -50,6 +56,7 @@ struct gl_program_parameter GLuint Size; /**< Number of components (1..4) */ GLboolean Used; /**< Helper flag for GLSL uniform tracking */ GLboolean Initialized; /**< Has the ParameterValue[] been set? */ + GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ /** * A sequence of STATE_* tokens and integers to identify GL state. */ @@ -94,7 +101,8 @@ extern GLint _mesa_add_parameter(struct gl_program_parameter_list *paramList, enum register_file type, const char *name, GLuint size, GLenum datatype, const GLfloat *values, - const gl_state_index state[STATE_LENGTH]); + const gl_state_index state[STATE_LENGTH], + GLbitfield flags); extern GLint _mesa_add_named_parameter(struct gl_program_parameter_list *paramList, @@ -125,7 +133,7 @@ _mesa_add_sampler(struct gl_program_parameter_list *paramList, extern GLint _mesa_add_varying(struct gl_program_parameter_list *paramList, - const char *name, GLuint size); + const char *name, GLuint size, GLbitfield flags); extern GLint _mesa_add_attribute(struct gl_program_parameter_list *paramList, diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index fa653055f32..0f004c813eb 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3776,7 +3776,9 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, if (prog) { /* user-defined varying */ - GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, totalSize); + GLbitfield flags = 0x0; + GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, + totalSize, flags); GLuint swizzle = _slang_var_swizzle(size, 0); store = _slang_new_ir_storage_swz(PROGRAM_VARYING, varyingLoc, totalSize, swizzle); diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 79fd9a064f5..fcd7fbf3ca1 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -103,7 +103,8 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog) } else { /* not already in linked list */ - j = _mesa_add_varying(shProg->Varying, var->Name, var->Size); + j = _mesa_add_varying(shProg->Varying, var->Name, var->Size, + var->Flags); } /* map varying[i] to varying[j]. -- 2.30.2