101e04c3fSmrg/*
201e04c3fSmrg * Copyright © 2018 Intel Corporation
301e04c3fSmrg *
401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a
501e04c3fSmrg * copy of this software and associated documentation files (the "Software"),
601e04c3fSmrg * to deal in the Software without restriction, including without limitation
701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the
901e04c3fSmrg * Software is furnished to do so, subject to the following conditions:
1001e04c3fSmrg *
1101e04c3fSmrg * The above copyright notice and this permission notice (including the next
1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the
1301e04c3fSmrg * Software.
1401e04c3fSmrg *
1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2101e04c3fSmrg * DEALINGS IN THE SOFTWARE.
2201e04c3fSmrg */
2301e04c3fSmrg
2401e04c3fSmrg#ifndef GLSL_LINKER_UTIL_H
2501e04c3fSmrg#define GLSL_LINKER_UTIL_H
2601e04c3fSmrg
277ec681f3Smrg#include "util/bitset.h"
287ec681f3Smrg
297ec681f3Smrgstruct gl_context;
3001e04c3fSmrgstruct gl_shader_program;
3101e04c3fSmrgstruct gl_uniform_storage;
3201e04c3fSmrg
3301e04c3fSmrg#ifdef __cplusplus
3401e04c3fSmrgextern "C" {
3501e04c3fSmrg#endif
3601e04c3fSmrg
3701e04c3fSmrg/**
3801e04c3fSmrg * Sometimes there are empty slots left over in UniformRemapTable after we
3901e04c3fSmrg * allocate slots to explicit locations. This struct represents a single
4001e04c3fSmrg * continouous block of empty slots in UniformRemapTable.
4101e04c3fSmrg */
4201e04c3fSmrgstruct empty_uniform_block {
4301e04c3fSmrg   struct exec_node link;
4401e04c3fSmrg   /* The start location of the block */
4501e04c3fSmrg   unsigned start;
4601e04c3fSmrg   /* The number of slots in the block */
4701e04c3fSmrg   unsigned slots;
4801e04c3fSmrg};
4901e04c3fSmrg
507ec681f3Smrg/**
517ec681f3Smrg * Describes an access of an array element or an access of the whole array
527ec681f3Smrg */
537ec681f3Smrgstruct array_deref_range {
547ec681f3Smrg   /**
557ec681f3Smrg    * Index that was accessed.
567ec681f3Smrg    *
577ec681f3Smrg    * All valid array indices are less than the size of the array.  If index
587ec681f3Smrg    * is equal to the size of the array, this means the entire array has been
597ec681f3Smrg    * accessed (e.g., due to use of a non-constant index).
607ec681f3Smrg    */
617ec681f3Smrg   unsigned index;
627ec681f3Smrg
637ec681f3Smrg   /** Size of the array.  Used for offset calculations. */
647ec681f3Smrg   unsigned size;
657ec681f3Smrg};
667ec681f3Smrg
6701e04c3fSmrgvoid
6801e04c3fSmrglinker_error(struct gl_shader_program *prog, const char *fmt, ...);
6901e04c3fSmrg
7001e04c3fSmrgvoid
7101e04c3fSmrglinker_warning(struct gl_shader_program *prog, const char *fmt, ...);
7201e04c3fSmrg
737ec681f3Smrgbool
747ec681f3Smrglink_util_should_add_buffer_variable(struct gl_shader_program *prog,
757ec681f3Smrg                                     struct gl_uniform_storage *uniform,
767ec681f3Smrg                                     int top_level_array_base_offset,
777ec681f3Smrg                                     int top_level_array_size_in_bytes,
787ec681f3Smrg                                     int second_element_offset,
797ec681f3Smrg                                     int block_index);
807ec681f3Smrg
8101e04c3fSmrgbool
8201e04c3fSmrglink_util_add_program_resource(struct gl_shader_program *prog,
8301e04c3fSmrg                               struct set *resource_set,
8401e04c3fSmrg                               GLenum type, const void *data, uint8_t stages);
8501e04c3fSmrg
8601e04c3fSmrgint
8701e04c3fSmrglink_util_find_empty_block(struct gl_shader_program *prog,
8801e04c3fSmrg                           struct gl_uniform_storage *uniform);
8901e04c3fSmrg
9001e04c3fSmrgvoid
9101e04c3fSmrglink_util_update_empty_uniform_locations(struct gl_shader_program *prog);
9201e04c3fSmrg
937ec681f3Smrgvoid
947ec681f3Smrglink_util_check_subroutine_resources(struct gl_shader_program *prog);
957ec681f3Smrg
967ec681f3Smrgvoid
977ec681f3Smrglink_util_check_uniform_resources(struct gl_context *ctx,
987ec681f3Smrg                                  struct gl_shader_program *prog);
997ec681f3Smrg
1007ec681f3Smrgvoid
1017ec681f3Smrglink_util_calculate_subroutine_compat(struct gl_shader_program *prog);
1027ec681f3Smrg
1037ec681f3Smrgvoid
1047ec681f3Smrglink_util_mark_array_elements_referenced(const struct array_deref_range *dr,
1057ec681f3Smrg                                         unsigned count, unsigned array_depth,
1067ec681f3Smrg                                         BITSET_WORD *bits);
1077ec681f3Smrg
10801e04c3fSmrg#ifdef __cplusplus
10901e04c3fSmrg}
11001e04c3fSmrg#endif
11101e04c3fSmrg
11201e04c3fSmrg#endif /* GLSL_LINKER_UTIL_H */
113