Files
third_party_mesa3d/src/compiler/glsl/builtin_functions.h
Lionel Landwerlin f81ede4699 glsl: builtin: always return clones of the builtins
Builtins are created once and allocated using their own private ralloc
context. When reparenting IR that includes builtins, we might be steal
bits of builtins. This is problematic because these builtins might now
be freed when the shader that includes then last is disposed. This
might also lead to inconsistent ralloc trees/lists if shaders are
created on multiple threads.

Rather than including builtins directly into a shader's IR, we should
include clones of them in the ralloc context of the shader that
requires them. This fixes double free issues we've been seeing when
running shader-db on a big multicore (72 threads) server.

v2: Also rename _mesa_glsl_find_builtin_function_by_name() to better
    reflect how this function is used. (Ken)

v3: Rename ctx to mem_ctx (Ken)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-09 08:30:36 +00:00

69 lines
2.2 KiB
C++

/*
* Copyright © 2016 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef BULITIN_FUNCTIONS_H
#define BULITIN_FUNCTIONS_H
extern void
_mesa_glsl_initialize_builtin_functions();
extern ir_function_signature *
_mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
const char *name, exec_list *actual_parameters);
extern bool
_mesa_glsl_has_builtin_function(const char *name);
extern gl_shader *
_mesa_glsl_get_builtin_function_shader(void);
extern ir_function_signature *
_mesa_get_main_function_signature(glsl_symbol_table *symbols);
extern void
_mesa_glsl_release_builtin_functions(void);
namespace generate_ir {
ir_function_signature *
udiv64(void *mem_ctx, builtin_available_predicate avail);
ir_function_signature *
idiv64(void *mem_ctx, builtin_available_predicate avail);
ir_function_signature *
umod64(void *mem_ctx, builtin_available_predicate avail);
ir_function_signature *
imod64(void *mem_ctx, builtin_available_predicate avail);
ir_function_signature *
umul64(void *mem_ctx, builtin_available_predicate avail);
ir_function_signature *
sign64(void *mem_ctx, builtin_available_predicate avail);
}
#endif /* BULITIN_FUNCTIONS_H */