From 9da8608136afb62ad2ebaf6dc80a41f7013c09ff Mon Sep 17 00:00:00 2001
From: Niall Walsh <niallwalsh@users.berlios.de>
Date: Sat, 2 Nov 2013 01:04:45 +0000
Subject: [PATCH 5/6] add first set of libv mesa patches from 9.2.1

---
 ...rovide-CompileShader-and-LinkShader-hooks.patch |  92 +++++++++++
 debian/patches/libv-0002-build-libdricommon.patch  |  40 +++++
 ...add-dricore-and-dricommon-pkgconfig-files.patch | 100 ++++++++++++
 ...-install-mesa-sdk-headers-into-the-system.patch | 180 +++++++++++++++++++++
 debian/patches/series                              |   4 +
 5 files changed, 416 insertions(+)
 create mode 100644 debian/patches/libv-0001-provide-CompileShader-and-LinkShader-hooks.patch
 create mode 100644 debian/patches/libv-0002-build-libdricommon.patch
 create mode 100644 debian/patches/libv-0003-add-dricore-and-dricommon-pkgconfig-files.patch
 create mode 100644 debian/patches/libv-0004-install-mesa-sdk-headers-into-the-system.patch

diff --git a/debian/patches/libv-0001-provide-CompileShader-and-LinkShader-hooks.patch b/debian/patches/libv-0001-provide-CompileShader-and-LinkShader-hooks.patch
new file mode 100644
index 0000000..f7ff4d0
--- /dev/null
+++ b/debian/patches/libv-0001-provide-CompileShader-and-LinkShader-hooks.patch
@@ -0,0 +1,92 @@
+From 76ffbb903813118427bfa524f7c92e042a958d6e Mon Sep 17 00:00:00 2001
+From: Luc Verhaegen <libv@skynet.be>
+Date: Tue, 29 Oct 2013 15:35:25 +0100
+Subject: [PATCH 1/4] provide CompileShader and LinkShader hooks
+
+This to allow bypassing of the glsl compiler.
+
+Signed-off-by: Luc Verhaegen <libv@skynet.be>
+---
+ src/mesa/main/dd.h        |    5 +++++
+ src/mesa/main/shaderapi.c |    4 ++--
+ src/mesa/main/shaderobj.c |    8 +++++++-
+ 3 files changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
+index c1d9b2c..4dd223f 100644
+--- a/src/mesa/main/dd.h
++++ b/src/mesa/main/dd.h
+@@ -661,9 +661,14 @@ struct dd_function_table {
+    /*@{*/
+    struct gl_shader *(*NewShader)(struct gl_context *ctx, GLuint name, GLenum type);
+    void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader);
++   void (*CompileShader)(struct gl_context *ctx, struct gl_shader *shader,
++			 GLboolean dump_ast, GLboolean dump_hir);
++
+    struct gl_shader_program *(*NewShaderProgram)(struct gl_context *ctx, GLuint name);
+    void (*DeleteShaderProgram)(struct gl_context *ctx,
+                                struct gl_shader_program *shProg);
++   void (*LinkShaderProgram)(struct gl_context *ctx,
++			     struct gl_shader_program *shProg);
+    void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg);
+    /*@}*/
+ 
+diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
+index 4cc0357..c2ce821 100644
+--- a/src/mesa/main/shaderapi.c
++++ b/src/mesa/main/shaderapi.c
+@@ -761,7 +761,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
+       /* this call will set the shader->CompileStatus field to indicate if
+        * compilation was successful.
+        */
+-      _mesa_glsl_compile_shader(ctx, sh, false, false);
++      ctx->Driver.CompileShader(ctx, sh, false, false);
+ 
+       if (ctx->Shader.Flags & GLSL_LOG) {
+          _mesa_write_shader_to_file(sh);
+@@ -816,7 +816,7 @@ link_program(struct gl_context *ctx, GLuint program)
+ 
+    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ 
+-   _mesa_glsl_link_shader(ctx, shProg);
++   ctx->Driver.LinkShaderProgram(ctx, shProg);
+ 
+    if (shProg->LinkStatus == GL_FALSE && 
+        (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) {
+diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
+index a62ad04..6d82614 100644
+--- a/src/mesa/main/shaderobj.c
++++ b/src/mesa/main/shaderobj.c
+@@ -41,6 +41,9 @@
+ #include "program/hash_table.h"
+ #include "ralloc.h"
+ 
++#include "program/ir_to_mesa.h"
++#include "../glsl/program.h"
++
+ /**********************************************************************/
+ /*** Shader object functions                                        ***/
+ /**********************************************************************/
+@@ -344,7 +347,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
+    shProg->TransformFeedback.VaryingNames = NULL;
+    shProg->TransformFeedback.NumVarying = 0;
+ 
+-
++   /* we should be dereferencing shaders instead of plainly deleting them */
+    for (sh = 0; sh < MESA_SHADER_TYPES; sh++) {
+       if (shProg->_LinkedShaders[sh] != NULL) {
+ 	 ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[sh]);
+@@ -422,7 +425,10 @@ _mesa_init_shader_object_functions(struct dd_function_table *driver)
+ {
+    driver->NewShader = _mesa_new_shader;
+    driver->DeleteShader = _mesa_delete_shader;
++   driver->CompileShader = _mesa_glsl_compile_shader;
+    driver->NewShaderProgram = _mesa_new_shader_program;
+    driver->DeleteShaderProgram = _mesa_delete_shader_program;
++   driver->LinkShaderProgram = _mesa_glsl_link_shader;
+    driver->LinkShader = _mesa_ir_link_shader;
+ }
++
+-- 
+1.7.7
+
diff --git a/debian/patches/libv-0002-build-libdricommon.patch b/debian/patches/libv-0002-build-libdricommon.patch
new file mode 100644
index 0000000..440d658
--- /dev/null
+++ b/debian/patches/libv-0002-build-libdricommon.patch
@@ -0,0 +1,40 @@
+From 3cf2d627461b2da140ed2b6d25693292ecd72a55 Mon Sep 17 00:00:00 2001
+From: Luc Verhaegen <libv@skynet.be>
+Date: Wed, 16 Oct 2013 18:51:38 +0200
+Subject: [PATCH 2/4] build libdricommon
+
+And include a version number to its name.
+
+Signed-off-by: Luc Verhaegen <libv@skynet.be>
+---
+ src/mesa/drivers/dri/common/Makefile.am |    7 +++++--
+ 1 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/mesa/drivers/dri/common/Makefile.am b/src/mesa/drivers/dri/common/Makefile.am
+index ce4119d..3437b03 100644
+--- a/src/mesa/drivers/dri/common/Makefile.am
++++ b/src/mesa/drivers/dri/common/Makefile.am
+@@ -27,8 +27,7 @@ AM_CFLAGS = \
+ 	-I$(top_srcdir)/src/mapi \
+ 	-I$(top_srcdir)/src/mesa/ \
+ 	$(DEFINES) \
+-	$(LIBDRM_CFLAGS) \
+-	$(VISIBILITY_CFLAGS)
++	$(LIBDRM_CFLAGS)
+ 
+ noinst_LTLIBRARIES = \
+ 	libdricommon.la \
+@@ -39,6 +38,10 @@ libdricommon_la_SOURCES = \
+ 	dri_util.c \
+ 	xmlconfig.c
+ 
++lib_LTLIBRARIES = libdricommon@VERSION@.la
++
++libdricommon@VERSION@_la_SOURCES = $(libdricommon_la_SOURCES)
++
+ libdri_test_stubs_la_SOURCES = \
+ 	dri_test.c
+ libdri_test_stubs_la_CFLAGS = $(AM_CFLAGS) -DNO_MAIN
+-- 
+1.7.7
+
diff --git a/debian/patches/libv-0003-add-dricore-and-dricommon-pkgconfig-files.patch b/debian/patches/libv-0003-add-dricore-and-dricommon-pkgconfig-files.patch
new file mode 100644
index 0000000..094f643
--- /dev/null
+++ b/debian/patches/libv-0003-add-dricore-and-dricommon-pkgconfig-files.patch
@@ -0,0 +1,100 @@
+From ddc2961a5eabdc5ef9ee097b9803760877278908 Mon Sep 17 00:00:00 2001
+From: Luc Verhaegen <libv@skynet.be>
+Date: Thu, 17 Oct 2013 20:09:00 +0200
+Subject: [PATCH 3/4] add dricore and dricommon pkgconfig files
+
+Signed-off-by: Luc Verhaegen <libv@skynet.be>
+---
+ configure.ac                                |    2 ++
+ src/mesa/drivers/dri/common/Makefile.am     |    3 +++
+ src/mesa/drivers/dri/common/dricommon.pc.in |   10 ++++++++++
+ src/mesa/libdricore/Makefile.am             |    3 +++
+ src/mesa/libdricore/dricore.pc.in           |   11 +++++++++++
+ 5 files changed, 29 insertions(+), 0 deletions(-)
+ create mode 100644 src/mesa/drivers/dri/common/dricommon.pc.in
+ create mode 100644 src/mesa/libdricore/dricore.pc.in
+
+diff --git a/configure.ac b/configure.ac
+index 1384224..16b41d8 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2123,6 +2123,7 @@ AC_CONFIG_FILES([Makefile
+ 		src/mesa/gl.pc
+ 		src/mesa/drivers/dri/dri.pc
+ 		src/mesa/drivers/dri/common/Makefile
++		src/mesa/drivers/dri/common/dricommon.pc
+ 		src/mesa/drivers/dri/common/xmlpool/Makefile
+ 		src/mesa/drivers/dri/i915/Makefile
+ 		src/mesa/drivers/dri/i965/Makefile
+@@ -2135,6 +2136,7 @@ AC_CONFIG_FILES([Makefile
+ 		src/mesa/drivers/osmesa/osmesa.pc
+ 		src/mesa/drivers/x11/Makefile
+ 		src/mesa/libdricore/Makefile
++		src/mesa/libdricore/dricore.pc
+ 		src/mesa/main/tests/Makefile
+ 		src/mesa/main/tests/hash_table/Makefile
+ 		src/mesa/program/Makefile
+diff --git a/src/mesa/drivers/dri/common/Makefile.am b/src/mesa/drivers/dri/common/Makefile.am
+index 3437b03..2f702c5 100644
+--- a/src/mesa/drivers/dri/common/Makefile.am
++++ b/src/mesa/drivers/dri/common/Makefile.am
+@@ -42,6 +42,9 @@ lib_LTLIBRARIES = libdricommon@VERSION@.la
+ 
+ libdricommon@VERSION@_la_SOURCES = $(libdricommon_la_SOURCES)
+ 
++pkgconfigdir = $(libdir)/pkgconfig
++pkgconfig_DATA = dricommon.pc
++
+ libdri_test_stubs_la_SOURCES = \
+ 	dri_test.c
+ libdri_test_stubs_la_CFLAGS = $(AM_CFLAGS) -DNO_MAIN
+diff --git a/src/mesa/drivers/dri/common/dricommon.pc.in b/src/mesa/drivers/dri/common/dricommon.pc.in
+new file mode 100644
+index 0000000..146a4b4
+--- /dev/null
++++ b/src/mesa/drivers/dri/common/dricommon.pc.in
+@@ -0,0 +1,10 @@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++includedir=@includedir@
++
++Name: dricommon
++Description: Direct Rendering Infrastructure helper library
++Version: @VERSION@
++Cflags: -I${includedir}/mesa/drivers/dri/common/
++Libs: -ldricommon@VERSION@
+diff --git a/src/mesa/libdricore/Makefile.am b/src/mesa/libdricore/Makefile.am
+index 56ceeb7..f9bebca 100644
+--- a/src/mesa/libdricore/Makefile.am
++++ b/src/mesa/libdricore/Makefile.am
+@@ -31,6 +31,9 @@ AM_CPPFLAGS = \
+ 	$(DEFINES) \
+ 	-DUSE_DRICORE
+ 
++pkgconfigdir = $(libdir)/pkgconfig
++pkgconfig_DATA = dricore.pc
++
+ libdricore@VERSION@_la_SOURCES = \
+ 	$(MESA_FILES) \
+ 	$(LIBGLCPP_GENERATED_FILES) \
+diff --git a/src/mesa/libdricore/dricore.pc.in b/src/mesa/libdricore/dricore.pc.in
+new file mode 100644
+index 0000000..15f57b2
+--- /dev/null
++++ b/src/mesa/libdricore/dricore.pc.in
+@@ -0,0 +1,11 @@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++includedir=@includedir@
++dridriverdir=@DRI_DRIVER_INSTALL_DIR@
++
++Name: dricore
++Description: Direct Rendering Infrastructure Core library
++Version: @VERSION@
++Cflags: -I${includedir}/mapi/ -I${includedir}/mesa/
++Libs: -L${libdir} -ldricore@VERSION@
+-- 
+1.7.7
+
diff --git a/debian/patches/libv-0004-install-mesa-sdk-headers-into-the-system.patch b/debian/patches/libv-0004-install-mesa-sdk-headers-into-the-system.patch
new file mode 100644
index 0000000..558ea00
--- /dev/null
+++ b/debian/patches/libv-0004-install-mesa-sdk-headers-into-the-system.patch
@@ -0,0 +1,180 @@
+From cf17cd80107f5b33e834a259c8bdadaf241fbc1b Mon Sep 17 00:00:00 2001
+From: Luc Verhaegen <libv@skynet.be>
+Date: Tue, 29 Oct 2013 15:01:12 +0100
+Subject: [PATCH 4/4] install mesa sdk headers into the system
+
+Signed-off-by: Luc Verhaegen <libv@skynet.be>
+---
+ src/glsl/Makefile.am                    |   14 +++++
+ src/mapi/glapi/Makefile.am              |   13 +++++
+ src/mesa/Makefile.am                    |   84 +++++++++++++++++++++++++++++++
+ src/mesa/drivers/dri/common/Makefile.am |    9 +++
+ 4 files changed, 120 insertions(+), 0 deletions(-)
+
+diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
+index 2bbad3d..5704077 100644
+--- a/src/glsl/Makefile.am
++++ b/src/glsl/Makefile.am
+@@ -33,6 +33,20 @@ AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
+ 
+ include Makefile.sources
+ 
++#
++# Mesa DRI SDK headers.
++#
++glslincludedir = $(includedir)/glsl
++glslinclude_HEADERS = \
++	builtin_type_macros.h \
++	glsl_types.h \
++	ir.h \
++	ir_hierarchical_visitor.h \
++	ir_uniform.h \
++	ir_visitor.h \
++	list.h \
++	ralloc.h
++
+ TESTS = glcpp/tests/glcpp-test				\
+ 	tests/optimization-test				\
+ 	tests/ralloc-test				\
+diff --git a/src/mapi/glapi/Makefile.am b/src/mapi/glapi/Makefile.am
+index 1698d14..9ef613a 100644
+--- a/src/mapi/glapi/Makefile.am
++++ b/src/mapi/glapi/Makefile.am
+@@ -55,6 +55,19 @@ glapi_ASM_sources = $(GLAPI_ASM_SOURCES)
+ glapi_MAPI_sources = $(MAPI_UTIL_FILES)
+ endif
+ 
++#
++# Mesa DRI SDK headers.
++#
++glapiincludedir = $(includedir)/mapi/glapi
++glapiinclude_HEADERS = \
++	glapi.h \
++	glthread.h
++
++mapiincludedir = $(includedir)/mapi
++mapiinclude_HEADERS = \
++	../u_compiler.h \
++	../u_thread.h
++
+ noinst_LTLIBRARIES = libglapi.la
+ 
+ libglapi_la_SOURCES = $(glapi_GLAPI_sources) $(glapi_ASM_sources) $(glapi_MAPI_sources)
+diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
+index d5f5f5b..ca0ca68 100644
+--- a/src/mesa/Makefile.am
++++ b/src/mesa/Makefile.am
+@@ -70,6 +70,90 @@ CLEANFILES = \
+ 	$(BUILT_SOURCES) \
+ 	git_sha1.h.tmp
+ 
++#
++# Mesa DRI SDK headers.
++#
++mesatopincludedir = $(includedir)/mesa
++mesatopinclude_HEADERS = \
++	$(top_srcdir)/include/c99_compat.h
++
++mainincludedir = $(includedir)/mesa/main
++maininclude_HEADERS = \
++	main/api_exec.h \
++	main/bufferobj.h \
++	main/compiler.h \
++	main/config.h \
++	main/context.h \
++	main/cpuinfo.h \
++	main/dd.h \
++	main/extensions.h \
++	main/errors.h \
++	main/fbobject.h \
++	main/formats.h \
++	main/framebuffer.h \
++	main/glheader.h \
++	main/imports.h \
++	main/macros.h \
++	main/mipmap.h \
++	main/mtypes.h \
++	main/renderbuffer.h \
++	main/teximage.h \
++	main/texformat.h \
++	main/texobj.h \
++	main/texstate.h \
++	main/samplerobj.h \
++	main/shaderobj.h \
++	main/simple_list.h \
++	main/uniforms.h \
++	main/version.h \
++	main/vtxfmt.h
++
++mathincludedir = $(includedir)/mesa/math
++mathinclude_HEADERS = \
++	math/m_matrix.h \
++	math/m_vector.h
++
++swrastincludedir = $(includedir)/mesa/swrast
++swrastinclude_HEADERS = \
++	swrast/swrast.h \
++	swrast/s_chan.h \
++	swrast/s_renderbuffer.h \
++	swrast/s_context.h \
++	swrast/s_fragprog.h \
++	swrast/s_span.h
++
++swrast_setupincludedir = $(includedir)/mesa/swrast_setup
++swrast_setupinclude_HEADERS = \
++	swrast_setup/swrast_setup.h
++
++tnlincludedir = $(includedir)/mesa/tnl
++tnlinclude_HEADERS = \
++	tnl/tnl.h \
++	tnl/t_context.h \
++	tnl/t_pipeline.h
++
++vboincludedir = $(includedir)/mesa/vbo
++vboinclude_HEADERS = \
++	vbo/vbo.h \
++	vbo/vbo_context.h \
++	vbo/vbo_attrib.h \
++	vbo/vbo_exec.h \
++	vbo/vbo_save.h
++
++programincludedir = $(includedir)/mesa/program
++programinclude_HEADERS = \
++	program/hash_table.h \
++	program/ir_to_mesa.h \
++	program/prog_execute.h \
++	program/prog_parameter.h \
++	program/prog_statevars.h \
++	program/program.h
++
++driverscommonincludedir = $(includedir)/mesa/drivers/common
++driverscommoninclude_HEADERS = \
++	drivers/common/driverfuncs.h \
++	drivers/common/meta.h
++
+ GET_HASH_GEN = main/get_hash_generator.py
+ 
+ main/get_hash.h: $(GLAPI)/gl_and_es_API.xml main/get_hash_params.py 	\
+diff --git a/src/mesa/drivers/dri/common/Makefile.am b/src/mesa/drivers/dri/common/Makefile.am
+index 2f702c5..540eee4 100644
+--- a/src/mesa/drivers/dri/common/Makefile.am
++++ b/src/mesa/drivers/dri/common/Makefile.am
+@@ -29,6 +29,15 @@ AM_CFLAGS = \
+ 	$(DEFINES) \
+ 	$(LIBDRM_CFLAGS)
+ 
++#
++# Mesa DRI SDK headers.
++#
++dricommonincludedir = $(includedir)/mesa/drivers/dri/common
++dricommoninclude_HEADERS = \
++	utils.h \
++	dri_util.h \
++	xmlconfig.h
++
+ noinst_LTLIBRARIES = \
+ 	libdricommon.la \
+ 	libdri_test_stubs.la
+-- 
+1.7.7
+
diff --git a/debian/patches/series b/debian/patches/series
index f20129c..60630ef 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,7 @@
 06_kfreebsd-ftbfs.diff
 08-kfreebsd-gallium.diff
 #11-hurd-ftbfs-again.diff
+libv-0001-provide-CompileShader-and-LinkShader-hooks.patch
+libv-0002-build-libdricommon.patch
+libv-0003-add-dricore-and-dricommon-pkgconfig-files.patch
+libv-0004-install-mesa-sdk-headers-into-the-system.patch
-- 
1.8.4.rc3

