diff options
author | Timothy Arceri <[email protected]> | 2016-11-09 09:49:59 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-01-06 11:21:42 +1100 |
commit | 076ab157ff2ed7a98b09363bce355247f4ed71e6 (patch) | |
tree | 1df981f143864f8a22871471fa6cd78f5e577f10 /src | |
parent | 937523971f42f37b40badb962e575ecd8258b2d5 (diff) |
st/mesa/glsl: move SamplerTargets to gl_program
This will help allow us to simplify the handling of samplers by
storing them in a single location rather than duplicating them in
both gl_linked_shader and gl_program.
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/link_uniforms.cpp | 7 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 14 | ||||
-rw-r--r-- | src/mesa/main/uniform_query.cpp | 2 | ||||
-rw-r--r-- | src/mesa/main/uniforms.c | 2 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 |
6 files changed, 16 insertions, 13 deletions
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index 8604dba4b07..57a7db41ff4 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/glsl/link_uniforms.cpp @@ -1248,10 +1248,11 @@ link_assign_uniform_storage(struct gl_context *ctx, parcel.shader_samplers_used; prog->_LinkedShaders[i]->shadow_samplers = parcel.shader_shadow_samplers; - STATIC_ASSERT(sizeof(prog->_LinkedShaders[i]->SamplerTargets) == + STATIC_ASSERT(sizeof(prog->_LinkedShaders[i]->Program->sh.SamplerTargets) == sizeof(parcel.targets)); - memcpy(prog->_LinkedShaders[i]->SamplerTargets, parcel.targets, - sizeof(prog->_LinkedShaders[i]->SamplerTargets)); + memcpy(prog->_LinkedShaders[i]->Program->sh.SamplerTargets, + parcel.targets, + sizeof(prog->_LinkedShaders[i]->Program->sh.SamplerTargets)); } #ifndef NDEBUG diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6ab5cdeec4e..243c76ded14 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2004,6 +2004,11 @@ struct gl_program struct gl_uniform_block **UniformBlocks; struct gl_uniform_block **ShaderStorageBlocks; + /** Which texture target is being sampled + * (TEXTURE_1D/2D/3D/etc_INDEX) + */ + gl_texture_index SamplerTargets[MAX_SAMPLERS]; + union { struct { /** @@ -2359,9 +2364,6 @@ struct gl_linked_shader GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */ /*@}*/ - /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ - gl_texture_index SamplerTargets[MAX_SAMPLERS]; - /** * Number of default uniform block components used by this shader. * @@ -2392,14 +2394,14 @@ struct gl_linked_shader struct gl_shader_info info; }; -static inline GLbitfield gl_external_samplers(struct gl_linked_shader *shader) +static inline GLbitfield gl_external_samplers(struct gl_program *prog) { GLbitfield external_samplers = 0; - GLbitfield mask = shader->Program->SamplersUsed; + GLbitfield mask = prog->SamplersUsed; while (mask) { int idx = u_bit_scan(&mask); - if (shader->SamplerTargets[idx] == TEXTURE_EXTERNAL_INDEX) + if (prog->sh.SamplerTargets[idx] == TEXTURE_EXTERNAL_INDEX) external_samplers |= (1 << idx); } diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 047d21a85cf..145eff01756 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -1107,7 +1107,7 @@ _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline) while (mask) { const int s = u_bit_scan(&mask); GLuint unit = shader->Program->SamplerUnits[s]; - GLuint tgt = shader->SamplerTargets[s]; + GLuint tgt = shader->Program->sh.SamplerTargets[s]; /* FIXME: Samplers are initialized to 0 and Mesa doesn't do a * great job of eliminating unused uniforms currently so for now diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 5534fcf2abe..51db39e63a0 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -80,7 +80,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg, while (mask) { const int s = u_bit_scan(&mask); GLuint unit = prog->SamplerUnits[s]; - GLuint tgt = shader->SamplerTargets[s]; + GLuint tgt = prog->sh.SamplerTargets[s]; assert(unit < ARRAY_SIZE(prog->TexturesUsed)); assert(tgt < NUM_TEXTURE_TARGETS); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 59aef12b1e3..f7797e28fa3 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2918,7 +2918,7 @@ get_mesa_program(struct gl_context *ctx, do_set_program_inouts(shader->ir, prog, shader->Stage); prog->ShadowSamplers = shader->shadow_samplers; - prog->ExternalSamplersUsed = gl_external_samplers(shader); + prog->ExternalSamplersUsed = gl_external_samplers(prog); _mesa_update_shader_textures_used(shader_program, prog); /* Set the gl_FragDepth layout. */ diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index d5309e49fab..60d101c91d8 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -413,7 +413,7 @@ st_nir_get_mesa_program(struct gl_context *ctx, } prog->ShadowSamplers = shader->shadow_samplers; - prog->ExternalSamplersUsed = gl_external_samplers(shader); + prog->ExternalSamplersUsed = gl_external_samplers(prog); _mesa_update_shader_textures_used(shader_program, prog); /* Avoid reallocation of the program parameter list, because the uniform |