Mesa (master): glsl: move max_index calc to assign_attribute_or_color_locations
Tapani Pälli
tpalli at kemper.freedesktop.org
Wed Jul 29 05:19:44 UTC 2015
Module: Mesa
Branch: master
Commit: b868971e786b849e70675852a0043538bcce0739
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b868971e786b849e70675852a0043538bcce0739
Author: Tapani Pälli <tapani.palli at intel.com>
Date: Mon Jul 27 13:29:20 2015 +0300
glsl: move max_index calc to assign_attribute_or_color_locations
Change function to get all gl_constants for inspection, this is used
by follow-up patch.
v2: rebase, update function documentation
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Reviewed-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
src/glsl/linker.cpp | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 8f2c8ee..c8d2e8e 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2313,12 +2313,10 @@ find_available_slots(unsigned used_mask, unsigned needed_count)
* Assign locations for either VS inputs or FS outputs
*
* \param prog Shader program whose variables need locations assigned
+ * \param constants Driver specific constant values for the program.
* \param target_index Selector for the program target to receive location
* assignmnets. Must be either \c MESA_SHADER_VERTEX or
* \c MESA_SHADER_FRAGMENT.
- * \param max_index Maximum number of generic locations. This corresponds
- * to either the maximum number of draw buffers or the
- * maximum number of generic attributes.
*
* \return
* If locations are successfully assigned, true is returned. Otherwise an
@@ -2326,9 +2324,17 @@ find_available_slots(unsigned used_mask, unsigned needed_count)
*/
bool
assign_attribute_or_color_locations(gl_shader_program *prog,
- unsigned target_index,
- unsigned max_index)
+ struct gl_constants *constants,
+ unsigned target_index)
{
+ /* Maximum number of generic locations. This corresponds to either the
+ * maximum number of draw buffers or the maximum number of generic
+ * attributes.
+ */
+ unsigned max_index = (target_index == MESA_SHADER_VERTEX) ?
+ constants->Program[target_index].MaxAttribs :
+ MAX2(constants->MaxDrawBuffers, constants->MaxDualSourceDrawBuffers);
+
/* Mark invalid locations as being used.
*/
unsigned used_locations = (max_index >= 32)
@@ -3648,12 +3654,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
- if (!assign_attribute_or_color_locations(prog, MESA_SHADER_VERTEX,
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)) {
+ if (!assign_attribute_or_color_locations(prog, &ctx->Const,
+ MESA_SHADER_VERTEX)) {
goto done;
}
- if (!assign_attribute_or_color_locations(prog, MESA_SHADER_FRAGMENT, MAX2(ctx->Const.MaxDrawBuffers, ctx->Const.MaxDualSourceDrawBuffers))) {
+ if (!assign_attribute_or_color_locations(prog, &ctx->Const,
+ MESA_SHADER_FRAGMENT)) {
goto done;
}
More information about the mesa-commit
mailing list