compiler: Import Mesa compiler components
Merciliess removal of gl_context state
compiler: Bring glslang and LunarGLASS into CMake process
compiler: Progress (?) towards standalone xglCompiler
diff --git a/icd/intel/compiler/shader/ast_function.cpp b/icd/intel/compiler/shader/ast_function.cpp
index 0cfaf4c..80c8032 100644
--- a/icd/intel/compiler/shader/ast_function.cpp
+++ b/icd/intel/compiler/shader/ast_function.cpp
@@ -25,7 +25,7 @@
#include "ast.h"
#include "glsl_types.h"
#include "ir.h"
-#include "main/core.h" /* for MIN2 */
+#include "libfns.h" // LunarG ADD:
static ir_rvalue *
convert_component(ir_rvalue *src, const glsl_type *desired_type);
diff --git a/icd/intel/compiler/shader/ast_to_hir.cpp b/icd/intel/compiler/shader/ast_to_hir.cpp
index 332f934..009c823 100644
--- a/icd/intel/compiler/shader/ast_to_hir.cpp
+++ b/icd/intel/compiler/shader/ast_to_hir.cpp
@@ -49,7 +49,7 @@
* parser (and lexer) sources.
*/
-#include "main/core.h" /* for struct gl_extensions */
+#include "libfns.h" // LunarG ADD:
#include "glsl_symbol_table.h"
#include "glsl_parser_extras.h"
#include "ast.h"
diff --git a/icd/intel/compiler/shader/builtin_functions.cpp b/icd/intel/compiler/shader/builtin_functions.cpp
index f9f0686..28b241e 100644
--- a/icd/intel/compiler/shader/builtin_functions.cpp
+++ b/icd/intel/compiler/shader/builtin_functions.cpp
@@ -55,7 +55,7 @@
#include <stdarg.h>
#include <stdio.h>
-#include "main/core.h" /* for struct gl_shader */
+#include "libfns.h" /* for struct gl_shader */
#include "main/shaderobj.h"
#include "ir_builder.h"
#include "glsl_parser_extras.h"
diff --git a/icd/intel/compiler/shader/builtin_variables.cpp b/icd/intel/compiler/shader/builtin_variables.cpp
index 60b0e38..1b4a39e 100644
--- a/icd/intel/compiler/shader/builtin_variables.cpp
+++ b/icd/intel/compiler/shader/builtin_variables.cpp
@@ -24,7 +24,7 @@
#include "ir.h"
#include "glsl_parser_extras.h"
#include "glsl_symbol_table.h"
-#include "main/core.h"
+#include "libfns.h"
#include "main/uniforms.h"
#include "program/prog_parameter.h"
#include "program/prog_statevars.h"
diff --git a/icd/intel/compiler/shader/glsl_parser_extras.cpp b/icd/intel/compiler/shader/glsl_parser_extras.cpp
index 2dbec8b..6cdbd25 100644
--- a/icd/intel/compiler/shader/glsl_parser_extras.cpp
+++ b/icd/intel/compiler/shader/glsl_parser_extras.cpp
@@ -35,7 +35,7 @@
#endif // USE_LUNARGLASS
extern "C" {
-#include "main/core.h" /* for struct gl_context */
+#include "libfns.h" // LunarG ADD:
#include "main/context.h"
#include "main/shaderobj.h"
#include "program/prog_diskcache.h"
@@ -44,7 +44,7 @@
#include "ralloc.h"
#include "ast.h"
#include "glsl_parser_extras.h"
-#include "glsl_parser.h"
+//#include "glsl_parser.h"
#include "ir_optimization.h"
#include "loop_analysis.h"
#include "threadpool.h"
@@ -1738,8 +1738,8 @@
bool dump_ast, bool dump_hir)
{
/* Search program disk cache if active. */
- if (ctx->BinaryShaderCacheActive && mesa_shader_diskcache_find(ctx, shader) == 0)
- return;
+// if (ctx->BinaryShaderCacheActive && mesa_shader_diskcache_find(ctx, shader) == 0)
+// return;
struct _mesa_glsl_parse_state *state =
new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
@@ -1807,8 +1807,8 @@
/* Retain any live IR, but trash the rest. */
reparent_ir(shader->ir, shader->ir);
- if (ctx->BinaryShaderCacheActive && shader->CompileStatus)
- mesa_shader_diskcache_cache(ctx, shader);
+// if (ctx->BinaryShaderCacheActive && shader->CompileStatus)
+// mesa_shader_diskcache_cache(ctx, shader);
ralloc_free(state);
}
@@ -1818,8 +1818,8 @@
bool dump_ast, bool dump_hir)
{
/* Search program disk cache if active. */
- if (ctx->BinaryShaderCacheActive && mesa_shader_diskcache_find(ctx, shader) == 0)
- return;
+// if (ctx->BinaryShaderCacheActive && mesa_shader_diskcache_find(ctx, shader) == 0)
+// return;
#ifdef USE_LUNARGLASS
// Temporary shader source blacklist, until a source of falling back into SIMD8 can be fixed.
@@ -1837,8 +1837,8 @@
}
#endif // USE_LUNARGLASS
- if (ctx->BinaryShaderCacheActive && shader->CompileStatus)
- mesa_shader_diskcache_cache(ctx, shader);
+// if (ctx->BinaryShaderCacheActive && shader->CompileStatus)
+// mesa_shader_diskcache_cache(ctx, shader);
}
} /* extern "C" */
diff --git a/icd/intel/compiler/shader/glsl_types.cpp b/icd/intel/compiler/shader/glsl_types.cpp
index cc14177..ca96940 100644
--- a/icd/intel/compiler/shader/glsl_types.cpp
+++ b/icd/intel/compiler/shader/glsl_types.cpp
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "main/core.h" /* for Elements */
+#include "libfns.h" // LunarG ADD:
#include "glsl_symbol_table.h"
#include "glsl_parser_extras.h"
#include "glsl_types.h"
diff --git a/icd/intel/compiler/shader/glsl_types.h b/icd/intel/compiler/shader/glsl_types.h
deleted file mode 100644
index 57ace59..0000000
--- a/icd/intel/compiler/shader/glsl_types.h
+++ /dev/null
@@ -1,711 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright © 2009 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.
- */
-
-#pragma once
-#ifndef GLSL_TYPES_H
-#define GLSL_TYPES_H
-
-#include <string.h>
-#include <assert.h>
-#include "main/mtypes.h" /* for gl_texture_index, C++'s enum rules are broken */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct _mesa_glsl_parse_state;
-struct glsl_symbol_table;
-
-extern void
-_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
-
-extern void
-_mesa_glsl_release_types(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-enum glsl_base_type {
- GLSL_TYPE_UINT = 0,
- GLSL_TYPE_INT,
- GLSL_TYPE_FLOAT,
- GLSL_TYPE_BOOL,
- GLSL_TYPE_SAMPLER,
- GLSL_TYPE_IMAGE,
- GLSL_TYPE_ATOMIC_UINT,
- GLSL_TYPE_STRUCT,
- GLSL_TYPE_INTERFACE,
- GLSL_TYPE_ARRAY,
- GLSL_TYPE_VOID,
- GLSL_TYPE_ERROR
-};
-
-enum glsl_sampler_dim {
- GLSL_SAMPLER_DIM_1D = 0,
- GLSL_SAMPLER_DIM_2D,
- GLSL_SAMPLER_DIM_3D,
- GLSL_SAMPLER_DIM_CUBE,
- GLSL_SAMPLER_DIM_RECT,
- GLSL_SAMPLER_DIM_BUF,
- GLSL_SAMPLER_DIM_EXTERNAL,
- GLSL_SAMPLER_DIM_MS
-};
-
-enum glsl_interface_packing {
- GLSL_INTERFACE_PACKING_STD140,
- GLSL_INTERFACE_PACKING_SHARED,
- GLSL_INTERFACE_PACKING_PACKED
-};
-
-#ifdef __cplusplus
-#include "GL/gl.h"
-#include "ralloc.h"
-#include "memory_writer.h"
-#include "memory_map.h"
-
-struct glsl_type {
- GLenum gl_type;
- glsl_base_type base_type;
-
- unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */
- unsigned sampler_shadow:1;
- unsigned sampler_array:1;
- unsigned sampler_type:2; /**< Type of data returned using this
- * sampler or image. Only \c
- * GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
- * and \c GLSL_TYPE_UINT are valid.
- */
- unsigned interface_packing:2;
-
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
- static void* operator new(size_t size)
- {
- mtx_lock(&glsl_type::mutex);
-
- /* mem_ctx should have been created by the static members */
- assert(glsl_type::mem_ctx != NULL);
-
- void *type;
-
- type = ralloc_size(glsl_type::mem_ctx, size);
- assert(type != NULL);
-
- mtx_unlock(&glsl_type::mutex);
-
- return type;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. */
- static void operator delete(void *type)
- {
- mtx_lock(&glsl_type::mutex);
- ralloc_free(type);
- mtx_unlock(&glsl_type::mutex);
- }
-
- /**
- * Serialization functionality used by binary shaders.
- */
- void serialize(memory_writer &mem) const;
-
- /**
- * Deserialization functionality used by binary shaders,
- * state and type_hash are helper structures managed by the
- * ir_deserializer class.
- */
- const glsl_type *deserialize(memory_map *map,
- struct _mesa_glsl_parse_state *state,
- struct hash_table *type_hash,
- uint32_t hash_value);
-
- /**
- * \name Vector and matrix element counts
- *
- * For scalars, each of these values will be 1. For non-numeric types
- * these will be 0.
- */
- /*@{*/
- unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */
- unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */
- /*@}*/
-
- /**
- * Name of the data type
- *
- * Will never be \c NULL.
- */
- const char *name;
-
- /**
- * For \c GLSL_TYPE_ARRAY, this is the length of the array. For
- * \c GLSL_TYPE_STRUCT or \c GLSL_TYPE_INTERFACE, it is the number of
- * elements in the structure and the number of values pointed to by
- * \c fields.structure (below).
- */
- unsigned length;
-
- /**
- * Subtype of composite data types.
- */
- union {
- const struct glsl_type *array; /**< Type of array elements. */
- const struct glsl_type *parameters; /**< Parameters to function. */
- struct glsl_struct_field *structure; /**< List of struct fields. */
- } fields;
-
- /**
- * \name Pointers to various public type singletons
- */
- /*@{*/
-#undef DECL_TYPE
-#define DECL_TYPE(NAME, ...) \
- static const glsl_type *const NAME##_type;
-#undef STRUCT_TYPE
-#define STRUCT_TYPE(NAME) \
- static const glsl_type *const struct_##NAME##_type;
-#include "builtin_type_macros.h"
- /*@}*/
-
- /**
- * Convenience accessors for vector types (shorter than get_instance()).
- * @{
- */
- static const glsl_type *vec(unsigned components);
- static const glsl_type *ivec(unsigned components);
- static const glsl_type *uvec(unsigned components);
- static const glsl_type *bvec(unsigned components);
- /**@}*/
-
- /**
- * For numeric and boolean derived types returns the basic scalar type
- *
- * If the type is a numeric or boolean scalar, vector, or matrix type,
- * this function gets the scalar type of the individual components. For
- * all other types, including arrays of numeric or boolean types, the
- * error type is returned.
- */
- const glsl_type *get_base_type() const;
-
- /**
- * Get the basic scalar type which this type aggregates.
- *
- * If the type is a numeric or boolean scalar, vector, or matrix, or an
- * array of any of those, this function gets the scalar type of the
- * individual components. For structs and arrays of structs, this function
- * returns the struct type. For samplers and arrays of samplers, this
- * function returns the sampler type.
- */
- const glsl_type *get_scalar_type() const;
-
- /**
- * Query the type of elements in an array
- *
- * \return
- * Pointer to the type of elements in the array for array types, or \c NULL
- * for non-array types.
- */
- const glsl_type *element_type() const
- {
- return is_array() ? fields.array : NULL;
- }
-
- /**
- * Get the instance of a built-in scalar, vector, or matrix type
- */
- static const glsl_type *get_instance(unsigned base_type, unsigned rows,
- unsigned columns);
-
- /**
- * Get the instance of an array type
- */
- static const glsl_type *get_array_instance(const glsl_type *base,
- unsigned elements);
-
- /**
- * Get the instance of a record type
- */
- static const glsl_type *get_record_instance(const glsl_struct_field *fields,
- unsigned num_fields,
- const char *name);
-
- /**
- * Get the instance of an interface block type
- */
- static const glsl_type *get_interface_instance(const glsl_struct_field *fields,
- unsigned num_fields,
- enum glsl_interface_packing packing,
- const char *block_name);
-
- /**
- * Query the total number of scalars that make up a scalar, vector or matrix
- */
- unsigned components() const
- {
- return vector_elements * matrix_columns;
- }
-
- /**
- * Calculate the number of components slots required to hold this type
- *
- * This is used to determine how many uniform or varying locations a type
- * might occupy.
- */
- unsigned component_slots() const;
-
- /**
- * Calculate the number of attribute slots required to hold this type
- *
- * This implements the language rules of GLSL 1.50 for counting the number
- * of slots used by a vertex attribute. It also determines the number of
- * varying slots the type will use up in the absence of varying packing
- * (and thus, it can be used to measure the number of varying slots used by
- * the varyings that are generated by lower_packed_varyings).
- */
- unsigned count_attribute_slots() const;
-
-
- /**
- * Alignment in bytes of the start of this type in a std140 uniform
- * block.
- */
- unsigned std140_base_alignment(bool row_major) const;
-
- /** Size in bytes of this type in a std140 uniform block.
- *
- * Note that this is not GL_UNIFORM_SIZE (which is the number of
- * elements in the array)
- */
- unsigned std140_size(bool row_major) const;
-
- /**
- * \brief Can this type be implicitly converted to another?
- *
- * \return True if the types are identical or if this type can be converted
- * to \c desired according to Section 4.1.10 of the GLSL spec.
- *
- * \verbatim
- * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10
- * Implicit Conversions:
- *
- * In some situations, an expression and its type will be implicitly
- * converted to a different type. The following table shows all allowed
- * implicit conversions:
- *
- * Type of expression | Can be implicitly converted to
- * --------------------------------------------------
- * int float
- * uint
- *
- * ivec2 vec2
- * uvec2
- *
- * ivec3 vec3
- * uvec3
- *
- * ivec4 vec4
- * uvec4
- *
- * There are no implicit array or structure conversions. For example,
- * an array of int cannot be implicitly converted to an array of float.
- * There are no implicit conversions between signed and unsigned
- * integers.
- * \endverbatim
- */
- bool can_implicitly_convert_to(const glsl_type *desired) const;
-
- /**
- * Query whether or not a type is a scalar (non-vector and non-matrix).
- */
- bool is_scalar() const
- {
- return (vector_elements == 1)
- && (base_type >= GLSL_TYPE_UINT)
- && (base_type <= GLSL_TYPE_BOOL);
- }
-
- /**
- * Query whether or not a type is a vector
- */
- bool is_vector() const
- {
- return (vector_elements > 1)
- && (matrix_columns == 1)
- && (base_type >= GLSL_TYPE_UINT)
- && (base_type <= GLSL_TYPE_BOOL);
- }
-
- /**
- * Query whether or not a type is a matrix
- */
- bool is_matrix() const
- {
- /* GLSL only has float matrices. */
- return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT);
- }
-
- /**
- * Query whether or not a type is a non-array numeric type
- */
- bool is_numeric() const
- {
- return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT);
- }
-
- /**
- * Query whether or not a type is an integral type
- */
- bool is_integer() const
- {
- return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT);
- }
-
- /**
- * Query whether or not type is an integral type, or for struct and array
- * types, contains an integral type.
- */
- bool contains_integer() const;
-
- /**
- * Query whether or not a type is a float type
- */
- bool is_float() const
- {
- return base_type == GLSL_TYPE_FLOAT;
- }
-
- /**
- * Query whether or not a type is a non-array boolean type
- */
- bool is_boolean() const
- {
- return base_type == GLSL_TYPE_BOOL;
- }
-
- /**
- * Query whether or not a type is a sampler
- */
- bool is_sampler() const
- {
- return base_type == GLSL_TYPE_SAMPLER;
- }
-
- /**
- * Query whether or not type is a sampler, or for struct and array
- * types, contains a sampler.
- */
- bool contains_sampler() 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 and array
- * types, contains an image.
- */
- bool contains_image() const;
-
- /**
- * Query whether or not a type is an image
- */
- bool is_image() const
- {
- return base_type == GLSL_TYPE_IMAGE;
- }
-
- /**
- * Query whether or not a type is an array
- */
- bool is_array() const
- {
- return base_type == GLSL_TYPE_ARRAY;
- }
-
- /**
- * Query whether or not a type is a record
- */
- bool is_record() const
- {
- return base_type == GLSL_TYPE_STRUCT;
- }
-
- /**
- * Query whether or not a type is an interface
- */
- bool is_interface() const
- {
- return base_type == GLSL_TYPE_INTERFACE;
- }
-
- /**
- * Query whether or not a type is the void type singleton.
- */
- bool is_void() const
- {
- return base_type == GLSL_TYPE_VOID;
- }
-
- /**
- * Query whether or not a type is the error type singleton.
- */
- bool is_error() const
- {
- return base_type == GLSL_TYPE_ERROR;
- }
-
- /**
- * Return the amount of atomic counter storage required for a type.
- */
- unsigned atomic_size() const
- {
- if (base_type == GLSL_TYPE_ATOMIC_UINT)
- return ATOMIC_COUNTER_SIZE;
- else if (is_array())
- return length * element_type()->atomic_size();
- else
- return 0;
- }
-
- /**
- * Return whether a type contains any atomic counters.
- */
- bool contains_atomic() const
- {
- return atomic_size() > 0;
- }
-
- /**
- * Return whether a type contains any opaque types.
- */
- bool contains_opaque() const;
-
- /**
- * Query the full type of a matrix row
- *
- * \return
- * If the type is not a matrix, \c glsl_type::error_type is returned.
- * Otherwise a type matching the rows of the matrix is returned.
- */
- const glsl_type *row_type() const
- {
- return is_matrix()
- ? get_instance(base_type, matrix_columns, 1)
- : error_type;
- }
-
- /**
- * Query the full type of a matrix column
- *
- * \return
- * If the type is not a matrix, \c glsl_type::error_type is returned.
- * Otherwise a type matching the columns of the matrix is returned.
- */
- const glsl_type *column_type() const
- {
- return is_matrix()
- ? get_instance(base_type, vector_elements, 1)
- : error_type;
- }
-
- /**
- * Get the type of a structure field
- *
- * \return
- * Pointer to the type of the named field. If the type is not a structure
- * or the named field does not exist, \c glsl_type::error_type is returned.
- */
- const glsl_type *field_type(const char *name) const;
-
- /**
- * Get the location of a filed within a record type
- */
- int field_index(const char *name) const;
-
- /**
- * Query the number of elements in an array type
- *
- * \return
- * The number of elements in the array for array types or -1 for non-array
- * types. If the number of elements in the array has not yet been declared,
- * zero is returned.
- */
- int array_size() const
- {
- return is_array() ? length : -1;
- }
-
- /**
- * Query whether the array size for all dimensions has been declared.
- */
- bool is_unsized_array() const
- {
- return is_array() && length == 0;
- }
-
- /**
- * Return the number of coordinate components needed for this
- * sampler or image type.
- *
- * This is based purely on the sampler's dimensionality. For example, this
- * returns 1 for sampler1D, and 3 for sampler2DArray.
- *
- * Note that this is often different than actual coordinate type used in
- * a texturing built-in function, since those pack additional values (such
- * as the shadow comparitor or projector) into the coordinate type.
- */
- int coordinate_components() const;
-
- /**
- * Compare a record type against another record type.
- *
- * This is useful for matching record types declared across shader stages.
- */
- bool record_compare(const glsl_type *b) const;
-
-private:
-
- static mtx_t mutex;
-
- /**
- * ralloc context for all glsl_type allocations
- *
- * Set on the first call to \c glsl_type::new.
- */
- static void *mem_ctx;
-
- void init_ralloc_type_ctx(void);
-
- /** Constructor for vector and matrix types */
- glsl_type(GLenum gl_type,
- glsl_base_type base_type, unsigned vector_elements,
- unsigned matrix_columns, const char *name);
-
- /** Constructor for sampler or image types */
- glsl_type(GLenum gl_type, glsl_base_type base_type,
- enum glsl_sampler_dim dim, bool shadow, bool array,
- unsigned type, const char *name);
-
- /** Constructor for record types */
- glsl_type(const glsl_struct_field *fields, unsigned num_fields,
- const char *name);
-
- /** Constructor for interface types */
- glsl_type(const glsl_struct_field *fields, unsigned num_fields,
- enum glsl_interface_packing packing, const char *name);
-
- /** Constructor for array types */
- glsl_type(const glsl_type *array, unsigned length);
-
- /** Hash table containing the known array types. */
- static struct hash_table *array_types;
-
- /** Hash table containing the known record types. */
- static struct hash_table *record_types;
-
- /** Hash table containing the known interface types. */
- static struct hash_table *interface_types;
-
- static int record_key_compare(const void *a, const void *b);
- static unsigned record_key_hash(const void *key);
-
- /**
- * \name Built-in type flyweights
- */
- /*@{*/
-#undef DECL_TYPE
-#define DECL_TYPE(NAME, ...) static const glsl_type _##NAME##_type;
-#undef STRUCT_TYPE
-#define STRUCT_TYPE(NAME) static const glsl_type _struct_##NAME##_type;
-#include "builtin_type_macros.h"
- /*@}*/
-
- /**
- * \name Friend functions.
- *
- * These functions are friends because they must have C linkage and the
- * need to call various private methods or access various private static
- * data.
- */
- /*@{*/
- friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *);
- friend void _mesa_glsl_release_types(void);
- /*@}*/
-};
-
-struct glsl_struct_field {
- const struct glsl_type *type;
- const char *name;
- bool row_major;
-
- /**
- * For interface blocks, gl_varying_slot corresponding to the input/output
- * if this is a built-in input/output (i.e. a member of the built-in
- * gl_PerVertex interface block); -1 otherwise.
- *
- * Ignored for structs.
- */
- int location;
-
- /**
- * For interface blocks, the interpolation mode (as in
- * ir_variable::interpolation). 0 otherwise.
- */
- unsigned interpolation:2;
-
- /**
- * For interface blocks, 1 if this variable uses centroid interpolation (as
- * in ir_variable::centroid). 0 otherwise.
- */
- unsigned centroid:1;
-
- /**
- * For interface blocks, 1 if this variable uses sample interpolation (as
- * in ir_variable::sample). 0 otherwise.
- */
- unsigned sample:1;
-};
-
-/**
- * Deserialization utility function used by the binary shaders, state and
- * type_hash are mandatory helper structures managed by the caller.
- */
-const glsl_type *
-deserialize_glsl_type(memory_map *map, struct _mesa_glsl_parse_state *state,
- struct hash_table *type_hash);
-
-static inline unsigned int
-glsl_align(unsigned int a, unsigned int align)
-{
- return (a + align - 1) / align * align;
-}
-
-#undef DECL_TYPE
-#undef STRUCT_TYPE
-#endif /* __cplusplus */
-
-#endif /* GLSL_TYPES_H */
diff --git a/icd/intel/compiler/shader/ir.cpp b/icd/intel/compiler/shader/ir.cpp
index ba8a839..2a3a5c6 100644
--- a/icd/intel/compiler/shader/ir.cpp
+++ b/icd/intel/compiler/shader/ir.cpp
@@ -21,10 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
-#include "main/core.h" /* for MAX2 */
#include "ir.h"
#include "ir_visitor.h"
#include "glsl_types.h"
+#include "libfns.h"
ir_rvalue::ir_rvalue()
{
diff --git a/icd/intel/compiler/shader/ir_constant_expression.cpp b/icd/intel/compiler/shader/ir_constant_expression.cpp
index 8afe8f7..4df343f 100644
--- a/icd/intel/compiler/shader/ir_constant_expression.cpp
+++ b/icd/intel/compiler/shader/ir_constant_expression.cpp
@@ -34,7 +34,7 @@
*/
#include <math.h>
-#include "main/core.h" /* for MAX2, MIN2, CLAMP */
+#include "libfns.h"
#include "ir.h"
#include "ir_visitor.h"
#include "glsl_types.h"
diff --git a/icd/intel/compiler/shader/ir_function_detect_recursion.cpp b/icd/intel/compiler/shader/ir_function_detect_recursion.cpp
index 5813315..af985cd 100644
--- a/icd/intel/compiler/shader/ir_function_detect_recursion.cpp
+++ b/icd/intel/compiler/shader/ir_function_detect_recursion.cpp
@@ -120,7 +120,7 @@
*
* \author Ian Romanick <ian.d.romanick@intel.com>
*/
-#include "main/core.h"
+#include "libfns.h" // LunarG ADD:
#include "ir.h"
#include "glsl_parser_extras.h"
#include "linker.h"
diff --git a/icd/intel/compiler/shader/ir_set_program_inouts.cpp b/icd/intel/compiler/shader/ir_set_program_inouts.cpp
index 5163eb2..e2ec9b6 100644
--- a/icd/intel/compiler/shader/ir_set_program_inouts.cpp
+++ b/icd/intel/compiler/shader/ir_set_program_inouts.cpp
@@ -37,7 +37,7 @@
* from the GLSL IR.
*/
-#include "main/core.h" /* for struct gl_program */
+#include "libfns.h" // LunarG ADD:
#include "ir.h"
#include "ir_visitor.h"
#include "glsl_types.h"
diff --git a/icd/intel/compiler/shader/libfns.h b/icd/intel/compiler/shader/libfns.h
new file mode 100644
index 0000000..d2760db
--- /dev/null
+++ b/icd/intel/compiler/shader/libfns.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2010 LunarG 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.
+ */
+
+// LunarG ADD:
+
+#ifndef LIBFNS_H
+#define LIBFNS_H
+
+#include "main/macros.h"
+
+#endif // LIBFNS_H
diff --git a/icd/intel/compiler/shader/libfns.h~ b/icd/intel/compiler/shader/libfns.h~
new file mode 100644
index 0000000..f42c3cb
--- /dev/null
+++ b/icd/intel/compiler/shader/libfns.h~
@@ -0,0 +1,6 @@
+// LunarG ADD:
+template<typename T>
+T MAX2(const T& a, const T& b) { return a > b ? a : b; }
+template<typename T>
+T MIN2(const T& a, const T& b) { return a < b ? a : b; }
+
diff --git a/icd/intel/compiler/shader/link_functions.cpp b/icd/intel/compiler/shader/link_functions.cpp
index 56f3f20..e16567e 100644
--- a/icd/intel/compiler/shader/link_functions.cpp
+++ b/icd/intel/compiler/shader/link_functions.cpp
@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include "main/core.h"
+#include "libfns.h" // LunarG ADD:
#include "glsl_symbol_table.h"
#include "glsl_parser_extras.h"
#include "ir.h"
diff --git a/icd/intel/compiler/shader/link_uniform_blocks.cpp b/icd/intel/compiler/shader/link_uniform_blocks.cpp
index 1a0e643..6430c34 100644
--- a/icd/intel/compiler/shader/link_uniform_blocks.cpp
+++ b/icd/intel/compiler/shader/link_uniform_blocks.cpp
@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include "main/core.h"
+#include "libfns.h" // LunarG ADD:
#include "ir.h"
#include "linker.h"
#include "ir_uniform.h"
diff --git a/icd/intel/compiler/shader/link_uniform_initializers.cpp b/icd/intel/compiler/shader/link_uniform_initializers.cpp
index 2100e05..ae4cd71 100644
--- a/icd/intel/compiler/shader/link_uniform_initializers.cpp
+++ b/icd/intel/compiler/shader/link_uniform_initializers.cpp
@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include "main/core.h"
+#include "libfns.h" // LunarG ADD:
#include "ir.h"
#include "linker.h"
#include "ir_uniform.h"
diff --git a/icd/intel/compiler/shader/link_uniforms.cpp b/icd/intel/compiler/shader/link_uniforms.cpp
index 29dc0b1..3d98f75 100644
--- a/icd/intel/compiler/shader/link_uniforms.cpp
+++ b/icd/intel/compiler/shader/link_uniforms.cpp
@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include "main/core.h"
+#include "libfns.h" // LunarG ADD:
#include "ir.h"
#include "linker.h"
#include "ir_uniform.h"
diff --git a/icd/intel/compiler/shader/linker.cpp b/icd/intel/compiler/shader/linker.cpp
index c448847..6f3b876 100644
--- a/icd/intel/compiler/shader/linker.cpp
+++ b/icd/intel/compiler/shader/linker.cpp
@@ -64,7 +64,7 @@
* \author Ian Romanick <ian.d.romanick@intel.com>
*/
-#include "main/core.h"
+#include "libfns.h" // LunarG ADD:
#include "glsl_symbol_table.h"
#include "glsl_parser_extras.h"
#include "ir.h"
diff --git a/icd/intel/compiler/shader/lower_instructions.cpp b/icd/intel/compiler/shader/lower_instructions.cpp
index 176070c..8d6d630 100644
--- a/icd/intel/compiler/shader/lower_instructions.cpp
+++ b/icd/intel/compiler/shader/lower_instructions.cpp
@@ -106,7 +106,7 @@
*
*/
-#include "main/core.h" /* for M_LOG2E */
+#include "libfns.h" // LunarG ADD:
#include "glsl_types.h"
#include "ir.h"
#include "ir_builder.h"
diff --git a/icd/intel/compiler/shader/main.cpp b/icd/intel/compiler/shader/main.cpp
index a9faad6..58f1140 100644
--- a/icd/intel/compiler/shader/main.cpp
+++ b/icd/intel/compiler/shader/main.cpp
@@ -40,11 +40,11 @@
static int glsl_version = 330;
-extern "C" void
-_mesa_error_no_memory(const char *caller)
-{
- fprintf(stderr, "Mesa error: out of memory in %s", caller);
-}
+//extern "C" void
+//_mesa_error_no_memory(const char *caller)
+//{
+// fprintf(stderr, "Mesa error: out of memory in %s", caller);
+//}
static void
initialize_context(struct gl_context *ctx, gl_api api)
diff --git a/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp b/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp
index 6612592..7e29b9b 100644
--- a/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp
+++ b/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp
@@ -46,7 +46,7 @@
* The same is done for the gl_FragData fragment shader output.
*/
-#include "main/core.h" /* for snprintf and ARRAY_SIZE */
+#include "libfns.h" // LunarG ADD:
#include "ir.h"
#include "ir_rvalue_visitor.h"
#include "ir_optimization.h"
diff --git a/icd/intel/compiler/shader/program.h b/icd/intel/compiler/shader/program.h
index f15113a..d44294d 100644
--- a/icd/intel/compiler/shader/program.h
+++ b/icd/intel/compiler/shader/program.h
@@ -22,7 +22,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "main/core.h"
+#include "libfns.h" // LunarG ADD:
#ifdef __cplusplus
extern "C" {
diff --git a/icd/intel/compiler/shader/ralloc.c b/icd/intel/compiler/shader/ralloc.c
deleted file mode 100644
index 36bc61f..0000000
--- a/icd/intel/compiler/shader/ralloc.c
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright © 2010 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.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-
-/* Android defines SIZE_MAX in limits.h, instead of the standard stdint.h */
-#ifdef ANDROID
-#include <limits.h>
-#endif
-
-/* Some versions of MinGW are missing _vscprintf's declaration, although they
- * still provide the symbol in the import library. */
-#ifdef __MINGW32__
-_CRTIMP int _vscprintf(const char *format, va_list argptr);
-#endif
-
-#include "ralloc.h"
-
-#ifndef va_copy
-#ifdef __va_copy
-#define va_copy(dest, src) __va_copy((dest), (src))
-#else
-#define va_copy(dest, src) (dest) = (src)
-#endif
-#endif
-
-#define CANARY 0x5A1106
-
-struct ralloc_header
-{
-#ifdef DEBUG
- /* A canary value used to determine whether a pointer is ralloc'd. */
- unsigned canary;
-#endif
-
- struct ralloc_header *parent;
-
- /* The first child (head of a linked list) */
- struct ralloc_header *child;
-
- /* Linked list of siblings */
- struct ralloc_header *prev;
- struct ralloc_header *next;
-
- void (*destructor)(void *);
-};
-
-typedef struct ralloc_header ralloc_header;
-
-static void unlink_block(ralloc_header *info);
-static void unsafe_free(ralloc_header *info);
-
-static ralloc_header *
-get_header(const void *ptr)
-{
- ralloc_header *info = (ralloc_header *) (((char *) ptr) -
- sizeof(ralloc_header));
-#ifdef DEBUG
- assert(info->canary == CANARY);
-#endif
- return info;
-}
-
-#define PTR_FROM_HEADER(info) (((char *) info) + sizeof(ralloc_header))
-
-static void
-add_child(ralloc_header *parent, ralloc_header *info)
-{
- if (parent != NULL) {
- info->parent = parent;
- info->next = parent->child;
- parent->child = info;
-
- if (info->next != NULL)
- info->next->prev = info;
- }
-}
-
-void *
-ralloc_context(const void *ctx)
-{
- return ralloc_size(ctx, 0);
-}
-
-void *
-ralloc_size(const void *ctx, size_t size)
-{
- void *block = calloc(1, size + sizeof(ralloc_header));
- ralloc_header *info;
- ralloc_header *parent;
-
- if (unlikely(block == NULL))
- return NULL;
- info = (ralloc_header *) block;
- parent = ctx != NULL ? get_header(ctx) : NULL;
-
- add_child(parent, info);
-
-#ifdef DEBUG
- info->canary = CANARY;
-#endif
-
- return PTR_FROM_HEADER(info);
-}
-
-void *
-rzalloc_size(const void *ctx, size_t size)
-{
- void *ptr = ralloc_size(ctx, size);
- if (likely(ptr != NULL))
- memset(ptr, 0, size);
- return ptr;
-}
-
-/* helper function - assumes ptr != NULL */
-static void *
-resize(void *ptr, size_t size)
-{
- ralloc_header *child, *old, *info;
-
- old = get_header(ptr);
- info = realloc(old, size + sizeof(ralloc_header));
-
- if (info == NULL)
- return NULL;
-
- /* Update parent and sibling's links to the reallocated node. */
- if (info != old && info->parent != NULL) {
- if (info->parent->child == old)
- info->parent->child = info;
-
- if (info->prev != NULL)
- info->prev->next = info;
-
- if (info->next != NULL)
- info->next->prev = info;
- }
-
- /* Update child->parent links for all children */
- for (child = info->child; child != NULL; child = child->next)
- child->parent = info;
-
- return PTR_FROM_HEADER(info);
-}
-
-void *
-reralloc_size(const void *ctx, void *ptr, size_t size)
-{
- if (unlikely(ptr == NULL))
- return ralloc_size(ctx, size);
-
- assert(ralloc_parent(ptr) == ctx);
- return resize(ptr, size);
-}
-
-void *
-ralloc_array_size(const void *ctx, size_t size, unsigned count)
-{
- if (count > SIZE_MAX/size)
- return NULL;
-
- return ralloc_size(ctx, size * count);
-}
-
-void *
-rzalloc_array_size(const void *ctx, size_t size, unsigned count)
-{
- if (count > SIZE_MAX/size)
- return NULL;
-
- return rzalloc_size(ctx, size * count);
-}
-
-void *
-reralloc_array_size(const void *ctx, void *ptr, size_t size, unsigned count)
-{
- if (count > SIZE_MAX/size)
- return NULL;
-
- return reralloc_size(ctx, ptr, size * count);
-}
-
-void
-ralloc_free(void *ptr)
-{
- ralloc_header *info;
-
- if (ptr == NULL)
- return;
-
- info = get_header(ptr);
- unlink_block(info);
- unsafe_free(info);
-}
-
-static void
-unlink_block(ralloc_header *info)
-{
- /* Unlink from parent & siblings */
- if (info->parent != NULL) {
- if (info->parent->child == info)
- info->parent->child = info->next;
-
- if (info->prev != NULL)
- info->prev->next = info->next;
-
- if (info->next != NULL)
- info->next->prev = info->prev;
- }
- info->parent = NULL;
- info->prev = NULL;
- info->next = NULL;
-}
-
-static void
-unsafe_free(ralloc_header *info)
-{
- /* Recursively free any children...don't waste time unlinking them. */
- ralloc_header *temp;
- while (info->child != NULL) {
- temp = info->child;
- info->child = temp->next;
- unsafe_free(temp);
- }
-
- /* Free the block itself. Call the destructor first, if any. */
- if (info->destructor != NULL)
- info->destructor(PTR_FROM_HEADER(info));
-
- free(info);
-}
-
-void
-ralloc_steal(const void *new_ctx, void *ptr)
-{
- ralloc_header *info, *parent;
-
- if (unlikely(ptr == NULL))
- return;
-
- info = get_header(ptr);
- parent = get_header(new_ctx);
-
- unlink_block(info);
-
- add_child(parent, info);
-}
-
-void *
-ralloc_parent(const void *ptr)
-{
- ralloc_header *info;
-
- if (unlikely(ptr == NULL))
- return NULL;
-
- info = get_header(ptr);
- return info->parent ? PTR_FROM_HEADER(info->parent) : NULL;
-}
-
-static void *autofree_context = NULL;
-
-static void
-autofree(void)
-{
- ralloc_free(autofree_context);
-}
-
-void *
-ralloc_autofree_context(void)
-{
- if (unlikely(autofree_context == NULL)) {
- autofree_context = ralloc_context(NULL);
- atexit(autofree);
- }
- return autofree_context;
-}
-
-void
-ralloc_set_destructor(const void *ptr, void(*destructor)(void *))
-{
- ralloc_header *info = get_header(ptr);
- info->destructor = destructor;
-}
-
-char *
-ralloc_strdup(const void *ctx, const char *str)
-{
- size_t n;
- char *ptr;
-
- if (unlikely(str == NULL))
- return NULL;
-
- n = strlen(str);
- ptr = ralloc_array(ctx, char, n + 1);
- memcpy(ptr, str, n);
- ptr[n] = '\0';
- return ptr;
-}
-
-char *
-ralloc_strndup(const void *ctx, const char *str, size_t max)
-{
- size_t n;
- char *ptr;
-
- if (unlikely(str == NULL))
- return NULL;
-
- n = strlen(str);
- if (n > max)
- n = max;
-
- ptr = ralloc_array(ctx, char, n + 1);
- memcpy(ptr, str, n);
- ptr[n] = '\0';
- return ptr;
-}
-
-/* helper routine for strcat/strncat - n is the exact amount to copy */
-static bool
-cat(char **dest, const char *str, size_t n)
-{
- char *both;
- size_t existing_length;
- assert(dest != NULL && *dest != NULL);
-
- existing_length = strlen(*dest);
- both = resize(*dest, existing_length + n + 1);
- if (unlikely(both == NULL))
- return false;
-
- memcpy(both + existing_length, str, n);
- both[existing_length + n] = '\0';
-
- *dest = both;
- return true;
-}
-
-
-bool
-ralloc_strcat(char **dest, const char *str)
-{
- return cat(dest, str, strlen(str));
-}
-
-bool
-ralloc_strncat(char **dest, const char *str, size_t n)
-{
- /* Clamp n to the string length */
- size_t str_length = strlen(str);
- if (str_length < n)
- n = str_length;
-
- return cat(dest, str, n);
-}
-
-char *
-ralloc_asprintf(const void *ctx, const char *fmt, ...)
-{
- char *ptr;
- va_list args;
- va_start(args, fmt);
- ptr = ralloc_vasprintf(ctx, fmt, args);
- va_end(args);
- return ptr;
-}
-
-/* Return the length of the string that would be generated by a printf-style
- * format and argument list, not including the \0 byte.
- */
-static size_t
-printf_length(const char *fmt, va_list untouched_args)
-{
- int size;
- char junk;
-
- /* Make a copy of the va_list so the original caller can still use it */
- va_list args;
- va_copy(args, untouched_args);
-
-#ifdef _WIN32
- /* We need to use _vcsprintf to calculate the size as vsnprintf returns -1
- * if the number of characters to write is greater than count.
- */
- size = _vscprintf(fmt, args);
- (void)junk;
-#else
- size = vsnprintf(&junk, 1, fmt, args);
-#endif
- assert(size >= 0);
-
- va_end(args);
-
- return size;
-}
-
-char *
-ralloc_vasprintf(const void *ctx, const char *fmt, va_list args)
-{
- size_t size = printf_length(fmt, args) + 1;
-
- char *ptr = ralloc_size(ctx, size);
- if (ptr != NULL)
- vsnprintf(ptr, size, fmt, args);
-
- return ptr;
-}
-
-bool
-ralloc_asprintf_append(char **str, const char *fmt, ...)
-{
- bool success;
- va_list args;
- va_start(args, fmt);
- success = ralloc_vasprintf_append(str, fmt, args);
- va_end(args);
- return success;
-}
-
-bool
-ralloc_vasprintf_append(char **str, const char *fmt, va_list args)
-{
- size_t existing_length;
- assert(str != NULL);
- existing_length = *str ? strlen(*str) : 0;
- return ralloc_vasprintf_rewrite_tail(str, &existing_length, fmt, args);
-}
-
-bool
-ralloc_asprintf_rewrite_tail(char **str, size_t *start, const char *fmt, ...)
-{
- bool success;
- va_list args;
- va_start(args, fmt);
- success = ralloc_vasprintf_rewrite_tail(str, start, fmt, args);
- va_end(args);
- return success;
-}
-
-bool
-ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
- va_list args)
-{
- size_t new_length;
- char *ptr;
-
- assert(str != NULL);
-
- if (unlikely(*str == NULL)) {
- // Assuming a NULL context is probably bad, but it's expected behavior.
- *str = ralloc_vasprintf(NULL, fmt, args);
- return true;
- }
-
- new_length = printf_length(fmt, args);
-
- ptr = resize(*str, *start + new_length + 1);
- if (unlikely(ptr == NULL))
- return false;
-
- vsnprintf(ptr + *start, new_length + 1, fmt, args);
- *str = ptr;
- *start += new_length;
- return true;
-}
diff --git a/icd/intel/compiler/shader/ralloc.h b/icd/intel/compiler/shader/ralloc.h
deleted file mode 100644
index 4581a7a..0000000
--- a/icd/intel/compiler/shader/ralloc.h
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Copyright © 2010 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.
- */
-
-/**
- * \file ralloc.h
- *
- * ralloc: a recursive memory allocator
- *
- * The ralloc memory allocator creates a hierarchy of allocated
- * objects. Every allocation is in reference to some parent, and
- * every allocated object can in turn be used as the parent of a
- * subsequent allocation. This allows for extremely convenient
- * discarding of an entire tree/sub-tree of allocations by calling
- * ralloc_free on any particular object to free it and all of its
- * children.
- *
- * The conceptual working of ralloc was directly inspired by Andrew
- * Tridgell's talloc, but ralloc is an independent implementation
- * released under the MIT license and tuned for Mesa.
- *
- * The talloc implementation is available under the GNU Lesser
- * General Public License (GNU LGPL), version 3 or later. It is
- * more sophisticated than ralloc in that it includes reference
- * counting and debugging features. See: http://talloc.samba.org/
- */
-
-#ifndef RALLOC_H
-#define RALLOC_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include "main/compiler.h"
-
-/**
- * \def ralloc(ctx, type)
- * Allocate a new object chained off of the given context.
- *
- * This is equivalent to:
- * \code
- * ((type *) ralloc_size(ctx, sizeof(type))
- * \endcode
- */
-#define ralloc(ctx, type) ((type *) ralloc_size(ctx, sizeof(type)))
-
-/**
- * \def rzalloc(ctx, type)
- * Allocate a new object out of the given context and initialize it to zero.
- *
- * This is equivalent to:
- * \code
- * ((type *) rzalloc_size(ctx, sizeof(type))
- * \endcode
- */
-#define rzalloc(ctx, type) ((type *) rzalloc_size(ctx, sizeof(type)))
-
-/**
- * Allocate a new ralloc context.
- *
- * While any ralloc'd pointer can be used as a context, sometimes it is useful
- * to simply allocate a context with no associated memory.
- *
- * It is equivalent to:
- * \code
- * ((type *) ralloc_size(ctx, 0)
- * \endcode
- */
-void *ralloc_context(const void *ctx);
-
-/**
- * Allocate memory chained off of the given context.
- *
- * This is the core allocation routine which is used by all others. It
- * simply allocates storage for \p size bytes and returns the pointer,
- * similar to \c malloc.
- */
-void *ralloc_size(const void *ctx, size_t size);
-
-/**
- * Allocate zero-initialized memory chained off of the given context.
- *
- * This is similar to \c calloc with a size of 1.
- */
-void *rzalloc_size(const void *ctx, size_t size);
-
-/**
- * Resize a piece of ralloc-managed memory, preserving data.
- *
- * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the
- * memory. Instead, it resizes it to a 0-byte ralloc context, just like
- * calling ralloc_size(ctx, 0). This is different from talloc.
- *
- * \param ctx The context to use for new allocation. If \p ptr != NULL,
- * it must be the same as ralloc_parent(\p ptr).
- * \param ptr Pointer to the memory to be resized. May be NULL.
- * \param size The amount of memory to allocate, in bytes.
- */
-void *reralloc_size(const void *ctx, void *ptr, size_t size);
-
-/// \defgroup array Array Allocators @{
-
-/**
- * \def ralloc_array(ctx, type, count)
- * Allocate an array of objects chained off the given context.
- *
- * Similar to \c calloc, but does not initialize the memory to zero.
- *
- * More than a convenience function, this also checks for integer overflow when
- * multiplying \c sizeof(type) and \p count. This is necessary for security.
- *
- * This is equivalent to:
- * \code
- * ((type *) ralloc_array_size(ctx, sizeof(type), count)
- * \endcode
- */
-#define ralloc_array(ctx, type, count) \
- ((type *) ralloc_array_size(ctx, sizeof(type), count))
-
-/**
- * \def rzalloc_array(ctx, type, count)
- * Allocate a zero-initialized array chained off the given context.
- *
- * Similar to \c calloc.
- *
- * More than a convenience function, this also checks for integer overflow when
- * multiplying \c sizeof(type) and \p count. This is necessary for security.
- *
- * This is equivalent to:
- * \code
- * ((type *) rzalloc_array_size(ctx, sizeof(type), count)
- * \endcode
- */
-#define rzalloc_array(ctx, type, count) \
- ((type *) rzalloc_array_size(ctx, sizeof(type), count))
-
-/**
- * \def reralloc(ctx, ptr, type, count)
- * Resize a ralloc-managed array, preserving data.
- *
- * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the
- * memory. Instead, it resizes it to a 0-byte ralloc context, just like
- * calling ralloc_size(ctx, 0). This is different from talloc.
- *
- * More than a convenience function, this also checks for integer overflow when
- * multiplying \c sizeof(type) and \p count. This is necessary for security.
- *
- * \param ctx The context to use for new allocation. If \p ptr != NULL,
- * it must be the same as ralloc_parent(\p ptr).
- * \param ptr Pointer to the array to be resized. May be NULL.
- * \param type The element type.
- * \param count The number of elements to allocate.
- */
-#define reralloc(ctx, ptr, type, count) \
- ((type *) reralloc_array_size(ctx, ptr, sizeof(type), count))
-
-/**
- * Allocate memory for an array chained off the given context.
- *
- * Similar to \c calloc, but does not initialize the memory to zero.
- *
- * More than a convenience function, this also checks for integer overflow when
- * multiplying \p size and \p count. This is necessary for security.
- */
-void *ralloc_array_size(const void *ctx, size_t size, unsigned count);
-
-/**
- * Allocate a zero-initialized array chained off the given context.
- *
- * Similar to \c calloc.
- *
- * More than a convenience function, this also checks for integer overflow when
- * multiplying \p size and \p count. This is necessary for security.
- */
-void *rzalloc_array_size(const void *ctx, size_t size, unsigned count);
-
-/**
- * Resize a ralloc-managed array, preserving data.
- *
- * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the
- * memory. Instead, it resizes it to a 0-byte ralloc context, just like
- * calling ralloc_size(ctx, 0). This is different from talloc.
- *
- * More than a convenience function, this also checks for integer overflow when
- * multiplying \c sizeof(type) and \p count. This is necessary for security.
- *
- * \param ctx The context to use for new allocation. If \p ptr != NULL,
- * it must be the same as ralloc_parent(\p ptr).
- * \param ptr Pointer to the array to be resized. May be NULL.
- * \param size The size of an individual element.
- * \param count The number of elements to allocate.
- *
- * \return True unless allocation failed.
- */
-void *reralloc_array_size(const void *ctx, void *ptr, size_t size,
- unsigned count);
-/// @}
-
-/**
- * Free a piece of ralloc-managed memory.
- *
- * This will also free the memory of any children allocated this context.
- */
-void ralloc_free(void *ptr);
-
-/**
- * "Steal" memory from one context, changing it to another.
- *
- * This changes \p ptr's context to \p new_ctx. This is quite useful if
- * memory is allocated out of a temporary context.
- */
-void ralloc_steal(const void *new_ctx, void *ptr);
-
-/**
- * Return the given pointer's ralloc context.
- */
-void *ralloc_parent(const void *ptr);
-
-/**
- * Return a context whose memory will be automatically freed at program exit.
- *
- * The first call to this function creates a context and registers a handler
- * to free it using \c atexit. This may cause trouble if used in a library
- * loaded with \c dlopen.
- */
-void *ralloc_autofree_context(void);
-
-/**
- * Set a callback to occur just before an object is freed.
- */
-void ralloc_set_destructor(const void *ptr, void(*destructor)(void *));
-
-/// \defgroup array String Functions @{
-/**
- * Duplicate a string, allocating the memory from the given context.
- */
-char *ralloc_strdup(const void *ctx, const char *str);
-
-/**
- * Duplicate a string, allocating the memory from the given context.
- *
- * Like \c strndup, at most \p n characters are copied. If \p str is longer
- * than \p n characters, \p n are copied, and a termining \c '\0' byte is added.
- */
-char *ralloc_strndup(const void *ctx, const char *str, size_t n);
-
-/**
- * Concatenate two strings, allocating the necessary space.
- *
- * This appends \p str to \p *dest, similar to \c strcat, using ralloc_resize
- * to expand \p *dest to the appropriate size. \p dest will be updated to the
- * new pointer unless allocation fails.
- *
- * The result will always be null-terminated.
- *
- * \return True unless allocation failed.
- */
-bool ralloc_strcat(char **dest, const char *str);
-
-/**
- * Concatenate two strings, allocating the necessary space.
- *
- * This appends at most \p n bytes of \p str to \p *dest, using ralloc_resize
- * to expand \p *dest to the appropriate size. \p dest will be updated to the
- * new pointer unless allocation fails.
- *
- * The result will always be null-terminated; \p str does not need to be null
- * terminated if it is longer than \p n.
- *
- * \return True unless allocation failed.
- */
-bool ralloc_strncat(char **dest, const char *str, size_t n);
-
-/**
- * Print to a string.
- *
- * This is analogous to \c sprintf, but allocates enough space (using \p ctx
- * as the context) for the resulting string.
- *
- * \return The newly allocated string.
- */
-char *ralloc_asprintf (const void *ctx, const char *fmt, ...) PRINTFLIKE(2, 3);
-
-/**
- * Print to a string, given a va_list.
- *
- * This is analogous to \c vsprintf, but allocates enough space (using \p ctx
- * as the context) for the resulting string.
- *
- * \return The newly allocated string.
- */
-char *ralloc_vasprintf(const void *ctx, const char *fmt, va_list args);
-
-/**
- * Rewrite the tail of an existing string, starting at a given index.
- *
- * Overwrites the contents of *str starting at \p start with newly formatted
- * text, including a new null-terminator. Allocates more memory as necessary.
- *
- * This can be used to append formatted text when the length of the existing
- * string is already known, saving a strlen() call.
- *
- * \sa ralloc_asprintf_append
- *
- * \param str The string to be updated.
- * \param start The index to start appending new data at.
- * \param fmt A printf-style formatting string
- *
- * \p str will be updated to the new pointer unless allocation fails.
- * \p start will be increased by the length of the newly formatted text.
- *
- * \return True unless allocation failed.
- */
-bool ralloc_asprintf_rewrite_tail(char **str, size_t *start,
- const char *fmt, ...)
- PRINTFLIKE(3, 4);
-
-/**
- * Rewrite the tail of an existing string, starting at a given index.
- *
- * Overwrites the contents of *str starting at \p start with newly formatted
- * text, including a new null-terminator. Allocates more memory as necessary.
- *
- * This can be used to append formatted text when the length of the existing
- * string is already known, saving a strlen() call.
- *
- * \sa ralloc_vasprintf_append
- *
- * \param str The string to be updated.
- * \param start The index to start appending new data at.
- * \param fmt A printf-style formatting string
- * \param args A va_list containing the data to be formatted
- *
- * \p str will be updated to the new pointer unless allocation fails.
- * \p start will be increased by the length of the newly formatted text.
- *
- * \return True unless allocation failed.
- */
-bool ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
- va_list args);
-
-/**
- * Append formatted text to the supplied string.
- *
- * This is equivalent to
- * \code
- * ralloc_asprintf_rewrite_tail(str, strlen(*str), fmt, ...)
- * \endcode
- *
- * \sa ralloc_asprintf
- * \sa ralloc_asprintf_rewrite_tail
- * \sa ralloc_strcat
- *
- * \p str will be updated to the new pointer unless allocation fails.
- *
- * \return True unless allocation failed.
- */
-bool ralloc_asprintf_append (char **str, const char *fmt, ...)
- PRINTFLIKE(2, 3);
-
-/**
- * Append formatted text to the supplied string, given a va_list.
- *
- * This is equivalent to
- * \code
- * ralloc_vasprintf_rewrite_tail(str, strlen(*str), fmt, args)
- * \endcode
- *
- * \sa ralloc_vasprintf
- * \sa ralloc_vasprintf_rewrite_tail
- * \sa ralloc_strcat
- *
- * \p str will be updated to the new pointer unless allocation fails.
- *
- * \return True unless allocation failed.
- */
-bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args);
-/// @}
-
-#ifdef __cplusplus
-} /* end of extern "C" */
-#endif
-
-/**
- * Declare C++ new and delete operators which use ralloc.
- *
- * Placing this macro in the body of a class makes it possible to do:
- *
- * TYPE *var = new(mem_ctx) TYPE(...);
- * delete var;
- *
- * which is more idiomatic in C++ than calling ralloc.
- */
-#define DECLARE_RALLOC_CXX_OPERATORS(TYPE) \
-private: \
- static void _ralloc_destructor(void *p) \
- { \
- reinterpret_cast<TYPE *>(p)->~TYPE(); \
- } \
-public: \
- static void* operator new(size_t size, void *mem_ctx) \
- { \
- void *p = ralloc_size(mem_ctx, size); \
- assert(p != NULL); \
- if (!HAS_TRIVIAL_DESTRUCTOR(TYPE)) \
- ralloc_set_destructor(p, _ralloc_destructor); \
- return p; \
- } \
- \
- static void operator delete(void *p) \
- { \
- /* The object's destructor is guaranteed to have already been \
- * called by the delete operator at this point -- Make sure it's \
- * not called again. \
- */ \
- if (!HAS_TRIVIAL_DESTRUCTOR(TYPE)) \
- ralloc_set_destructor(p, NULL); \
- ralloc_free(p); \
- }
-
-
-#endif
diff --git a/icd/intel/compiler/shader/s_expression.h b/icd/intel/compiler/shader/s_expression.h
index 642af19..b3751e4 100644
--- a/icd/intel/compiler/shader/s_expression.h
+++ b/icd/intel/compiler/shader/s_expression.h
@@ -26,7 +26,7 @@
#ifndef S_EXPRESSION_H
#define S_EXPRESSION_H
-#include "main/core.h" /* for Elements */
+#include "libfns.h" // LunarG ADD:
#include "strtod.h"
#include "list.h"
diff --git a/icd/intel/compiler/shader/standalone_scaffolding.cpp b/icd/intel/compiler/shader/standalone_scaffolding.cpp
index 6c25010..7d34e90 100644
--- a/icd/intel/compiler/shader/standalone_scaffolding.cpp
+++ b/icd/intel/compiler/shader/standalone_scaffolding.cpp
@@ -33,23 +33,23 @@
#include <string.h>
#include "ralloc.h"
-void
-_mesa_warning(struct gl_context *ctx, const char *fmt, ...)
-{
- va_list vargs;
- (void) ctx;
+//void
+//_mesa_warning(struct gl_context *ctx, const char *fmt, ...)
+//{
+// va_list vargs;
+// (void) ctx;
- va_start(vargs, fmt);
+// va_start(vargs, fmt);
- /* This output is not thread-safe, but that's good enough for the
- * standalone compiler.
- */
- fprintf(stderr, "Mesa warning: ");
- vfprintf(stderr, fmt, vargs);
- fprintf(stderr, "\n");
+// /* This output is not thread-safe, but that's good enough for the
+// * standalone compiler.
+// */
+// fprintf(stderr, "Mesa warning: ");
+// vfprintf(stderr, fmt, vargs);
+// fprintf(stderr, "\n");
- va_end(vargs);
-}
+// va_end(vargs);
+//}
void
_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
@@ -59,11 +59,11 @@
*ptr = sh;
}
-void
-_mesa_shader_debug(struct gl_context *, GLenum, GLuint *id,
- const char *, int)
-{
-}
+//void
+//_mesa_shader_debug(struct gl_context *, GLenum, GLuint *id,
+// const char *, int)
+//{
+//}
struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
diff --git a/icd/intel/compiler/shader/threadpool.h b/icd/intel/compiler/shader/threadpool.h
deleted file mode 100644
index b1a8ea8..0000000
--- a/icd/intel/compiler/shader/threadpool.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2014 LunarG, Inc. All Rights Reserved.
- *
- * 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 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 THREADPOOL_H
-#define THREADPOOL_H
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct _mesa_threadpool;
-struct _mesa_threadpool_task;
-
-struct _mesa_threadpool *
-_mesa_threadpool_create(int max_threads);
-
-struct _mesa_threadpool *
-_mesa_threadpool_ref(struct _mesa_threadpool *pool);
-
-void
-_mesa_threadpool_unref(struct _mesa_threadpool *pool);
-
-void
-_mesa_threadpool_join(struct _mesa_threadpool *pool, bool graceful);
-
-struct _mesa_threadpool_task *
-_mesa_threadpool_queue_task(struct _mesa_threadpool *pool,
- void (*func)(void *), void *data);
-
-bool
-_mesa_threadpool_complete_tasks(struct _mesa_threadpool *pool,
- struct _mesa_threadpool_task **tasks,
- int num_tasks);
-
-bool
-_mesa_threadpool_complete_task(struct _mesa_threadpool *pool,
- struct _mesa_threadpool_task *task);
-
-struct _mesa_threadpool *
-_mesa_glsl_get_threadpool(int max_threads);
-
-void
-_mesa_glsl_wait_threadpool(void);
-
-void
-_mesa_glsl_destroy_threadpool(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* THREADPOOL_H */