aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniforms.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-05-13 15:46:49 +0200
committerMarek Olšák <[email protected]>2013-05-28 13:05:30 +0200
commitd4a06d77f5898726e2453ef32795a2183c033c05 (patch)
treeb72e6a5743f0f7abd7d63d30151759970f67246d /src/mesa/main/uniforms.c
parentb4cb857dbfeb89d56ac0eb67ba1d7d5f65e336d4 (diff)
mesa: fix GLSL program objects with more than 16 samplers combined
The problem is the sampler units are allocated from the same pool for all shader stages, so if a vertex shader uses 12 samplers (0..11), the fragment shader samplers start at index 12, leaving only 4 sampler units for the fragment shader. The main cause is probably the fact that samplers (texture unit -> sampler unit mapping, etc.) are tracked globally for an entire program object. This commit adapts the GLSL linker and core Mesa such that the sampler units are assigned to sampler uniforms for each shader stage separately (if a sampler uniform is used in all shader stages, it may occupy a different sampler unit in each, and vice versa, an i-th sampler unit may refer to a different sampler uniform in each shader stage), and the sampler-specific variables are moved from gl_shader_program to gl_shader. This doesn't require any driver changes, and it fixes piglit/max-samplers for gallium and classic swrast. It also works with any number of shader stages. v2: - converted tabs to spaces - added an assertion to _mesa_get_sampler_uniform_value Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main/uniforms.c')
-rw-r--r--src/mesa/main/uniforms.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index f0d80f0c812..6d79df6835f 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -45,6 +45,7 @@
#include "main/enums.h"
#include "ir_uniform.h"
#include "glsl_types.h"
+#include "program/program.h"
/**
* Update the vertex/fragment program's TexturesUsed array.
@@ -66,14 +67,18 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
struct gl_program *prog)
{
GLuint s;
+ struct gl_shader *shader =
+ shProg->_LinkedShaders[_mesa_program_target_to_index(prog->Target)];
- memcpy(prog->SamplerUnits, shProg->SamplerUnits, sizeof(prog->SamplerUnits));
+ assert(shader);
+
+ memcpy(prog->SamplerUnits, shader->SamplerUnits, sizeof(prog->SamplerUnits));
memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
for (s = 0; s < MAX_SAMPLERS; s++) {
if (prog->SamplersUsed & (1 << s)) {
- GLuint unit = shProg->SamplerUnits[s];
- GLuint tgt = shProg->SamplerTargets[s];
+ GLuint unit = shader->SamplerUnits[s];
+ GLuint tgt = shader->SamplerTargets[s];
assert(unit < Elements(prog->TexturesUsed));
assert(tgt < NUM_TEXTURE_TARGETS);
prog->TexturesUsed[unit] |= (1 << tgt);