diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index fb032be1e72..1e47bb1ff7c 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -749,6 +749,34 @@ get_next_index(struct nir_link_uniforms_state *state, return index; } +static gl_texture_index +texture_index_for_type(const struct glsl_type *type) +{ + const bool sampler_array = glsl_sampler_type_is_array(type); + switch (glsl_get_sampler_dim(type)) { + case GLSL_SAMPLER_DIM_1D: + return sampler_array ? TEXTURE_1D_ARRAY_INDEX : TEXTURE_1D_INDEX; + case GLSL_SAMPLER_DIM_2D: + return sampler_array ? TEXTURE_2D_ARRAY_INDEX : TEXTURE_2D_INDEX; + case GLSL_SAMPLER_DIM_3D: + return TEXTURE_3D_INDEX; + case GLSL_SAMPLER_DIM_CUBE: + return sampler_array ? TEXTURE_CUBE_ARRAY_INDEX : TEXTURE_CUBE_INDEX; + case GLSL_SAMPLER_DIM_RECT: + return TEXTURE_RECT_INDEX; + case GLSL_SAMPLER_DIM_BUF: + return TEXTURE_BUFFER_INDEX; + case GLSL_SAMPLER_DIM_EXTERNAL: + return TEXTURE_EXTERNAL_INDEX; + case GLSL_SAMPLER_DIM_MS: + return sampler_array ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : + TEXTURE_2D_MULTISAMPLE_INDEX; + default: + assert(!"Should not get here."); + return TEXTURE_BUFFER_INDEX; + } +} + /* Update the uniforms info for the current shader stage */ static void update_uniforms_shader_info(struct gl_shader_program *prog, @@ -786,7 +814,7 @@ update_uniforms_shader_info(struct gl_shader_program *prog, for (unsigned j = sh->Program->sh.NumBindlessSamplers; j < state->next_bindless_sampler_index; j++) { sh->Program->sh.BindlessSamplers[j].target = - glsl_get_sampler_target(type_no_array); + texture_index_for_type(type_no_array); } sh->Program->sh.NumBindlessSamplers = @@ -806,7 +834,7 @@ update_uniforms_shader_info(struct gl_shader_program *prog, for (unsigned i = sampler_index; i < MIN2(state->next_sampler_index, MAX_SAMPLERS); i++) { sh->Program->sh.SamplerTargets[i] = - glsl_get_sampler_target(type_no_array); + texture_index_for_type(type_no_array); state->shader_samplers_used |= 1U << i; state->shader_shadow_samplers |= shadow << i; } diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index c9277be953f..061801e7e60 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -32,6 +32,7 @@ #include #include "glsl_symbol_table.h" +#include "mesa/main/menums.h" /* for gl_api */ /* THIS is a macro defined somewhere deep in the Windows MSVC header files. * Undefine it here to avoid collision with the lexer's THIS token. diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index af8f2e9d02e..a7356e2c7e1 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -331,36 +331,6 @@ glsl_type::contains_subroutine() const } } -gl_texture_index -glsl_type::sampler_index() const -{ - const glsl_type *const t = (this->is_array()) ? this->fields.array : this; - - assert(t->is_sampler() || t->is_image()); - - switch (t->sampler_dimensionality) { - case GLSL_SAMPLER_DIM_1D: - return (t->sampler_array) ? TEXTURE_1D_ARRAY_INDEX : TEXTURE_1D_INDEX; - case GLSL_SAMPLER_DIM_2D: - return (t->sampler_array) ? TEXTURE_2D_ARRAY_INDEX : TEXTURE_2D_INDEX; - case GLSL_SAMPLER_DIM_3D: - return TEXTURE_3D_INDEX; - case GLSL_SAMPLER_DIM_CUBE: - return (t->sampler_array) ? TEXTURE_CUBE_ARRAY_INDEX : TEXTURE_CUBE_INDEX; - case GLSL_SAMPLER_DIM_RECT: - return TEXTURE_RECT_INDEX; - case GLSL_SAMPLER_DIM_BUF: - return TEXTURE_BUFFER_INDEX; - case GLSL_SAMPLER_DIM_EXTERNAL: - return TEXTURE_EXTERNAL_INDEX; - case GLSL_SAMPLER_DIM_MS: - return (t->sampler_array) ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : TEXTURE_2D_MULTISAMPLE_INDEX; - default: - assert(!"Should not get here."); - return TEXTURE_BUFFER_INDEX; - } -} - bool glsl_type::contains_image() const { diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 4c11bbb35f4..96ed6eaec06 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -38,7 +38,6 @@ #ifdef __cplusplus #include "mesa/main/config.h" -#include "mesa/main/menums.h" /* for gl_texture_index, C++'s enum rules are broken */ #endif struct glsl_type; @@ -934,11 +933,6 @@ public: */ bool contains_array() const; - /** - * Get the Mesa texture target index for a sampler type. - */ - gl_texture_index sampler_index() const; - /** * Query whether or not type is an image, or for struct, interface and * array types, contains an image. diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index 8a59b064383..6de94017b9d 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -240,13 +240,6 @@ glsl_get_sampler_result_type(const struct glsl_type *type) return (glsl_base_type)type->sampled_type; } -unsigned -glsl_get_sampler_target(const struct glsl_type *type) -{ - assert(glsl_type_is_sampler(type)); - return type->sampler_index(); -} - int glsl_get_sampler_coordinate_components(const struct glsl_type *type) {