glsl2: Replace the GLSL compiler with the glsl2 project.
authorEric Anholt <eric@anholt.net>
Mon, 21 Jun 2010 18:29:15 +0000 (11:29 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 25 Jun 2010 00:23:21 +0000 (17:23 -0700)
configure.ac
src/glsl/Makefile
src/glsl/Makefile.am
src/mesa/Makefile
src/mesa/drivers/dri/Makefile.template
src/mesa/shader/ir_to_mesa.cpp
src/mesa/shader/shader_api.c
src/mesa/sources.mak

index 21123eccccb33c184a21582fe6fa7b37fa3b509b..bf42992b2fd67f9d4e89bff897de95c1bd8b6b62 100644 (file)
@@ -462,6 +462,8 @@ xxlib|xdri|xosmesa)
     ;;
 esac
 
+PKG_CHECK_MODULES([TALLOC], [talloc])
+
 dnl
 dnl Driver specific build directories
 dnl
@@ -852,7 +854,7 @@ if test "$mesa_driver" = dri; then
         [AC_MSG_ERROR([Expat required for DRI.])])
 
     # put all the necessary libs together
-    DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
+    DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS $TALLOC_LIBS"
 fi
 AC_SUBST([DRI_DIRS])
 AC_SUBST([EXPAT_INCLUDES])
index ca7f2d2ac7d1c9985de5d3366dad43146c8dc857..91e4d2e05dd352b57bc9f0e818ab63d1bb0b955c 100644 (file)
-# src/glsl/Makefile
+#src/glsl/pp/Makefile
 
 TOP = ../..
 
 include $(TOP)/configs/current
 
-SUBDIRS = pp cl apps
+LIBNAME = glsl
 
-default install clean:
-       @for dir in $(SUBDIRS) ; do \
-               if [ -d $$dir ] ; then \
-                       (cd $$dir && $(MAKE) $@) || exit 1; \
-               fi \
-       done
+C_SOURCES = \
+       glcpp/glcpp.c \
+       glcpp/glcpp-lex.c \
+       glcpp/glcpp-parse.c \
+       glcpp/pp.c \
+       glcpp/xtalloc.c
 
+CXX_SOURCES = \
+       ast_expr.cpp \
+       ast_function.cpp \
+       ast_to_hir.cpp \
+       ast_type.cpp \
+       builtin_function.cpp \
+       glsl_lexer.cpp \
+       glsl_parser.cpp \
+       glsl_parser_extras.cpp \
+       glsl_types.cpp \
+       hir_field_selection.cpp \
+       ir_basic_block.cpp \
+       ir_clone.cpp \
+       ir_constant_expression.cpp \
+       ir_constant_folding.cpp \
+       ir_constant_variable.cpp \
+       ir_copy_propagation.cpp \
+       ir.cpp \
+       ir_dead_code.cpp \
+       ir_dead_code_local.cpp \
+       ir_expression_flattening.cpp \
+       ir_function_can_inline.cpp \
+       ir_function.cpp \
+       ir_function_inlining.cpp \
+       ir_hierarchical_visitor.cpp \
+       ir_hv_accept.cpp \
+       ir_if_simplification.cpp \
+       ir_print_visitor.cpp \
+       ir_reader.cpp \
+       ir_swizzle_swizzle.cpp \
+       ir_validate.cpp \
+       ir_variable.cpp \
+       ir_vec_index_to_swizzle.cpp \
+       linker.cpp \
+       s_expression.cpp
+
+LIBS = \
+       $(TOP)/src/glsl/libglsl.a \
+       $(shell pkg-config --libs talloc)
+
+APPS = glsl_compiler
+GLSL2_C_SOURCES = \
+       ../mesa/shader/hash_table.c \
+       ../mesa/shader/symbol_table.c
+GLSL2_CXX_SOURCES = \
+       main.cpp
+
+GLSL2_OBJECTS = \
+       $(GLSL2_C_SOURCES:.c=.o) \
+       $(GLSL2_CXX_SOURCES:.cpp=.o)
+
+### Basic defines ###
+
+OBJECTS = \
+       $(C_SOURCES:.c=.o) \
+       $(CXX_SOURCES:.cpp=.o)
+
+INCLUDES = \
+       -I. \
+       -I../mesa \
+       -I../mapi \
+       -I../mesa/shader \
+       $(LIBRARY_INCLUDES)
+
+
+##### TARGETS #####
+
+default: depend lib$(LIBNAME).a $(APPS)
+
+lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template
+       $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS)
+
+depend: $(CXX_SOURCES) $(GLSL2_CXX_SOURCES) $(GLSL2_C_SOURCES)
+       rm -f depend
+       touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $@ 2> /dev/null
+
+# Remove .o and backup files
+clean:
+       rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak
+       -rm -f $(APPS)
+
+# Dummy target
+install:
+       @echo -n ""
+
+
+##### RULES #####
+
+glsl_compiler: $(GLSL2_OBJECTS) libglsl.a
+       $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) $(LIBS) -o $@
+
+.cpp.o:
+       $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+
+glsl_lexer.cpp: glsl_lexer.lpp
+       flex --never-interactive --outfile="$@"  $<
+
+glsl_parser.cpp: glsl_parser.ypp
+       bison -v -o "$@" --defines=glsl_parser.h $<
+
+glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
+       flex --never-interactive --outfile="$@" $<
+
+glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
+       bison -v -o "$@" --defines=glcpp/glcpp-parse.h $<
+
+builtin_function.cpp: builtins/*/*
+       ./builtins/tools/generate_builtins.pl > builtin_function.cpp
+
+-include depend
index c34f7d8abfb6a16a5f9767d492ffc6173739d07e..5728a8b63da3cc47f4046fbb4aa769eb04ef3092 100644 (file)
@@ -32,7 +32,7 @@ glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS)
 glsl_SOURCES = \
        main.cpp \
        builtin_types.h \
-       symbol_table.c hash_table.c glsl_types.cpp \
+       glsl_types.cpp \
        glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \
        ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \
        ir.cpp hir_field_selection.cpp builtin_function.cpp \
@@ -62,11 +62,7 @@ glsl_SOURCES = \
        ir_to_mesa.h \
        ir_validate.cpp \
        ir_vec_index_to_swizzle.cpp \
-       linker.cpp \
-       mesa/shader/prog_instruction.c \
-       mesa/shader/prog_instruction.h \
-       mesa/shader/prog_print.c \
-       mesa/shader/prog_print.h
+       linker.cpp
 
 BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp
 CLEANFILES = $(BUILT_SOURCES)
index 4f81768924a3fbf813ee46d0e92d493c24d8c1d0..84ced279536ca4b87bb5c651a6973567cf22c6c9 100644 (file)
@@ -35,16 +35,24 @@ MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS))
 MESA_INCLUDES := $(INCLUDE_DIRS)
 ES1_INCLUDES := -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS)
 ES2_INCLUDES := -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS)
-
+MESA_INCLUDES := -I$(TOP)/src/glsl $(MESA_INCLUDES)
 
 define mesa-cc-c
        @mkdir -p $(dir $@)
        $(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CFLAGS)
 endef
 
+define mesa-cxx-c
+       @mkdir -p $(dir $@)
+       $(CXX) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CXXFLAGS)
+endef
+
 $(MESA_OBJ_DIR)/%.o: %.c
        $(call mesa-cc-c,MESA)
 
+$(MESA_OBJ_DIR)/%.o: %.cpp
+       $(call mesa-cxx-c,MESA)
+
 $(MESA_OBJ_DIR)/%.o: %.S
        $(call mesa-cc-c,MESA)
 
@@ -63,7 +71,7 @@ $(ES2_OBJ_DIR)/%.o: %.S
 
 # Default: build dependencies, then asm_subdirs, GLSL built-in lib,
 # then convenience libs (.a) and finally the device drivers:
-default: $(DEPENDS) asm_subdirs glsl_builtin \
+default: $(DEPENDS) asm_subdirs \
        $(MESA_LIBS) $(ES1_LIBS) $(ES2_LIBS) driver_subdirs
 
 main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py
@@ -113,12 +121,6 @@ asm_subdirs:
        fi
 
 
-######################################################################
-# GLSL built-in library
-glsl_builtin:
-       (cd shader/slang/library && $(MAKE)) || exit 1 ;
-
-
 ######################################################################
 # Dependency generation
 
@@ -234,7 +236,6 @@ clean: clean-es1 clean-es2
        -rm -f depend depend.bak libmesa.a libmesagallium.a
        -rm -f drivers/*/*.o
        -rm -f *.pc
-       -rm -f shader/slang/library/*_gc.h
        -@cd drivers/dri && $(MAKE) clean
        -@cd drivers/x11 && $(MAKE) clean
        -@cd drivers/osmesa && $(MAKE) clean
index 8cb25439e4843ba15c36c1bf605bc10255163c9e..35daacfacdc9e21e9122c33c63e56a20b03a740b 100644 (file)
@@ -54,9 +54,9 @@ lib: symlinks subdirs depend
 
 $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \
                $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o
-       $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+       $(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
                $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS)
-       $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
+       $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
        @rm -f $@.test
        mv -f $@.tmp $@
 
index 26449c5a5c4e212e9e3ca170803e3dc947576982..9fc1268e5ab64e1296260944a2afba2ecf9185ee 100644 (file)
@@ -36,6 +36,7 @@
 #include "glsl_types.h"
 
 extern "C" {
+#include "main/mtypes.h"
 #include "shader/prog_instruction.h"
 #include "shader/prog_print.h"
 }
index c414e89825fb365cfba0071d4e7b5ac1eaba47c8..a584f6072c44571ad903b9a101bf2dc95df34a07 100644 (file)
@@ -44,8 +44,6 @@
 #include "shader/prog_uniform.h"
 #include "shader/shader_api.h"
 #include "shader/uniforms.h"
-#include "shader/slang/slang_compile.h"
-#include "shader/slang/slang_link.h"
 
 
 /**
@@ -1100,7 +1098,7 @@ _mesa_compile_shader(GLcontext *ctx, GLuint shaderObj)
    /* this call will set the sh->CompileStatus field to indicate if
     * compilation was successful.
     */
-   (void) _slang_compile(ctx, sh);
+   _mesa_glsl_compile_shader(ctx, sh);
 }
 
 
@@ -1126,7 +1124,7 @@ _mesa_link_program(GLcontext *ctx, GLuint program)
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
-   _slang_link(ctx, program, shProg);
+   _mesa_glsl_link_shader(ctx, shProg);
 
    /* debug code */
    if (0) {
index ddd63cea0b4d52f27449e10781bf4dbbcb0cc034..117b3f3d2b9e6fd58800b12722a74278a0e2955a 100644 (file)
@@ -250,6 +250,9 @@ SHADER_SOURCES = \
        shader/shader_api.c \
        shader/uniforms.c
 
+SHADER_CXX_SOURCES = \
+       shader/ir_to_mesa.cpp
+
 SLANG_SOURCES =        \
        shader/slang/slang_builtin.c    \
        shader/slang/slang_codegen.c    \
@@ -324,8 +327,10 @@ MESA_SOURCES = \
        $(SWRAST_SOURCES)       \
        $(SWRAST_SETUP_SOURCES) \
        $(COMMON_DRIVER_SOURCES)\
-       $(ASM_C_SOURCES)        \
-       $(SLANG_SOURCES)
+       $(ASM_C_SOURCES)
+
+MESA_CXX_SOURCES = \
+        $(SHADER_CXX_SOURCES)
 
 # Sources for building Gallium drivers
 MESA_GALLIUM_SOURCES = \
@@ -335,12 +340,15 @@ MESA_GALLIUM_SOURCES = \
        $(STATETRACKER_SOURCES) \
        $(SHADER_SOURCES)       \
        ppc/common_ppc.c        \
-       x86/common_x86.c        \
-       $(SLANG_SOURCES)
+       x86/common_x86.c
+
+MESA_GALLIUM_CXX_SOURCES = \
+        $(SHADER_CXX_SOURCES)
 
 # All the core C sources, for dependency checking
 ALL_SOURCES = \
        $(MESA_SOURCES)         \
+       $(MESA_CXX_SOURCES)     \
        $(MESA_ASM_SOURCES)     \
        $(STATETRACKER_SOURCES)
 
@@ -349,10 +357,12 @@ ALL_SOURCES = \
 
 MESA_OBJECTS = \
        $(MESA_SOURCES:.c=.o) \
+       $(MESA_CXX_SOURCES:.cpp=.o) \
        $(MESA_ASM_SOURCES:.S=.o)
 
 MESA_GALLIUM_OBJECTS = \
        $(MESA_GALLIUM_SOURCES:.c=.o) \
+       $(MESA_GALLIUM_CXX_SOURCES:.cpp=.o) \
        $(MESA_ASM_SOURCES:.S=.o)
 
 
@@ -362,8 +372,7 @@ COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o)
 ### Other archives/libraries
 
 GLSL_LIBS = \
-       $(TOP)/src/glsl/pp/libglslpp.a \
-       $(TOP)/src/glsl/cl/libglslcl.a
+       $(TOP)/src/glsl/libglsl.a
 
 
 ### Include directories