[Mesa-dev] [PATCH 2/6] nir: move shader_enums.[ch] to compiler
Emil Velikov
emil.l.velikov at gmail.com
Mon Jan 18 04:02:24 PST 2016
From: Emil Velikov <emil.velikov at collabora.com>
This way one can reuse it in glsl, nir or other infrastructure without
pulling nir as dependency.
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Android.mk | 1 +
src/SConscript | 1 +
src/compiler/Android.mk | 44 ++++++++++++++++++++++++++
src/compiler/Makefile.am | 23 +++++++++++++-
src/compiler/Makefile.sources | 4 ++-
src/compiler/SConscript | 22 +++++++++++++
src/{glsl/nir => compiler}/shader_enums.c | 0
src/{glsl/nir => compiler}/shader_enums.h | 0
src/gallium/auxiliary/nir/tgsi_to_nir.c | 2 +-
src/gallium/drivers/freedreno/ir3/ir3_nir.h | 2 +-
src/gallium/drivers/freedreno/ir3/ir3_shader.h | 2 +-
src/gallium/targets/dri/SConscript | 1 +
src/gallium/targets/haiku-softpipe/SConscript | 1 +
src/gallium/targets/libgl-gdi/SConscript | 2 +-
src/gallium/targets/libgl-xlib/SConscript | 1 +
src/gallium/targets/osmesa/SConscript | 1 +
src/glsl/Android.mk | 2 ++
src/glsl/Makefile.am | 8 ++++-
src/glsl/Makefile.sources | 4 +--
src/glsl/SConscript | 3 +-
src/glsl/nir/nir.h | 2 +-
src/glsl/nir/nir_print.c | 2 +-
src/mesa/drivers/x11/SConscript | 1 +
src/mesa/main/mtypes.h | 2 +-
24 files changed, 116 insertions(+), 15 deletions(-)
create mode 100644 src/compiler/Android.mk
create mode 100644 src/compiler/SConscript
rename src/{glsl/nir => compiler}/shader_enums.c (100%)
rename src/{glsl/nir => compiler}/shader_enums.h (100%)
diff --git a/Android.mk b/Android.mk
index ed160fb..9b140a7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -86,6 +86,7 @@ ifneq ($(strip $(MESA_GPU_DRIVERS)),)
SUBDIRS := \
src/loader \
src/mapi \
+ src/compiler \
src/glsl \
src/mesa \
src/util \
diff --git a/src/SConscript b/src/SConscript
index 106b87d..8acf9b0 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -5,6 +5,7 @@ if env['platform'] == 'windows':
SConscript('getopt/SConscript')
SConscript('util/SConscript')
+SConscript('compiler/SConscript')
SConscript('glsl/SConscript')
if env['hostonly']:
diff --git a/src/compiler/Android.mk b/src/compiler/Android.mk
new file mode 100644
index 0000000..8ebd497
--- /dev/null
+++ b/src/compiler/Android.mk
@@ -0,0 +1,44 @@
+# Mesa 3-D graphics library
+#
+# Copyright (C) 2015 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 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/Makefile.sources
+
+# ---------------------------------------
+# Build libmesa_compiler
+# ---------------------------------------
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(LIBCOMPILER_FILES)
+
+LOCAL_C_INCLUDES := \
+ $(MESA_TOP)/src/mapi \
+ $(MESA_TOP)/src/mesa \
+ $(MESA_TOP)/src/gallium/include \
+ $(MESA_TOP)/src/gallium/auxiliary
+
+LOCAL_MODULE := libmesa_compiler
+
+include $(MESA_COMMON_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/src/compiler/Makefile.am b/src/compiler/Makefile.am
index 8ed8205..fd1dd4b 100644
--- a/src/compiler/Makefile.am
+++ b/src/compiler/Makefile.am
@@ -22,4 +22,25 @@
include Makefile.sources
-EXTRA_DIST = $(LIBCOMPILER_FILES)
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/mapi \
+ -I$(top_srcdir)/src/mesa/ \
+ -I$(top_srcdir)/src/gallium/include \
+ -I$(top_srcdir)/src/gallium/auxiliary \
+ $(DEFINES)
+
+AM_CFLAGS = \
+ $(VISIBILITY_CFLAGS) \
+ $(MSVC2013_COMPAT_CFLAGS)
+
+AM_CXXFLAGS = \
+ $(VISIBILITY_CXXFLAGS) \
+ $(MSVC2013_COMPAT_CXXFLAGS)
+
+noinst_LTLIBRARIES = libcompiler.la
+
+libcompiler_la_SOURCES = $(LIBCOMPILER_FILES)
+
+EXTRA_DIST = SConscript
diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index f154062..73e1771 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -1,2 +1,4 @@
LIBCOMPILER_FILES = \
- builtin_type_macros.h
+ builtin_type_macros.h \
+ shader_enums.c \
+ shader_enums.h
diff --git a/src/compiler/SConscript b/src/compiler/SConscript
new file mode 100644
index 0000000..412da0e
--- /dev/null
+++ b/src/compiler/SConscript
@@ -0,0 +1,22 @@
+Import('*')
+
+env = env.Clone()
+
+env.MSVC2013Compat()
+
+env.Prepend(CPPPATH = [
+ '#include',
+ '#src',
+ '#src/mapi',
+ '#src/mesa',
+ '#src/gallium/include',
+ '#src/gallium/auxiliary',
+])
+
+sources = env.ParseSourceList('Makefile.sources', 'LIBCOMPILER_FILES')
+
+compiler = env.ConvenienceLibrary(
+ target = 'compiler',
+ source = sources
+)
+Export('compiler')
diff --git a/src/glsl/nir/shader_enums.c b/src/compiler/shader_enums.c
similarity index 100%
rename from src/glsl/nir/shader_enums.c
rename to src/compiler/shader_enums.c
diff --git a/src/glsl/nir/shader_enums.h b/src/compiler/shader_enums.h
similarity index 100%
rename from src/glsl/nir/shader_enums.h
rename to src/compiler/shader_enums.h
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index dfda80f..0d6eb76 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -27,7 +27,7 @@
#include "glsl/nir/nir_control_flow.h"
#include "glsl/nir/nir_builder.h"
#include "glsl/list.h"
-#include "glsl/nir/shader_enums.h"
+#include "compiler/shader_enums.h"
#include "nir/tgsi_to_nir.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.h b/src/gallium/drivers/freedreno/ir3/ir3_nir.h
index 534199d..311a403 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.h
@@ -30,7 +30,7 @@
#define IR3_NIR_H_
#include "glsl/nir/nir.h"
-#include "glsl/nir/shader_enums.h"
+#include "compiler/shader_enums.h"
#include "ir3_shader.h"
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
index b3c28a4..03d4fa2 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
@@ -30,7 +30,7 @@
#define IR3_SHADER_H_
#include "pipe/p_state.h"
-#include "glsl/nir/shader_enums.h"
+#include "compiler/shader_enums.h"
#include "ir3.h"
#include "disasm.h"
diff --git a/src/gallium/targets/dri/SConscript b/src/gallium/targets/dri/SConscript
index b451659..bf3baa7 100644
--- a/src/gallium/targets/dri/SConscript
+++ b/src/gallium/targets/dri/SConscript
@@ -41,6 +41,7 @@ env.Prepend(LIBS = [
pipe_loader,
libloader,
mesautil,
+ compiler,
mesa,
glsl,
gallium,
diff --git a/src/gallium/targets/haiku-softpipe/SConscript b/src/gallium/targets/haiku-softpipe/SConscript
index 210721c..b7c1373 100644
--- a/src/gallium/targets/haiku-softpipe/SConscript
+++ b/src/gallium/targets/haiku-softpipe/SConscript
@@ -6,6 +6,7 @@ env.Prepend(LIBS = [
trace,
rbug,
mesautil,
+ compiler,
mesa,
glsl,
gallium
diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript
index 594f34d..3a63e3e 100644
--- a/src/gallium/targets/libgl-gdi/SConscript
+++ b/src/gallium/targets/libgl-gdi/SConscript
@@ -50,7 +50,7 @@ if env['gles']:
opengl32 = env.SharedLibrary(
target ='opengl32',
source = sources,
- LIBS = wgl + ws_gdi + glapi + mesa + drivers + gallium + glsl + env['LIBS'],
+ LIBS = wgl + ws_gdi + glapi + compiler + mesa + drivers + gallium + glsl + env['LIBS'],
)
env.Alias('opengl32', opengl32)
diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript
index 687a8b9d..e1c78dd 100644
--- a/src/gallium/targets/libgl-xlib/SConscript
+++ b/src/gallium/targets/libgl-xlib/SConscript
@@ -29,6 +29,7 @@ env.Prepend(LIBS = [
ws_xlib,
glapi,
mesautil,
+ compiler,
mesa,
glsl,
gallium,
diff --git a/src/gallium/targets/osmesa/SConscript b/src/gallium/targets/osmesa/SConscript
index 4a9115b..eeaacbc 100644
--- a/src/gallium/targets/osmesa/SConscript
+++ b/src/gallium/targets/osmesa/SConscript
@@ -12,6 +12,7 @@ env.Prepend(LIBS = [
st_osmesa,
ws_null,
glapi,
+ compiler,
mesa,
gallium,
trace,
diff --git a/src/glsl/Android.mk b/src/glsl/Android.mk
index f63b7da..9cbb9a3 100644
--- a/src/glsl/Android.mk
+++ b/src/glsl/Android.mk
@@ -44,6 +44,8 @@ LOCAL_C_INCLUDES := \
$(MESA_TOP)/src/gallium/include \
$(MESA_TOP)/src/gallium/auxiliary
+LOCAL_STATIC_LIBRARIES := libmesa_compiler
+
LOCAL_MODULE := libmesa_glsl
include $(LOCAL_PATH)/Android.gen.mk
diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index ba7af7c..07d5267 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -137,7 +137,10 @@ glcpp_glcpp_LDADD = \
$(top_builddir)/src/libglsl_util.la \
-lm
-libglsl_la_LIBADD = libglcpp.la
+libglsl_la_LIBADD = \
+ $(top_builddir)/src/compiler/libcompiler.la \
+ libglcpp.la
+
libglsl_la_SOURCES = \
glsl_lexer.cpp \
glsl_parser.cpp \
@@ -147,6 +150,9 @@ libglsl_la_SOURCES = \
$(NIR_GENERATED_FILES) \
$(GLSL_TO_NIR_FILES)
+libnir_la_LIBADD = \
+ $(top_builddir)/src/compiler/libcompiler.la
+
libnir_la_SOURCES = \
$(NIR_FILES) \
$(NIR_GENERATED_FILES)
diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 8b43eb8..5a576bc 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -81,9 +81,7 @@ NIR_FILES = \
nir/nir_vla.h \
nir/nir_worklist.c \
nir/nir_worklist.h \
- nir/nir_types.cpp \
- nir/shader_enums.h \
- nir/shader_enums.c
+ nir/nir_types.cpp
# libglsl
diff --git a/src/glsl/SConscript b/src/glsl/SConscript
index a9d38c1..e89d4e0 100644
--- a/src/glsl/SConscript
+++ b/src/glsl/SConscript
@@ -65,7 +65,6 @@ for l in ('LIBGLCPP_FILES', 'LIBGLSL_FILES'):
# XXX: Remove this once we build NIR and NIR_FILES.
glsl_sources += [
'nir/glsl_types.cpp',
- 'nir/shader_enums.c',
]
if env['msvc']:
@@ -115,7 +114,7 @@ if env['platform'] == 'windows':
'user32',
])
-env.Prepend(LIBS = [glsl])
+env.Prepend(LIBS = [compiler, glsl])
glsl_compiler = env.Program(
target = 'glsl_compiler',
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index e2bd2bf..79b35f7 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -35,7 +35,7 @@
#include "util/set.h"
#include "util/bitset.h"
#include "nir_types.h"
-#include "shader_enums.h"
+#include "compiler/shader_enums.h"
#include <stdio.h>
#include "nir_opcodes.h"
diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
index be9ca4e..48ecb48 100644
--- a/src/glsl/nir/nir_print.c
+++ b/src/glsl/nir/nir_print.c
@@ -26,7 +26,7 @@
*/
#include "nir.h"
-#include "shader_enums.h"
+#include "compiler/shader_enums.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/mesa/drivers/x11/SConscript b/src/mesa/drivers/x11/SConscript
index d29f987..4541997 100644
--- a/src/mesa/drivers/x11/SConscript
+++ b/src/mesa/drivers/x11/SConscript
@@ -18,6 +18,7 @@ env.Prepend(LIBPATH = env['X11_LIBPATH'])
env.Prepend(LIBS = [
glapi,
mesautil,
+ compiler,
glsl,
mesa,
])
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0992d4d..3d73918 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -42,7 +42,7 @@
#include "main/config.h"
#include "glapi/glapi.h"
#include "math/m_matrix.h" /* GLmatrix */
-#include "glsl/nir/shader_enums.h"
+#include "compiler/shader_enums.h"
#include "main/formats.h" /* MESA_FORMAT_COUNT */
--
2.6.2
More information about the mesa-dev
mailing list