Commit 1e0da623 authored by Kenneth Graunke's avatar Kenneth Graunke Committed by Jason Ekstrand

util: Move ralloc to a new src/util directory.

For a long time, we've wanted a place to put utility code which isn't
directly tied to Mesa or Gallium internals.  This patch creates a new
src/util directory for exactly that purpose, and builds the contents as
libmesautil.la.

ralloc seemed like a good first candidate.  These days, it's directly
used by mesa/main, i965, i915, and r300g, so keeping it in src/glsl
didn't make much sense.
Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>

v2 (Jason Ekstrand): More realloc uses and some scons fixes
Signed-off-by: Jason Ekstrand's avatarJason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
parent dcc29c18
......@@ -2279,7 +2279,9 @@ AC_CONFIG_FILES([Makefile
src/mesa/drivers/osmesa/osmesa.pc
src/mesa/drivers/x11/Makefile
src/mesa/main/tests/Makefile
src/mesa/main/tests/hash_table/Makefile])
src/mesa/main/tests/hash_table/Makefile
src/util/Makefile
src/util/tests/Makefile])
dnl Sort the dirs alphabetically
GALLIUM_TARGET_DIRS=`echo $GALLIUM_TARGET_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
......
......@@ -19,7 +19,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
SUBDIRS = gtest mapi
SUBDIRS = util gtest mapi
if NEED_OPENGL_COMMON
SUBDIRS += glsl mesa
......
......@@ -4,6 +4,7 @@ Import('*')
if env['platform'] == 'windows':
SConscript('getopt/SConscript')
SConscript('util/SConscript')
SConscript('glsl/SConscript')
if env['hostonly']:
......
......@@ -4,6 +4,7 @@ include Makefile.sources
include $(top_srcdir)/src/gallium/Automake.inc
AM_CFLAGS = \
-I$(top_srcdir)/src/util \
-I$(top_srcdir)/src/mesa/program \
-I$(top_srcdir)/src/mesa \
-I$(top_srcdir)/src/glsl \
......@@ -17,6 +18,7 @@ check_PROGRAMS = r300_compiler_tests
TESTS = r300_compiler_tests
r300_compiler_tests_LDADD = libr300.la libr300-helper.la \
$(top_builddir)/src/util/libmesautil.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
$(GALLIUM_COMMON_LIB_DEPS)
r300_compiler_tests_CPPFLAGS = \
......@@ -32,4 +34,5 @@ libr300_la_SOURCES = $(C_SOURCES)
#
# Solve this by building them into a separate helper library that can be linked
# in place of libmesagallium.
libr300_helper_la_CPPFLAGS = -I$(top_srcdir)/src
libr300_helper_la_SOURCES = $(HELPER_SOURCES)
../../../glsl/ralloc.c
\ No newline at end of file
../../../util/ralloc.c
\ No newline at end of file
......@@ -27,6 +27,7 @@ if env['gles']:
env.Prepend(LIBS = [
st_xlib,
ws_xlib,
mesautil,
glapi,
mesa,
glsl,
......
......@@ -21,6 +21,7 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa/ \
-I$(top_srcdir)/src/glsl/glcpp \
......@@ -34,7 +35,6 @@ include Makefile.sources
TESTS = glcpp/tests/glcpp-test \
tests/general-ir-test \
tests/optimization-test \
tests/ralloc-test \
tests/sampler-types-test \
tests/uniform-initializer-test
......@@ -47,7 +47,6 @@ check_PROGRAMS = \
glcpp/glcpp \
glsl_test \
tests/general-ir-test \
tests/ralloc-test \
tests/sampler-types-test \
tests/uniform-initializer-test
......@@ -87,14 +86,6 @@ tests_uniform_initializer_test_LDADD = \
$(top_builddir)/src/glsl/libglsl.la \
$(PTHREAD_LIBS)
tests_ralloc_test_SOURCES = \
tests/ralloc_test.cpp \
$(top_builddir)/src/glsl/ralloc.c
tests_ralloc_test_CFLAGS = $(PTHREAD_CFLAGS)
tests_ralloc_test_LDADD = \
$(top_builddir)/src/gtest/libgtest.la \
$(PTHREAD_LIBS)
tests_sampler_types_test_SOURCES = \
$(top_srcdir)/src/mesa/program/prog_hash_table.c\
$(top_srcdir)/src/mesa/program/symbol_table.c \
......@@ -107,6 +98,8 @@ tests_sampler_types_test_LDADD = \
$(top_builddir)/src/glsl/libglsl.la \
$(PTHREAD_LIBS)
libglcpp_la_LIBADD = \
$(top_builddir)/src/util/libmesautil.la
libglcpp_la_SOURCES = \
glcpp/glcpp-lex.c \
glcpp/glcpp-parse.c \
......
......@@ -6,7 +6,6 @@ GLSL_BUILDDIR = $(top_builddir)/src/glsl
# libglcpp
LIBGLCPP_FILES = \
$(GLSL_SRCDIR)/ralloc.c \
$(GLSL_SRCDIR)/glcpp/pp.c
LIBGLCPP_GENERATED_FILES = \
......
......@@ -8,12 +8,15 @@ env = env.Clone()
env.Prepend(CPPPATH = [
'#include',
'#src',
'#src/mapi',
'#src/mesa',
'#src/glsl',
'#src/glsl/glcpp',
])
env.Prepend(LIBS = [mesautil])
# Make glcpp-parse.h and glsl_parser.h reachable from the include path.
env.Append(CPPPATH = [Dir('.').abspath, Dir('glcpp').abspath])
......
......@@ -29,7 +29,7 @@
#include "main/mtypes.h"
#include "../ralloc.h"
#include "util/ralloc.h"
#include "program/hash_table.h"
......
......@@ -31,7 +31,7 @@ extern "C" {
#include "main/shaderobj.h"
}
#include "ralloc.h"
#include "util/ralloc.h"
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
......
......@@ -81,7 +81,7 @@ enum glsl_interface_packing {
#ifdef __cplusplus
#include "GL/gl.h"
#include "ralloc.h"
#include "util/ralloc.h"
struct glsl_type {
GLenum gl_type;
......
......@@ -29,7 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "ralloc.h"
#include "util/ralloc.h"
#include "glsl_types.h"
#include "list.h"
#include "ir_visitor.h"
......
......@@ -69,7 +69,7 @@
#endif
#include <assert.h>
#include "ralloc.h"
#include "util/ralloc.h"
struct exec_node {
struct exec_node *next;
......
......@@ -31,7 +31,7 @@
#include <assert.h>
#include <string.h>
#include "ralloc.h"
#include "util/ralloc.h"
void
_mesa_warning(struct gl_context *ctx, const char *fmt, ...)
......
......@@ -25,7 +25,6 @@
#include "main/compiler.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "ir.h"
#include "glsl_parser_extras.h"
#include "glsl_symbol_table.h"
......
......@@ -24,7 +24,7 @@
#include "main/compiler.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "util/ralloc.h"
#include "uniform_initializer_utils.h"
namespace linker {
......
......@@ -24,7 +24,6 @@
#include "main/compiler.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "ir.h"
TEST(ir_variable_constructor, interface)
......
......@@ -24,7 +24,7 @@
#include "main/compiler.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "util/ralloc.h"
#include "ir.h"
#include "linker.h"
......
......@@ -24,7 +24,6 @@
#include "main/compiler.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "ir.h"
/**
......
......@@ -24,7 +24,7 @@
#include "main/compiler.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "util/ralloc.h"
#include "uniform_initializer_utils.h"
namespace linker {
......
......@@ -23,7 +23,7 @@
#include <gtest/gtest.h>
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "util/ralloc.h"
#include "uniform_initializer_utils.h"
#include <stdio.h>
......
......@@ -24,7 +24,7 @@
#include "main/compiler.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "ralloc.h"
#include "util/ralloc.h"
#include "ir.h"
#include "program/hash_table.h"
......
......@@ -352,6 +352,7 @@ MESA_GALLIUM_FILES = \
INCLUDE_DIRS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/glsl \
-I$(top_builddir)/src/glsl \
-I$(top_srcdir)/src/glsl/glcpp \
......
......@@ -11,6 +11,7 @@ from sys import executable as python_cmd
env = env.Clone()
env.Append(CPPPATH = [
'#/src',
'#/src/mapi',
'#/src/glsl',
'#/src/mesa',
......
......@@ -84,7 +84,7 @@
#include "drivers/common/meta.h"
#include "main/enums.h"
#include "main/glformats.h"
#include "../glsl/ralloc.h"
#include "util/ralloc.h"
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
......
......@@ -49,7 +49,7 @@
#include "main/viewport.h"
#include "swrast/swrast.h"
#include "drivers/common/meta.h"
#include "../glsl/ralloc.h"
#include "util/ralloc.h"
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
......
......@@ -35,7 +35,7 @@
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "intel_tris.h"
#include "../glsl/ralloc.h"
#include "util/ralloc.h"
/***************************************
* Mesa's Driver Functions
......
......@@ -40,7 +40,7 @@
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "../glsl/ralloc.h"
#include "util/ralloc.h"
#include "i915_reg.h"
#include "i915_program.h"
......
......@@ -56,7 +56,7 @@
#include "intel_mipmap_tree.h"
#include "utils.h"
#include "../glsl/ralloc.h"
#include "util/ralloc.h"
int INTEL_DEBUG = (0);
......
......@@ -21,7 +21,7 @@
* IN THE SOFTWARE.
*/
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "brw_blorp_blit_eu.h"
#include "brw_blorp.h"
......
......@@ -28,7 +28,7 @@ extern "C" {
#include "main/renderbuffer.h"
}
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "intel_fbo.h"
......
......@@ -42,7 +42,7 @@
#include "brw_state.h"
#include "brw_clip.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#define FRONT_UNFILLED_BIT 0x1
#define BACK_UNFILLED_BIT 0x2
......
......@@ -65,7 +65,7 @@
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
/***************************************
* Mesa's Driver Functions
......
......@@ -34,7 +34,7 @@
#include "brw_defines.h"
#include "brw_eu.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
/**
* Converts a BRW_REGISTER_TYPE_* enum to a short string (F, UD, and so on).
......
......@@ -34,7 +34,7 @@
#include "brw_defines.h"
#include "brw_eu.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
/***********************************************************************
* Internal helper for constructing instructions
......
......@@ -43,7 +43,7 @@
#include "brw_state.h"
#include "brw_gs.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
static void compile_ff_gs_prog(struct brw_context *brw,
struct brw_ff_gs_prog_key *key)
......
......@@ -57,7 +57,7 @@
#include "main/blend.h"
#include "main/varray.h"
#include "main/shaderapi.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "drivers/common/meta.h"
#include "brw_meta_util.h"
......
......@@ -50,7 +50,7 @@
#include "main/mtypes.h"
#include "main/performance_monitor.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "brw_context.h"
#include "brw_defines.h"
......
......@@ -38,7 +38,7 @@
#include "program/program.h"
#include "program/programopt.h"
#include "tnl/tnl.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "glsl/ir.h"
#include "brw_context.h"
......
......@@ -45,7 +45,7 @@
#include "brw_sf.h"
#include "brw_state.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
static void compile_sf_prog( struct brw_context *brw,
struct brw_sf_prog_key *key )
......
......@@ -32,7 +32,7 @@
#include "brw_state.h"
#include "intel_batchbuffer.h"
#include "main/imports.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
static void
brw_track_state_batch(struct brw_context *brw,
......
......@@ -38,7 +38,7 @@
#include "program/prog_print.h"
#include "program/prog_parameter.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
static inline void assign_vue_slot(struct brw_vue_map *vue_map,
int varying)
......
......@@ -40,7 +40,7 @@
#include "program/program.h"
#include "intel_mipmap_tree.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
/**
* Return a bitfield where bit n is set if barycentric interpolation mode n
......
......@@ -32,7 +32,7 @@ extern "C" {
#include "brw_context.h"
} /* extern "C" */
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "brw_eu.h"
#include "brw_reg.h"
#include "gen8_generator.h"
......
......@@ -37,7 +37,7 @@
#include "main/fbobject.h"
#include "main/version.h"
#include "swrast/s_renderbuffer.h"
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "utils.h"
#include "xmlpool.h"
......
......@@ -24,7 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "glsl/ralloc.h"
#include "util/ralloc.h"
#include "brw_context.h"
#include "brw_eu.h"
......
......@@ -16,6 +16,7 @@ env.Prepend(LIBPATH = env['X11_LIBPATH'])
env.Prepend(LIBS = [
glapi,
mesautil,
glsl,
mesa,
])
......
......@@ -45,7 +45,7 @@
#include "main/hash_table.h"
#include "main/macros.h"
#include "ralloc.h"
#include "util/ralloc.h"
static const uint32_t deleted_key_value;
......
......@@ -43,7 +43,7 @@
#include "mtypes.h"
#include "performance_monitor.h"
#include "bitset.h"
#include "ralloc.h"
#include "util/ralloc.h"
void
_mesa_init_performance_monitors(struct gl_context *ctx)
......
......@@ -44,7 +44,7 @@
#include "main/uniforms.h"
#include "program/program.h"
#include "program/prog_parameter.h"
#include "ralloc.h"
#include "util/ralloc.h"
#include <stdbool.h>
#include "../glsl/glsl_parser_extras.h"
#include "../glsl/ir_uniform.h"
......
......@@ -36,7 +36,7 @@
#include "macros.h"
#include "set.h"
#include "ralloc.h"
#include "util/ralloc.h"
/*
* From Knuth -- a good choice for hash/rehash values is p, p-2 where
......
......@@ -52,7 +52,7 @@
#include "program/program.h"
#include "program/prog_print.h"
#include "program/prog_parameter.h"
#include "ralloc.h"
#include "util/ralloc.h"
#include <stdbool.h>
#include "../glsl/glsl_parser_extras.h"
#include "../glsl/ir.h"
......
......@@ -40,7 +40,7 @@
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/hash_table.h"
#include "ralloc.h"
#include "util/ralloc.h"
/**********************************************************************/
/*** Shader object functions ***/
......
......@@ -5,6 +5,7 @@ AM_CFLAGS = \
$(PTHREAD_CFLAGS)
AM_CPPFLAGS = \
-I$(top_srcdir)/src/gtest/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa \
-I$(top_builddir)/src/mesa \
......
......@@ -71,8 +71,8 @@
*/
#include <stdbool.h>
#include <ralloc.h>
#include "util/ralloc.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
......
# Copyright © 2014 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.
SUBDIRS = . tests
include Makefile.sources
noinst_LTLIBRARIES = libmesautil.la
libmesautil_la_CPPFLAGS = \
$(DEFINES) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/mesa \
$(VISIBILITY_CFLAGS)
libmesautil_la_SOURCES = $(MESA_UTIL_FILES)
### Tests:
CFLAGS_FOR_TESTS = $(PTHREAD_CFLAGS)
CPPFLAGS_FOR_TESTS = \
$(libmesautil_la_CPPFLAGS) \
-I$(top_srcdir)/src/gtest/include
LDADD_FOR_TESTS = \
$(top_builddir)/src/gtest/libgtest.la \
$(top_builddir)/src/util/libmesautil.la \
$(PTHREAD_LIBS)
TESTS = tests/ralloc_test
check_PROGRAMS = $(TESTS)
tests_ralloc_test_SOURCES = tests/ralloc_test.cpp
tests_ralloc_test_CFLAGS = $(CFLAGS_FOR_TESTS)
tests_ralloc_test_CPPFLAGS = $(CPPFLAGS_FOR_TESTS)
tests_ralloc_test_LDADD = $(LDADD_FOR_TESTS)
MESA_UTIL_FILES := \
ralloc.c
import common
Import('*')
from sys import executable as python_cmd
env = env.Clone()
env.Prepend(CPPPATH = [
'#include',
'#src/mesa',
'#src/util',
])
# parse Makefile.sources
source_lists = env.ParseSourceList('Makefile.sources')
mesautil_sources = source_lists['MESA_UTIL_FILES']
mesautil = env.ConvenienceLibrary(
target = 'mesautil',
source = mesautil_sources,
)
env.Alias('mesautil', mesautil)
Export('mesautil')
# Copyright © 2014 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.
AM_CFLAGS = \
$(PTHREAD_CFLAGS)
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/util \
-I$(top_srcdir)/src/mesa \
-I$(top_srcdir)/src/gtest/include \
$(DEFINES) $(INCLUDE_DIRS)
LDADD = \
$(top_builddir)/src/gtest/libgtest.la \
$(top_builddir)/src/util/libmesautil.la \
$(PTHREAD_LIBS)
TESTS = ralloc_test
check_PROGRAMS = $(TESTS)
ralloc_test_SOURCES = ralloc_test.cpp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment