mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-01 16:10:09 +01:00
nir/gl: Move glsl_type::sampler_target() into a helper in its one caller
The new version also doesn't need to worry about arrays of textures because the caller already takes care of that. Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24503>
This commit is contained in:
parent
f17c5297d7
commit
f2f4e811be
5 changed files with 31 additions and 45 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue