diff options
author | Marek Olšák <[email protected]> | 2013-05-13 15:46:49 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2013-05-28 13:05:30 +0200 |
commit | d4a06d77f5898726e2453ef32795a2183c033c05 (patch) | |
tree | b72e6a5743f0f7abd7d63d30151759970f67246d /src/glsl/tests | |
parent | b4cb857dbfeb89d56ac0eb67ba1d7d5f65e336d4 (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/glsl/tests')
-rw-r--r-- | src/glsl/tests/set_uniform_initializer_tests.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/glsl/tests/set_uniform_initializer_tests.cpp b/src/glsl/tests/set_uniform_initializer_tests.cpp index 55831f914ca..5c6d4a51491 100644 --- a/src/glsl/tests/set_uniform_initializer_tests.cpp +++ b/src/glsl/tests/set_uniform_initializer_tests.cpp @@ -116,7 +116,10 @@ establish_uniform_storage(struct gl_shader_program *prog, unsigned num_storage, prog->UniformStorage[index_to_set].type = type; prog->UniformStorage[index_to_set].array_elements = array_size; prog->UniformStorage[index_to_set].initialized = false; - prog->UniformStorage[index_to_set].sampler = ~0; + for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + prog->UniformStorage[index_to_set].sampler[sh].index = ~0; + prog->UniformStorage[index_to_set].sampler[sh].active = false; + } prog->UniformStorage[index_to_set].num_driver_storage = 0; prog->UniformStorage[index_to_set].driver_storage = NULL; prog->UniformStorage[index_to_set].storage = @@ -134,7 +137,10 @@ establish_uniform_storage(struct gl_shader_program *prog, unsigned num_storage, prog->UniformStorage[i].type = glsl_type::void_type; prog->UniformStorage[i].array_elements = 0; prog->UniformStorage[i].initialized = false; - prog->UniformStorage[i].sampler = ~0; + for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + prog->UniformStorage[i].sampler[sh].index = ~0; + prog->UniformStorage[i].sampler[sh].active = false; + } prog->UniformStorage[i].num_driver_storage = 0; prog->UniformStorage[i].driver_storage = NULL; prog->UniformStorage[i].storage = NULL; |