aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-06-28 16:49:07 +0200
committermarha <marha@users.sourceforge.net>2013-06-28 16:49:07 +0200
commit3c204c4a20943586532ce477ced827d108f3b4b0 (patch)
treec9891fdc315c41cc90806634589231172572b2ba /mesalib/src
parent73a26452133415b7e3bf54836d23995d59a7bac4 (diff)
parentced1a6b8f5a750fcd3b8d3d0d9bbdee830064e6c (diff)
downloadvcxsrv-3c204c4a20943586532ce477ced827d108f3b4b0.tar.gz
vcxsrv-3c204c4a20943586532ce477ced827d108f3b4b0.tar.bz2
vcxsrv-3c204c4a20943586532ce477ced827d108f3b4b0.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig mesa git update 28 June 2013 libXext mesa git update 29 June 20013
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_context.c100
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_cpu.c12
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_fps.c14
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_private.h2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_stack.c56
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_stack.h7
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_symbol.c239
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h25
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_pack.py29
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_parse.py10
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_table.py4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_linkage.c4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_pack_color.h36
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_prim.h4
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_slab.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_staging.c4
-rw-r--r--mesalib/src/glsl/Makefile.sources1
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp18
-rw-r--r--mesalib/src/glsl/builtin_type_macros.h120
-rw-r--r--mesalib/src/glsl/builtin_types.cpp288
-rw-r--r--mesalib/src/glsl/builtin_types.h368
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp118
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h3
-rw-r--r--mesalib/src/glsl/glsl_types.cpp313
-rw-r--r--mesalib/src/glsl/glsl_types.h97
-rw-r--r--mesalib/src/glsl/ir.h12
-rw-r--r--mesalib/src/glsl/ir_hierarchical_visitor.h2
-rw-r--r--mesalib/src/glsl/ir_print_visitor.cpp3
-rw-r--r--mesalib/src/glsl/ir_print_visitor.h3
-rw-r--r--mesalib/src/glsl/ir_rvalue_visitor.cpp1
-rw-r--r--mesalib/src/glsl/ir_visitor.h2
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp2
-rw-r--r--mesalib/src/glsl/link_varyings.cpp15
-rw-r--r--mesalib/src/glsl/linker.cpp4
-rw-r--r--mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp2
-rw-r--r--mesalib/src/glsl/main.cpp60
-rw-r--r--mesalib/src/glsl/opt_array_splitting.cpp1
-rw-r--r--mesalib/src/glsl/opt_noop_swizzle.cpp1
-rw-r--r--mesalib/src/glsl/opt_structure_splitting.cpp1
-rw-r--r--mesalib/src/glsl/program.h16
-rw-r--r--mesalib/src/glsl/test_optpass.cpp1
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_debug_output.xml2
-rw-r--r--mesalib/src/mapi/glapi/gen/SConscript14
-rwxr-xr-xmesalib/src/mapi/glapi/gen/gl_API.xml2
-rw-r--r--mesalib/src/mapi/glapi/glapi_priv.h2
-rw-r--r--mesalib/src/mesa/drivers/common/driverfuncs.c1
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am2
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c1
-rw-r--r--mesalib/src/mesa/drivers/windows/gdi/wmesa.c1
-rw-r--r--mesalib/src/mesa/main/attrib.c2
-rw-r--r--mesalib/src/mesa/main/context.c45
-rw-r--r--mesalib/src/mesa/main/dd.h9
-rw-r--r--mesalib/src/mesa/main/errors.c4
-rw-r--r--mesalib/src/mesa/main/errors.h2
-rw-r--r--mesalib/src/mesa/main/extensions.c1
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp1
-rw-r--r--mesalib/src/mesa/main/framebuffer.c69
-rw-r--r--mesalib/src/mesa/main/hint.c11
-rw-r--r--mesalib/src/mesa/main/mtypes.h4
-rw-r--r--mesalib/src/mesa/main/shaderapi.c60
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp9
-rw-r--r--mesalib/src/mesa/main/uniforms.h2
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp107
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.h1
-rw-r--r--mesalib/src/mesa/program/register_allocate.c45
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_constbuf.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_readpixels.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c58
-rw-r--r--mesalib/src/mesa/state_tracker/st_gen_mipmap.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp12
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c2
76 files changed, 1186 insertions, 1305 deletions
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_context.c b/mesalib/src/gallium/auxiliary/hud/hud_context.c
index 981708314..47566d816 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_context.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_context.c
@@ -33,6 +33,8 @@
* Set GALLIUM_HUD=help for more info.
*/
+#include <stdio.h>
+
#include "hud/hud_context.h"
#include "hud/hud_private.h"
#include "hud/font.h"
@@ -106,8 +108,8 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
hud->constants.color[1] = g;
hud->constants.color[2] = b;
hud->constants.color[3] = a;
- hud->constants.translate[0] = xoffset;
- hud->constants.translate[1] = yoffset;
+ hud->constants.translate[0] = (float) xoffset;
+ hud->constants.translate[1] = (float) yoffset;
hud->constants.scale[0] = 1;
hud->constants.scale[1] = yscale;
cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
@@ -127,10 +129,10 @@ hud_draw_colored_quad(struct hud_context *hud, unsigned prim,
float r, float g, float b, float a)
{
float buffer[] = {
- x1, y1,
- x1, y2,
- x2, y2,
- x2, y1,
+ (float) x1, (float) y1,
+ (float) x1, (float) y2,
+ (float) x2, (float) y2,
+ (float) x2, (float) y1,
};
hud_draw_colored_prims(hud, prim, buffer, 4, r, g, b, a, 0, 0, 1);
@@ -145,17 +147,17 @@ hud_draw_background_quad(struct hud_context *hud,
assert(hud->bg.num_vertices + 4 <= hud->bg.max_num_vertices);
- vertices[num++] = x1;
- vertices[num++] = y1;
+ vertices[num++] = (float) x1;
+ vertices[num++] = (float) y1;
- vertices[num++] = x1;
- vertices[num++] = y2;
+ vertices[num++] = (float) x1;
+ vertices[num++] = (float) y2;
- vertices[num++] = x2;
- vertices[num++] = y2;
+ vertices[num++] = (float) x2;
+ vertices[num++] = (float) y2;
- vertices[num++] = x2;
- vertices[num++] = y1;
+ vertices[num++] = (float) x2;
+ vertices[num++] = (float) y1;
hud->bg.num_vertices += num/2;
}
@@ -200,25 +202,25 @@ hud_draw_string(struct hud_context *hud, unsigned x, unsigned y,
assert(hud->text.num_vertices + num/4 + 4 <= hud->text.max_num_vertices);
- vertices[num++] = x1;
- vertices[num++] = y1;
- vertices[num++] = tx1;
- vertices[num++] = ty1;
+ vertices[num++] = (float) x1;
+ vertices[num++] = (float) y1;
+ vertices[num++] = (float) tx1;
+ vertices[num++] = (float) ty1;
- vertices[num++] = x1;
- vertices[num++] = y2;
- vertices[num++] = tx1;
- vertices[num++] = ty2;
+ vertices[num++] = (float) x1;
+ vertices[num++] = (float) y2;
+ vertices[num++] = (float) tx1;
+ vertices[num++] = (float) ty2;
- vertices[num++] = x2;
- vertices[num++] = y2;
- vertices[num++] = tx2;
- vertices[num++] = ty2;
+ vertices[num++] = (float) x2;
+ vertices[num++] = (float) y2;
+ vertices[num++] = (float) tx2;
+ vertices[num++] = (float) ty2;
- vertices[num++] = x2;
- vertices[num++] = y1;
- vertices[num++] = tx2;
- vertices[num++] = ty1;
+ vertices[num++] = (float) x2;
+ vertices[num++] = (float) y1;
+ vertices[num++] = (float) tx2;
+ vertices[num++] = (float) ty1;
x += hud->font.glyph_width;
s++;
@@ -316,25 +318,25 @@ hud_pane_accumulate_vertices(struct hud_context *hud,
/* draw border */
assert(hud->whitelines.num_vertices + num/2 + 8 <= hud->whitelines.max_num_vertices);
- line_verts[num++] = pane->x1;
- line_verts[num++] = pane->y1;
- line_verts[num++] = pane->x2;
- line_verts[num++] = pane->y1;
-
- line_verts[num++] = pane->x2;
- line_verts[num++] = pane->y1;
- line_verts[num++] = pane->x2;
- line_verts[num++] = pane->y2;
-
- line_verts[num++] = pane->x1;
- line_verts[num++] = pane->y2;
- line_verts[num++] = pane->x2;
- line_verts[num++] = pane->y2;
-
- line_verts[num++] = pane->x1;
- line_verts[num++] = pane->y1;
- line_verts[num++] = pane->x1;
- line_verts[num++] = pane->y2;
+ line_verts[num++] = (float) pane->x1;
+ line_verts[num++] = (float) pane->y1;
+ line_verts[num++] = (float) pane->x2;
+ line_verts[num++] = (float) pane->y1;
+
+ line_verts[num++] = (float) pane->x2;
+ line_verts[num++] = (float) pane->y1;
+ line_verts[num++] = (float) pane->x2;
+ line_verts[num++] = (float) pane->y2;
+
+ line_verts[num++] = (float) pane->x1;
+ line_verts[num++] = (float) pane->y2;
+ line_verts[num++] = (float) pane->x2;
+ line_verts[num++] = (float) pane->y2;
+
+ line_verts[num++] = (float) pane->x1;
+ line_verts[num++] = (float) pane->y1;
+ line_verts[num++] = (float) pane->x1;
+ line_verts[num++] = (float) pane->y2;
/* draw horizontal lines inside the graph */
for (i = 0; i <= 5; i++) {
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_cpu.c b/mesalib/src/gallium/auxiliary/hud/hud_cpu.c
index ce98115d5..cd20deec9 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_cpu.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_cpu.c
@@ -116,6 +116,12 @@ query_cpu_load(struct hud_graph *gr)
}
}
+static void
+free_query_data(void *p)
+{
+ FREE(p);
+}
+
void
hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index)
{
@@ -144,7 +150,11 @@ hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index)
}
gr->query_new_value = query_cpu_load;
- gr->free_query_data = free;
+
+ /* Don't use free() as our callback as that messes up Gallium's
+ * memory debugger. Use simple free_query_data() wrapper.
+ */
+ gr->free_query_data = free_query_data;
info = gr->query_data;
info->cpu_index = cpu_index;
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_fps.c b/mesalib/src/gallium/auxiliary/hud/hud_fps.c
index 80381f547..a360bc2ed 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_fps.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_fps.c
@@ -52,7 +52,7 @@ query_fps(struct hud_graph *gr)
info->frames = 0;
info->last_time = now;
- hud_graph_add_value(gr, fps);
+ hud_graph_add_value(gr, (uint64_t) fps);
}
}
else {
@@ -60,6 +60,12 @@ query_fps(struct hud_graph *gr)
}
}
+static void
+free_query_data(void *p)
+{
+ FREE(p);
+}
+
void
hud_fps_graph_install(struct hud_pane *pane)
{
@@ -76,7 +82,11 @@ hud_fps_graph_install(struct hud_pane *pane)
}
gr->query_new_value = query_fps;
- gr->free_query_data = free;
+
+ /* Don't use free() as our callback as that messes up Gallium's
+ * memory debugger. Use simple free_query_data() wrapper.
+ */
+ gr->free_query_data = free_query_data;
hud_pane_add_graph(pane, gr);
}
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_private.h b/mesalib/src/gallium/auxiliary/hud/hud_private.h
index 2b7d56bb1..1606ada4a 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_private.h
+++ b/mesalib/src/gallium/auxiliary/hud/hud_private.h
@@ -42,7 +42,7 @@ struct hud_graph {
char name[128];
void *query_data;
void (*query_new_value)(struct hud_graph *gr);
- void (*free_query_data)(void *ptr);
+ void (*free_query_data)(void *ptr); /**< do not use ordinary free() */
/* mutable variables */
unsigned num_vertices;
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_stack.c b/mesalib/src/gallium/auxiliary/util/u_debug_stack.c
index 50a248a97..68961d351 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_stack.c
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_stack.c
@@ -36,7 +36,17 @@
#include "u_debug_symbol.h"
#include "u_debug_stack.h"
+#if defined(PIPE_OS_WINDOWS)
+#include <windows.h>
+#endif
+
+/**
+ * Capture stack backtrace.
+ *
+ * NOTE: The implementation of this function is quite big, but it is important not to
+ * break it down in smaller functions to avoid adding new frames to the calling stack.
+ */
void
debug_backtrace_capture(struct debug_stack_frame *backtrace,
unsigned start_frame,
@@ -45,8 +55,50 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace,
const void **frame_pointer = NULL;
unsigned i = 0;
- if(!nr_frames)
+ if (!nr_frames) {
return;
+ }
+
+ /*
+ * On Windows try obtaining the stack backtrace via CaptureStackBackTrace.
+ *
+ * It works reliably both for x86 for x86_64.
+ */
+#if defined(PIPE_OS_WINDOWS)
+ {
+ typedef USHORT (WINAPI *PFNCAPTURESTACKBACKTRACE)(ULONG, ULONG, PVOID *, PULONG);
+ static PFNCAPTURESTACKBACKTRACE pfnCaptureStackBackTrace = NULL;
+
+ if (!pfnCaptureStackBackTrace) {
+ static HMODULE hModule = NULL;
+ if (!hModule) {
+ hModule = LoadLibraryA("kernel32");
+ assert(hModule);
+ }
+ if (hModule) {
+ pfnCaptureStackBackTrace = (PFNCAPTURESTACKBACKTRACE)GetProcAddress(hModule,
+ "RtlCaptureStackBackTrace");
+ }
+ }
+ if (pfnCaptureStackBackTrace) {
+ /*
+ * Skip this (debug_backtrace_capture) function's frame.
+ */
+
+ start_frame += 1;
+
+ assert(start_frame + nr_frames < 63);
+ i = pfnCaptureStackBackTrace(start_frame, nr_frames, (PVOID *) &backtrace->function, NULL);
+
+ /* Pad remaing requested frames with NULL */
+ while (i < nr_frames) {
+ backtrace[i++].function = NULL;
+ }
+
+ return;
+ }
+ }
+#endif
#if defined(PIPE_CC_GCC)
frame_pointer = ((const void **)__builtin_frame_address(1));
@@ -86,7 +138,7 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace,
#else
(void) frame_pointer;
#endif
-
+
while(nr_frames) {
backtrace[i++].function = NULL;
--nr_frames;
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_stack.h b/mesalib/src/gallium/auxiliary/util/u_debug_stack.h
index f50f04e0f..b1848ddef 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_stack.h
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_stack.h
@@ -42,6 +42,13 @@ extern "C" {
#endif
+/**
+ * Represent a frame from a stack backtrace.
+ *
+ * XXX: Do not change this.
+ *
+ * TODO: This should be refactored as a void * typedef.
+ */
struct debug_stack_frame
{
const void *function;
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
index 0ef111c3b..bba9122e7 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -40,7 +40,8 @@
#include "u_debug_symbol.h"
#include "u_hash_table.h"
-#if defined(PIPE_OS_WINDOWS) && defined(PIPE_ARCH_X86)
+
+#if defined(PIPE_OS_WINDOWS)
#include <windows.h>
#include <stddef.h>
@@ -48,139 +49,221 @@
#include "dbghelp.h"
-static BOOL bSymInitialized = FALSE;
-
-static HMODULE hModule_Dbghelp = NULL;
+/**
+ * SymInitialize() must be called once for each process (in this case, the
+ * current process), before any of the other functions can be called.
+ */
+static BOOL g_bSymInitialized = FALSE;
-static
-FARPROC WINAPI __GetProcAddress(LPCSTR lpProcName)
+/**
+ * Lookup the address of a DbgHelp function.
+ */
+static FARPROC WINAPI
+getDbgHelpProcAddress(LPCSTR lpProcName)
{
+ static HMODULE hModule = NULL;
+
+ if (!hModule) {
+ static boolean bail = FALSE;
+
+ if (bail) {
+ return NULL;
+ }
+
#ifdef PIPE_CC_GCC
- if (!hModule_Dbghelp) {
/*
- * bfdhelp.dll is a dbghelp.dll look-alike replacement, which is able to
- * understand MinGW symbols using BFD library. It is available from
+ * DbgHelp does not understand the debug information generated by MinGW toolchain.
+ *
+ * mgwhelp.dll is a dbghelp.dll look-alike replacement, which is able to
+ * understand MinGW symbols, including on 64-bit builds.
+ */
+ if (!hModule) {
+ hModule = LoadLibraryA("mgwhelp.dll");
+ if (!hModule) {
+ _debug_printf("warning: mgwhelp.dll not found: symbol names will not be resolved\n"
+ "warning: download it from http://code.google.com/p/jrfonseca/wiki/DrMingw#MgwHelp\n");
+ }
+ }
+
+ /*
+ * bfdhelp.dll was the predecessor of mgwhelp.dll. It is available from
* http://people.freedesktop.org/~jrfonseca/bfdhelp/ for now.
*/
- hModule_Dbghelp = LoadLibraryA("bfdhelp.dll");
- }
-#endif
+ if (!hModule) {
+ hModule = LoadLibraryA("bfdhelp.dll");
+ }
+ #endif
- if (!hModule_Dbghelp) {
- hModule_Dbghelp = LoadLibraryA("dbghelp.dll");
- if (!hModule_Dbghelp) {
+ /*
+ * Fallback to the real DbgHelp.
+ */
+ if (!hModule) {
+ hModule = LoadLibraryA("dbghelp.dll");
+ }
+
+ if (!hModule) {
+ bail = TRUE;
return NULL;
}
}
- return GetProcAddress(hModule_Dbghelp, lpProcName);
+ return GetProcAddress(hModule, lpProcName);
}
-typedef BOOL (WINAPI *PFNSYMINITIALIZE)(HANDLE, LPSTR, BOOL);
-static PFNSYMINITIALIZE pfnSymInitialize = NULL;
+/**
+ * Generic macro to dispatch a DbgHelp functions.
+ */
+#define DBGHELP_DISPATCH(_name, _ret_type, _ret_default, _arg_types, _arg_names) \
+ static _ret_type WINAPI \
+ j_##_name _arg_types \
+ { \
+ typedef BOOL (WINAPI *PFN) _arg_types; \
+ static PFN pfn = NULL; \
+ if (!pfn) { \
+ pfn = (PFN) getDbgHelpProcAddress(#_name); \
+ if (!pfn) { \
+ return _ret_default; \
+ } \
+ } \
+ return pfn _arg_names; \
+ }
-static
-BOOL WINAPI j_SymInitialize(HANDLE hProcess, PSTR UserSearchPath, BOOL fInvadeProcess)
-{
- if(
- (pfnSymInitialize || (pfnSymInitialize = (PFNSYMINITIALIZE) __GetProcAddress("SymInitialize")))
- )
- return pfnSymInitialize(hProcess, UserSearchPath, fInvadeProcess);
- else
- return FALSE;
-}
+DBGHELP_DISPATCH(SymInitialize,
+ BOOL, 0,
+ (HANDLE hProcess, PSTR UserSearchPath, BOOL fInvadeProcess),
+ (hProcess, UserSearchPath, fInvadeProcess))
-typedef DWORD (WINAPI *PFNSYMSETOPTIONS)(DWORD);
-static PFNSYMSETOPTIONS pfnSymSetOptions = NULL;
+DBGHELP_DISPATCH(SymSetOptions,
+ DWORD, FALSE,
+ (DWORD SymOptions),
+ (SymOptions))
-static
-DWORD WINAPI j_SymSetOptions(DWORD SymOptions)
-{
- if(
- (pfnSymSetOptions || (pfnSymSetOptions = (PFNSYMSETOPTIONS) __GetProcAddress("SymSetOptions")))
- )
- return pfnSymSetOptions(SymOptions);
- else
- return FALSE;
-}
+DBGHELP_DISPATCH(SymFromAddr,
+ BOOL, FALSE,
+ (HANDLE hProcess, DWORD64 Address, PDWORD64 Displacement, PSYMBOL_INFO Symbol),
+ (hProcess, Address, Displacement, Symbol))
-typedef BOOL (WINAPI *PFNSYMGETSYMFROMADDR)(HANDLE, DWORD64, PDWORD64, PSYMBOL_INFO);
-static PFNSYMGETSYMFROMADDR pfnSymFromAddr = NULL;
+DBGHELP_DISPATCH(SymGetLineFromAddr64,
+ BOOL, FALSE,
+ (HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line),
+ (hProcess, dwAddr, pdwDisplacement, Line))
-static
-BOOL WINAPI j_SymFromAddr(HANDLE hProcess, DWORD64 Address, PDWORD64 Displacement, PSYMBOL_INFO Symbol)
-{
- if(
- (pfnSymFromAddr || (pfnSymFromAddr = (PFNSYMGETSYMFROMADDR) __GetProcAddress("SymFromAddr")))
- )
- return pfnSymFromAddr(hProcess, Address, Displacement, Symbol);
- else
- return FALSE;
-}
+
+#undef DBGHELP_DISPATCH
-static INLINE void
+static INLINE boolean
debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size)
{
- HANDLE hProcess;
- BYTE symbolBuffer[1024];
- PSYMBOL_INFO pSymbol = (PSYMBOL_INFO) symbolBuffer;
- DWORD64 dwDisplacement = 0; /* Displacement of the input address, relative to the start of the symbol */
+ DWORD64 dwAddr = (DWORD64)(uintptr_t)addr;
+ HANDLE hProcess = GetCurrentProcess();
- hProcess = GetCurrentProcess();
+ /* General purpose buffer, to back pSymbol and other temporary stuff.
+ * Must not be too memory hungry here to avoid stack overflows.
+ */
+ CHAR buffer[512];
+
+ PSYMBOL_INFO pSymbol = (PSYMBOL_INFO) buffer;
+ DWORD64 dwDisplacement = 0; /* Displacement of the input address, relative to the start of the symbol */
+ DWORD dwLineDisplacement = 0;
+ IMAGEHLP_LINE64 Line;
memset(pSymbol, 0, sizeof *pSymbol);
- pSymbol->SizeOfStruct = sizeof(symbolBuffer);
- pSymbol->MaxNameLen = sizeof(symbolBuffer) - offsetof(SYMBOL_INFO, Name);
+ pSymbol->SizeOfStruct = sizeof buffer;
+ pSymbol->MaxNameLen = sizeof buffer - offsetof(SYMBOL_INFO, Name);
- if(!bSymInitialized) {
+ if (!g_bSymInitialized) {
j_SymSetOptions(/* SYMOPT_UNDNAME | */ SYMOPT_LOAD_LINES);
- if(j_SymInitialize(hProcess, NULL, TRUE))
- bSymInitialized = TRUE;
+ if (j_SymInitialize(hProcess, NULL, TRUE)) {
+ g_bSymInitialized = TRUE;
+ }
}
- if(!j_SymFromAddr(hProcess, (DWORD64)(uintptr_t)addr, &dwDisplacement, pSymbol))
- buf[0] = 0;
- else
- {
- strncpy(buf, pSymbol->Name, size);
- buf[size - 1] = 0;
+ /* Lookup symbol name */
+ if (!g_bSymInitialized ||
+ !j_SymFromAddr(hProcess, dwAddr, &dwDisplacement, pSymbol)) {
+ /*
+ * We couldn't obtain symbol information. At least tell which module the address belongs.
+ */
+
+ HMODULE hModule = NULL;
+
+ if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (LPCTSTR)addr,
+ &hModule)) {
+ return FALSE;
+ }
+
+ if (GetModuleFileNameA(hModule, buffer, sizeof buffer) == sizeof buffer) {
+ return FALSE;
+ }
+ util_snprintf(buf, size, "%p at %s+0x%lx",
+ addr, buffer,
+ (unsigned long)((uintptr_t)addr - (uintptr_t)hModule));
+
+ return TRUE;
}
+
+ /*
+ * Try to get filename and line number.
+ */
+ memset(&Line, 0, sizeof Line);
+ Line.SizeOfStruct = sizeof Line;
+ if (!j_SymGetLineFromAddr64(hProcess, dwAddr, &dwLineDisplacement, &Line)) {
+ Line.FileName = NULL;
+ }
+
+ if (Line.FileName) {
+ util_snprintf(buf, size, "%s at %s:%lu", pSymbol->Name, Line.FileName, Line.LineNumber);
+ } else {
+ util_snprintf(buf, size, "%s", pSymbol->Name);
+ }
+
+ return TRUE;
}
-#endif
+
+#endif /* PIPE_OS_WINDOWS */
+
#if defined(__GLIBC__) && !defined(__UCLIBC__)
+
#include <execinfo.h>
/* This can only provide dynamic symbols, or binary offsets into a file.
*
* To fix this, post-process the output with tools/addr2line.sh
*/
-static INLINE void
+static INLINE boolean
debug_symbol_name_glibc(const void *addr, char* buf, unsigned size)
{
char** syms = backtrace_symbols((void**)&addr, 1);
+ if (!syms) {
+ return FALSE;
+ }
strncpy(buf, syms[0], size);
buf[size - 1] = 0;
free(syms);
+ return TRUE;
}
-#endif
+
+#endif /* defined(__GLIBC__) && !defined(__UCLIBC__) */
+
void
debug_symbol_name(const void *addr, char* buf, unsigned size)
{
-#if defined(PIPE_OS_WINDOWS) && defined(PIPE_ARCH_X86)
- debug_symbol_name_dbghelp(addr, buf, size);
- if(buf[0])
+#if defined(PIPE_OS_WINDOWS)
+ if (debug_symbol_name_dbghelp(addr, buf, size)) {
return;
+ }
#endif
#if defined(__GLIBC__) && !defined(__UCLIBC__)
- debug_symbol_name_glibc(addr, buf, size);
- if(buf[0])
- return;
+ if (debug_symbol_name_glibc(addr, buf, size)) {
+ return;
+ }
#endif
util_snprintf(buf, size, "%p", addr);
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 4cace6ad1..9774a2b4c 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -133,6 +133,7 @@ struct util_format_channel_description
unsigned normalized:1;
unsigned pure_integer:1;
unsigned size:9; /**< bits per channel */
+ unsigned shift:16; /** number of bits from lsb */
};
@@ -179,9 +180,31 @@ struct util_format_description
unsigned is_mixed:1;
/**
- * Input channel description.
+ * Input channel description, in the order XYZW.
*
* Only valid for UTIL_FORMAT_LAYOUT_PLAIN formats.
+ *
+ * If each channel is accessed as an individual N-byte value, X is always
+ * at the lowest address in memory, Y is always next, and so on. For all
+ * currently-defined formats, the N-byte value has native endianness.
+ *
+ * If instead a group of channels is accessed as a single N-byte value,
+ * the order of the channels within that value depends on endianness.
+ * For big-endian targets, X is the most significant subvalue,
+ * otherwise it is the least significant one.
+ *
+ * For example, if X is 8 bits and Y is 24 bits, the memory order is:
+ *
+ * 0 1 2 3
+ * little-endian: X Yl Ym Yu (l = lower, m = middle, u = upper)
+ * big-endian: X Yu Ym Yl
+ *
+ * If X is 5 bits, Y is 5 bits, Z is 5 bits and W is 1 bit, the layout is:
+ *
+ * 0 1
+ * msb lsb msb lsb
+ * little-endian: YYYXXXXX WZZZZZYY
+ * big-endian: XXXXXYYY YYZZZZZW
*/
struct util_format_channel_description channel[4];
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
index 565d059c3..d1f68c804 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py
@@ -99,15 +99,6 @@ def generate_format_type(format):
print
-def bswap_format(format):
- '''Generate a structure that describes the format.'''
-
- if format.is_bitmask() and not format.is_array() and format.block_size() > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' pixel.value = util_bswap%u(pixel.value);' % format.block_size()
- print '#endif'
-
-
def is_format_supported(format):
'''Determines whether we actually have the plumbing necessary to generate the
to read/write to/from this format.'''
@@ -423,16 +414,11 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
elif src_channel.type == SIGNED:
print ' int%u_t %s;' % (depth, src_channel.name)
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
# Compute the intermediate unshifted values
- shift = 0
for i in range(format.nr_channels()):
src_channel = format.channels[i]
value = 'value'
+ shift = src_channel.shift
if src_channel.type == UNSIGNED:
if shift:
value = '%s >> %u' % (value, shift)
@@ -455,8 +441,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
if value is not None:
print ' %s = %s;' % (src_channel.name, value)
- shift += src_channel.size
-
# Convert, swizzle, and store final values
for i in range(4):
swizzle = format.swizzles[i]
@@ -484,7 +468,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
else:
print ' union util_format_%s pixel;' % format.short_name()
print ' memcpy(&pixel, src, sizeof pixel);'
- bswap_format(format)
for i in range(4):
swizzle = format.swizzles[i]
@@ -525,9 +508,9 @@ def generate_pack_kernel(format, src_channel, src_native_type):
depth = format.block_size()
print ' uint%u_t value = 0;' % depth
- shift = 0
for i in range(4):
dst_channel = format.channels[i]
+ shift = dst_channel.shift
if inv_swizzle[i] is not None:
value ='src[%u]' % inv_swizzle[i]
dst_colorspace = format.colorspace
@@ -551,13 +534,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
if value is not None:
print ' value |= %s;' % (value)
- shift += dst_channel.size
-
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
print ' *(uint%u_t *)dst = value;' % depth
else:
@@ -579,7 +555,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
dst_colorspace = dst_colorspace)
print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
- bswap_format(format)
print ' memcpy(dst, &pixel, sizeof pixel);'
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_parse.py b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
index 07052b996..e202099b9 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_parse.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_parse.py
@@ -30,6 +30,8 @@
'''
+import sys
+
VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7)
@@ -42,6 +44,9 @@ YUV = 'yuv'
ZS = 'zs'
+# Not cross-compiler friendly
+is_big_endian = sys.byteorder == 'big'
+
def is_pot(x):
return (x & (x - 1)) == 0
@@ -307,6 +312,11 @@ def parse(filename):
channel = Channel(type, norm, pure, size, names[i])
channels.append(channel)
+ shift = 0
+ for channel in channels[3::-1] if is_big_endian else channels:
+ channel.shift = shift
+ shift += channel.size
+
format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace)
formats.append(format)
return formats
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_table.py b/mesalib/src/gallium/auxiliary/util/u_format_table.py
index 8edb50523..9d44cf391 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_table.py
+++ b/mesalib/src/gallium/auxiliary/util/u_format_table.py
@@ -114,9 +114,9 @@ def write_format_table(formats):
else:
sep = ""
if channel.size:
- print " {%s, %s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, sep, "xyzw"[i], channel.name)
+ print " {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name)
else:
- print " {0, 0, 0, 0}%s" % (sep,)
+ print " {0, 0, 0, 0, 0}%s" % (sep,)
print " },"
print " {"
for i in range(4):
diff --git a/mesalib/src/gallium/auxiliary/util/u_linkage.c b/mesalib/src/gallium/auxiliary/util/u_linkage.c
index 2f6f41ba8..245d941dc 100644
--- a/mesalib/src/gallium/auxiliary/util/u_linkage.c
+++ b/mesalib/src/gallium/auxiliary/util/u_linkage.c
@@ -130,12 +130,12 @@ util_semantic_layout_from_set(unsigned char *layout, const struct util_semantic_
last = i;
}
- if(last < efficient_slots)
+ if (last < (int) efficient_slots)
{
UTIL_SEMANTIC_SET_FOR_EACH(i, set)
layout[i] = i;
}
- else if((last - first) < efficient_slots)
+ else if ((last - first) < (int) efficient_slots)
{
UTIL_SEMANTIC_SET_FOR_EACH(i, set)
layout[i - first] = i;
diff --git a/mesalib/src/gallium/auxiliary/util/u_pack_color.h b/mesalib/src/gallium/auxiliary/util/u_pack_color.h
index 1f6a56a33..102ad6051 100644
--- a/mesalib/src/gallium/auxiliary/util/u_pack_color.h
+++ b/mesalib/src/gallium/auxiliary/util/u_pack_color.h
@@ -65,32 +65,32 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
enum pipe_format format, union util_color *uc)
{
switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_ABGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
- case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_XBGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
}
return;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_BGRA8888_UNORM:
{
uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_BGRX8888_UNORM:
{
uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_ARGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_XRGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
}
@@ -166,7 +166,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
ubyte *r, ubyte *g, ubyte *b, ubyte *a)
{
switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_ABGR8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 24) & 0xff);
@@ -175,7 +175,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) ((p >> 0) & 0xff);
}
return;
- case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_XBGR8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 24) & 0xff);
@@ -184,7 +184,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) 0xff;
}
return;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_BGRA8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 16) & 0xff);
@@ -193,7 +193,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) ((p >> 24) & 0xff);
}
return;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_BGRX8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 16) & 0xff);
@@ -202,7 +202,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) 0xff;
}
return;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_ARGB8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 8) & 0xff);
@@ -211,7 +211,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) ((p >> 0) & 0xff);
}
return;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_XRGB8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 8) & 0xff);
@@ -350,32 +350,32 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color *
}
switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_ABGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
- case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_XBGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
}
return;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_BGRA8888_UNORM:
{
uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_BGRX8888_UNORM:
{
uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_ARGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_XRGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_prim.h b/mesalib/src/gallium/auxiliary/util/u_prim.h
index 8f444a305..8a9cca20a 100644
--- a/mesalib/src/gallium/auxiliary/util/u_prim.h
+++ b/mesalib/src/gallium/auxiliary/util/u_prim.h
@@ -38,8 +38,8 @@ extern "C" {
#endif
struct u_prim_vertex_count {
- int min;
- int incr;
+ unsigned min;
+ unsigned incr;
};
/**
diff --git a/mesalib/src/gallium/auxiliary/util/u_slab.c b/mesalib/src/gallium/auxiliary/util/u_slab.c
index f9f5ef68f..dbdebc6c9 100644
--- a/mesalib/src/gallium/auxiliary/util/u_slab.c
+++ b/mesalib/src/gallium/auxiliary/util/u_slab.c
@@ -55,7 +55,7 @@ static void util_slab_add_new_page(struct util_slab_mempool *pool)
{
struct util_slab_page *page;
struct util_slab_block *block;
- int i;
+ unsigned i;
page = MALLOC(pool->page_size);
insert_at_tail(&pool->list, page);
diff --git a/mesalib/src/gallium/auxiliary/util/u_staging.c b/mesalib/src/gallium/auxiliary/util/u_staging.c
index b5e37932e..b569c8f99 100644
--- a/mesalib/src/gallium/auxiliary/util/u_staging.c
+++ b/mesalib/src/gallium/auxiliary/util/u_staging.c
@@ -84,7 +84,7 @@ util_staging_transfer_init(struct pipe_context *pipe,
if (usage & PIPE_TRANSFER_READ)
{
/* XXX this looks wrong dst is always the same but looping over src z? */
- unsigned zi;
+ int zi;
struct pipe_box sbox;
sbox.x = box->x;
sbox.y = box->y;
@@ -111,7 +111,7 @@ util_staging_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer *p
{
if(tx->base.usage & PIPE_TRANSFER_WRITE) {
/* XXX this looks wrong src is always the same but looping over dst z? */
- unsigned zi;
+ int zi;
struct pipe_box sbox;
sbox.x = 0;
sbox.y = 0;
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index 50bad85ad..acd19d1ff 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -21,6 +21,7 @@ LIBGLSL_FILES = \
$(GLSL_SRCDIR)/ast_function.cpp \
$(GLSL_SRCDIR)/ast_to_hir.cpp \
$(GLSL_SRCDIR)/ast_type.cpp \
+ $(GLSL_SRCDIR)/builtin_types.cpp \
$(GLSL_SRCDIR)/builtin_variables.cpp \
$(GLSL_SRCDIR)/glsl_parser_extras.cpp \
$(GLSL_SRCDIR)/glsl_types.cpp \
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 4b5f04980..efbd72c18 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -94,6 +94,24 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
detect_conflicting_assignments(state, instructions);
state->toplevel_ir = NULL;
+
+ /* Move all of the variable declarations to the front of the IR list, and
+ * reverse the order. This has the (intended!) side effect that vertex
+ * shader inputs and fragment shader outputs will appear in the IR in the
+ * same order that they appeared in the shader code. This results in the
+ * locations being assigned in the declared order. Many (arguably buggy)
+ * applications depend on this behavior, and it matches what nearly all
+ * other drivers do.
+ */
+ foreach_list_safe(node, instructions) {
+ ir_variable *const var = ((ir_instruction *) node)->as_variable();
+
+ if (var == NULL)
+ continue;
+
+ var->remove();
+ instructions->push_head(var);
+ }
}
diff --git a/mesalib/src/glsl/builtin_type_macros.h b/mesalib/src/glsl/builtin_type_macros.h
new file mode 100644
index 000000000..fec38da12
--- /dev/null
+++ b/mesalib/src/glsl/builtin_type_macros.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright © 2013 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 builtin_type_macros.h
+ *
+ * This contains definitions for all GLSL built-in types, regardless of what
+ * language version or extension might provide them.
+ */
+
+#include "glsl_types.h"
+
+DECL_TYPE(error, GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0)
+DECL_TYPE(void, GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0)
+
+DECL_TYPE(bool, GL_BOOL, GLSL_TYPE_BOOL, 1, 1)
+DECL_TYPE(bvec2, GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1)
+DECL_TYPE(bvec3, GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1)
+DECL_TYPE(bvec4, GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1)
+
+DECL_TYPE(int, GL_INT, GLSL_TYPE_INT, 1, 1)
+DECL_TYPE(ivec2, GL_INT_VEC2, GLSL_TYPE_INT, 2, 1)
+DECL_TYPE(ivec3, GL_INT_VEC3, GLSL_TYPE_INT, 3, 1)
+DECL_TYPE(ivec4, GL_INT_VEC4, GLSL_TYPE_INT, 4, 1)
+
+DECL_TYPE(uint, GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1)
+DECL_TYPE(uvec2, GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1)
+DECL_TYPE(uvec3, GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1)
+DECL_TYPE(uvec4, GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1)
+
+DECL_TYPE(float, GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1)
+DECL_TYPE(vec2, GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1)
+DECL_TYPE(vec3, GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1)
+DECL_TYPE(vec4, GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1)
+
+DECL_TYPE(mat2, GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2)
+DECL_TYPE(mat3, GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3)
+DECL_TYPE(mat4, GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4)
+
+DECL_TYPE(mat2x3, GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2)
+DECL_TYPE(mat2x4, GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2)
+DECL_TYPE(mat3x2, GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3)
+DECL_TYPE(mat3x4, GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3)
+DECL_TYPE(mat4x2, GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4)
+DECL_TYPE(mat4x3, GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4)
+
+DECL_TYPE(sampler1D, GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2D, GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler3D, GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(samplerCube, GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler1DArray, GL_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2DArray, GL_SAMPLER_2D_ARRAY, GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT)
+DECL_TYPE(samplerCubeArray, GL_SAMPLER_CUBE_MAP_ARRAY, GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2DRect, GL_SAMPLER_2D_RECT, GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(samplerBuffer, GL_SAMPLER_BUFFER, GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2DMS, GL_SAMPLER_2D_MULTISAMPLE, GLSL_SAMPLER_DIM_MS, 0, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2DMSArray, GL_SAMPLER_2D_MULTISAMPLE_ARRAY, GLSL_SAMPLER_DIM_MS, 0, 1, GLSL_TYPE_FLOAT)
+
+DECL_TYPE(isampler1D, GL_INT_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT)
+DECL_TYPE(isampler2D, GL_INT_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT)
+DECL_TYPE(isampler3D, GL_INT_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT)
+DECL_TYPE(isamplerCube, GL_INT_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT)
+DECL_TYPE(isampler1DArray, GL_INT_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT)
+DECL_TYPE(isampler2DArray, GL_INT_SAMPLER_2D_ARRAY, GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT)
+DECL_TYPE(isamplerCubeArray, GL_INT_SAMPLER_CUBE_MAP_ARRAY, GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_INT)
+DECL_TYPE(isampler2DRect, GL_INT_SAMPLER_2D_RECT, GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_INT)
+DECL_TYPE(isamplerBuffer, GL_INT_SAMPLER_BUFFER, GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT)
+DECL_TYPE(isampler2DMS, GL_INT_SAMPLER_2D_MULTISAMPLE, GLSL_SAMPLER_DIM_MS, 0, 0, GLSL_TYPE_INT)
+DECL_TYPE(isampler2DMSArray, GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GLSL_SAMPLER_DIM_MS, 0, 1, GLSL_TYPE_INT)
+
+DECL_TYPE(usampler1D, GL_UNSIGNED_INT_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usampler2D, GL_UNSIGNED_INT_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usampler3D, GL_UNSIGNED_INT_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usamplerCube, GL_INT_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usampler1DArray, GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT)
+DECL_TYPE(usampler2DArray, GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT)
+DECL_TYPE(usamplerCubeArray, GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY, GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_UINT)
+DECL_TYPE(usampler2DRect, GL_UNSIGNED_INT_SAMPLER_2D_RECT, GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usamplerBuffer, GL_UNSIGNED_INT_SAMPLER_BUFFER, GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usampler2DMS, GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, GLSL_SAMPLER_DIM_MS, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usampler2DMSArray, GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GLSL_SAMPLER_DIM_MS, 0, 1, GLSL_TYPE_UINT)
+
+DECL_TYPE(sampler1DShadow, GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2DShadow, GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(samplerCubeShadow, GL_SAMPLER_CUBE_SHADOW, GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler1DArrayShadow, GL_SAMPLER_1D_ARRAY_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2DArrayShadow, GL_SAMPLER_2D_ARRAY_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT)
+DECL_TYPE(samplerCubeArrayShadow, GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW, GLSL_SAMPLER_DIM_CUBE, 1, 1, GLSL_TYPE_FLOAT)
+DECL_TYPE(sampler2DRectShadow, GL_SAMPLER_2D_RECT_SHADOW, GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT)
+
+DECL_TYPE(samplerExternalOES, GL_SAMPLER_EXTERNAL_OES, GLSL_SAMPLER_DIM_EXTERNAL, 0, 0, GLSL_TYPE_FLOAT)
+
+STRUCT_TYPE(gl_DepthRangeParameters)
+STRUCT_TYPE(gl_PointParameters)
+STRUCT_TYPE(gl_MaterialParameters)
+STRUCT_TYPE(gl_LightSourceParameters)
+STRUCT_TYPE(gl_LightModelParameters)
+STRUCT_TYPE(gl_LightModelProducts)
+STRUCT_TYPE(gl_LightProducts)
+STRUCT_TYPE(gl_FogParameters)
diff --git a/mesalib/src/glsl/builtin_types.cpp b/mesalib/src/glsl/builtin_types.cpp
new file mode 100644
index 000000000..722eda2da
--- /dev/null
+++ b/mesalib/src/glsl/builtin_types.cpp
@@ -0,0 +1,288 @@
+/*
+ * Copyright © 2013 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 builtin_types.cpp
+ *
+ * The glsl_type class has static members to represent all the built-in types
+ * (such as the glsl_type::_float_type flyweight) as well as convenience pointer
+ * accessors (such as glsl_type::float_type). Those global variables are
+ * declared and initialized in this file.
+ *
+ * This also contains _mesa_glsl_initialize_types(), a function which populates
+ * a symbol table with the available built-in types for a particular language
+ * version and set of enabled extensions.
+ */
+
+#include "glsl_types.h"
+#include "glsl_parser_extras.h"
+
+/**
+ * Declarations of type flyweights (glsl_type::_foo_type) and
+ * convenience pointers (glsl_type::foo_type).
+ * @{
+ */
+#define DECL_TYPE(NAME, ...) \
+ const glsl_type glsl_type::_##NAME##_type = glsl_type(__VA_ARGS__, #NAME); \
+ const glsl_type *const glsl_type::NAME##_type = &glsl_type::_##NAME##_type;
+
+#define STRUCT_TYPE(NAME) \
+ const glsl_type glsl_type::_struct_##NAME##_type = \
+ glsl_type(NAME##_fields, Elements(NAME##_fields), #NAME); \
+ const glsl_type *const glsl_type::struct_##NAME##_type = \
+ &glsl_type::_struct_##NAME##_type;
+
+static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
+ { glsl_type::float_type, "near", false },
+ { glsl_type::float_type, "far", false },
+ { glsl_type::float_type, "diff", false },
+};
+
+static const struct glsl_struct_field gl_PointParameters_fields[] = {
+ { glsl_type::float_type, "size", false },
+ { glsl_type::float_type, "sizeMin", false },
+ { glsl_type::float_type, "sizeMax", false },
+ { glsl_type::float_type, "fadeThresholdSize", false },
+ { glsl_type::float_type, "distanceConstantAttenuation", false },
+ { glsl_type::float_type, "distanceLinearAttenuation", false },
+ { glsl_type::float_type, "distanceQuadraticAttenuation", false },
+};
+
+static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
+ { glsl_type::vec4_type, "emission", false },
+ { glsl_type::vec4_type, "ambient", false },
+ { glsl_type::vec4_type, "diffuse", false },
+ { glsl_type::vec4_type, "specular", false },
+ { glsl_type::float_type, "shininess", false },
+};
+
+static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
+ { glsl_type::vec4_type, "ambient", false },
+ { glsl_type::vec4_type, "diffuse", false },
+ { glsl_type::vec4_type, "specular", false },
+ { glsl_type::vec4_type, "position", false },
+ { glsl_type::vec4_type, "halfVector", false },
+ { glsl_type::vec3_type, "spotDirection", false },
+ { glsl_type::float_type, "spotExponent", false },
+ { glsl_type::float_type, "spotCutoff", false },
+ { glsl_type::float_type, "spotCosCutoff", false },
+ { glsl_type::float_type, "constantAttenuation", false },
+ { glsl_type::float_type, "linearAttenuation", false },
+ { glsl_type::float_type, "quadraticAttenuation", false },
+};
+
+static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
+ { glsl_type::vec4_type, "ambient", false },
+};
+
+static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
+ { glsl_type::vec4_type, "sceneColor", false },
+};
+
+static const struct glsl_struct_field gl_LightProducts_fields[] = {
+ { glsl_type::vec4_type, "ambient", false },
+ { glsl_type::vec4_type, "diffuse", false },
+ { glsl_type::vec4_type, "specular", false },
+};
+
+static const struct glsl_struct_field gl_FogParameters_fields[] = {
+ { glsl_type::vec4_type, "color", false },
+ { glsl_type::float_type, "density", false },
+ { glsl_type::float_type, "start", false },
+ { glsl_type::float_type, "end", false },
+ { glsl_type::float_type, "scale", false },
+};
+
+#include "builtin_type_macros.h"
+/** @} */
+
+/**
+ * Code to populate a symbol table with the built-in types available in a
+ * particular shading language version. The table below contains tags every
+ * type with the GLSL/GLSL ES versions where it was introduced.
+ *
+ * @{
+ */
+#define T(TYPE, MIN_GL, MIN_ES) \
+ { glsl_type::TYPE##_type, MIN_GL, MIN_ES },
+
+const static struct builtin_type_versions {
+ const glsl_type *const type;
+ int min_gl;
+ int min_es;
+} builtin_type_versions[] = {
+ T(void, 110, 100)
+ T(bool, 110, 100)
+ T(bvec2, 110, 100)
+ T(bvec3, 110, 100)
+ T(bvec4, 110, 100)
+ T(int, 110, 100)
+ T(ivec2, 110, 100)
+ T(ivec3, 110, 100)
+ T(ivec4, 110, 100)
+ T(uint, 130, 300)
+ T(uvec2, 130, 300)
+ T(uvec3, 130, 300)
+ T(uvec4, 130, 300)
+ T(float, 110, 100)
+ T(vec2, 110, 100)
+ T(vec3, 110, 100)
+ T(vec4, 110, 100)
+ T(mat2, 110, 100)
+ T(mat3, 110, 100)
+ T(mat4, 110, 100)
+ T(mat2x3, 120, 300)
+ T(mat2x4, 120, 300)
+ T(mat3x2, 120, 300)
+ T(mat3x4, 120, 300)
+ T(mat4x2, 120, 300)
+ T(mat4x3, 120, 300)
+
+ T(sampler1D, 110, 999)
+ T(sampler2D, 110, 100)
+ T(sampler3D, 110, 300)
+ T(samplerCube, 110, 100)
+ T(sampler1DArray, 130, 999)
+ T(sampler2DArray, 130, 300)
+ T(samplerCubeArray, 400, 999)
+ T(sampler2DRect, 140, 999)
+ T(samplerBuffer, 140, 999)
+ T(sampler2DMS, 150, 999)
+ T(sampler2DMSArray, 150, 999)
+
+ T(isampler1D, 130, 999)
+ T(isampler2D, 130, 300)
+ T(isampler3D, 130, 300)
+ T(isamplerCube, 130, 300)
+ T(isampler1DArray, 130, 999)
+ T(isampler2DArray, 130, 300)
+ T(isamplerCubeArray, 400, 999)
+ T(isampler2DRect, 140, 999)
+ T(isamplerBuffer, 140, 999)
+ T(isampler2DMS, 150, 999)
+ T(isampler2DMSArray, 150, 999)
+
+ T(usampler1D, 130, 999)
+ T(usampler2D, 130, 300)
+ T(usampler3D, 130, 300)
+ T(usamplerCube, 130, 300)
+ T(usampler1DArray, 130, 999)
+ T(usampler2DArray, 130, 300)
+ T(usamplerCubeArray, 400, 999)
+ T(usampler2DRect, 140, 999)
+ T(usamplerBuffer, 140, 999)
+ T(usampler2DMS, 150, 999)
+ T(usampler2DMSArray, 150, 999)
+
+ T(sampler1DShadow, 110, 999)
+ T(sampler2DShadow, 110, 300)
+ T(samplerCubeShadow, 130, 300)
+ T(sampler1DArrayShadow, 130, 999)
+ T(sampler2DArrayShadow, 130, 300)
+ T(samplerCubeArrayShadow, 400, 999)
+ T(sampler2DRectShadow, 140, 999)
+
+ T(struct_gl_DepthRangeParameters, 110, 100)
+};
+
+const glsl_type *const deprecated_types[] = {
+ glsl_type::struct_gl_PointParameters_type,
+ glsl_type::struct_gl_MaterialParameters_type,
+ glsl_type::struct_gl_LightSourceParameters_type,
+ glsl_type::struct_gl_LightModelParameters_type,
+ glsl_type::struct_gl_LightModelProducts_type,
+ glsl_type::struct_gl_LightProducts_type,
+ glsl_type::struct_gl_FogParameters_type,
+};
+
+static inline void
+add_type(glsl_symbol_table *symbols, const glsl_type *const type)
+{
+ symbols->add_type(type->name, type);
+}
+
+/**
+ * Populate the symbol table with available built-in types.
+ */
+void
+_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
+{
+ struct glsl_symbol_table *symbols = state->symbols;
+
+ for (unsigned i = 0; i < Elements(builtin_type_versions); i++) {
+ const struct builtin_type_versions *const t = &builtin_type_versions[i];
+ if (state->is_version(t->min_gl, t->min_es)) {
+ add_type(symbols, t->type);
+ }
+ }
+
+ /* Add deprecated structure types. While these were deprecated in 1.30,
+ * they're still present. We've removed them in 1.40+ (OpenGL 3.1+).
+ */
+ if (!state->es_shader && state->language_version < 140) {
+ for (unsigned i = 0; i < Elements(deprecated_types); i++) {
+ add_type(symbols, deprecated_types[i]);
+ }
+ }
+
+ /* Add types for enabled extensions. They may have already been added
+ * by the version-based loop, but attempting to add them a second time
+ * is harmless.
+ */
+ if (state->ARB_texture_cube_map_array_enable) {
+ add_type(symbols, glsl_type::samplerCubeArray_type);
+ add_type(symbols, glsl_type::samplerCubeArrayShadow_type);
+ add_type(symbols, glsl_type::isamplerCubeArray_type);
+ add_type(symbols, glsl_type::usamplerCubeArray_type);
+ }
+
+ if (state->ARB_texture_multisample_enable) {
+ add_type(symbols, glsl_type::sampler2DMS_type);
+ add_type(symbols, glsl_type::isampler2DMS_type);
+ add_type(symbols, glsl_type::usampler2DMS_type);
+ add_type(symbols, glsl_type::sampler2DMSArray_type);
+ add_type(symbols, glsl_type::isampler2DMSArray_type);
+ add_type(symbols, glsl_type::usampler2DMSArray_type);
+ }
+
+ if (state->ARB_texture_rectangle_enable) {
+ add_type(symbols, glsl_type::sampler2DRect_type);
+ add_type(symbols, glsl_type::sampler2DRectShadow_type);
+ }
+
+ if (state->EXT_texture_array_enable) {
+ add_type(symbols, glsl_type::sampler1DArray_type);
+ add_type(symbols, glsl_type::sampler2DArray_type);
+ add_type(symbols, glsl_type::sampler1DArrayShadow_type);
+ add_type(symbols, glsl_type::sampler2DArrayShadow_type);
+ }
+
+ if (state->OES_EGL_image_external_enable) {
+ add_type(symbols, glsl_type::samplerExternalOES_type);
+ }
+
+ if (state->OES_texture_3D_enable) {
+ add_type(symbols, glsl_type::sampler3D_type);
+ }
+}
+/** @} */
diff --git a/mesalib/src/glsl/builtin_types.h b/mesalib/src/glsl/builtin_types.h
deleted file mode 100644
index acd2d76d5..000000000
--- a/mesalib/src/glsl/builtin_types.h
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * 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.
- */
-
-const glsl_type glsl_type::_error_type =
- glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, "");
-
-const glsl_type glsl_type::_void_type =
- glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void");
-
-const glsl_type glsl_type::_sampler3D_type =
- glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
- "sampler3D");
-
-const glsl_type glsl_type::_samplerCubeShadow_type =
- glsl_type(GL_SAMPLER_CUBE_SHADOW,
- GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT,
- "samplerCubeShadow");
-
-const glsl_type *const glsl_type::error_type = & glsl_type::_error_type;
-const glsl_type *const glsl_type::void_type = & glsl_type::_void_type;
-
-/** \name Core built-in types
- *
- * These types exist in all versions of GLSL.
- */
-/*@{*/
-
-const glsl_type glsl_type::builtin_core_types[] = {
- glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"),
- glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"),
- glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"),
- glsl_type(GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1, "bvec4"),
- glsl_type(GL_INT, GLSL_TYPE_INT, 1, 1, "int"),
- glsl_type(GL_INT_VEC2, GLSL_TYPE_INT, 2, 1, "ivec2"),
- glsl_type(GL_INT_VEC3, GLSL_TYPE_INT, 3, 1, "ivec3"),
- glsl_type(GL_INT_VEC4, GLSL_TYPE_INT, 4, 1, "ivec4"),
- glsl_type(GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1, "float"),
- glsl_type(GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1, "vec2"),
- glsl_type(GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1, "vec3"),
- glsl_type(GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1, "vec4"),
- glsl_type(GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2, "mat2"),
- glsl_type(GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3, "mat3"),
- glsl_type(GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4, "mat4"),
- glsl_type(GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT,
- "sampler2D"),
- glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT,
- "samplerCube"),
-};
-
-const glsl_type *const glsl_type::bool_type = & builtin_core_types[0];
-const glsl_type *const glsl_type::bvec2_type = & builtin_core_types[1];
-const glsl_type *const glsl_type::bvec3_type = & builtin_core_types[2];
-const glsl_type *const glsl_type::bvec4_type = & builtin_core_types[3];
-const glsl_type *const glsl_type::int_type = & builtin_core_types[4];
-const glsl_type *const glsl_type::ivec2_type = & builtin_core_types[5];
-const glsl_type *const glsl_type::ivec3_type = & builtin_core_types[6];
-const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7];
-const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
-const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
-const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10];
-const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11];
-const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12];
-const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13];
-const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14];
-/*@}*/
-
-/** \name GLSL structures that have not been deprecated.
- */
-/*@{*/
-
-static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
- { glsl_type::float_type, "near", false },
- { glsl_type::float_type, "far", false },
- { glsl_type::float_type, "diff", false },
-};
-
-const glsl_type glsl_type::builtin_structure_types[] = {
- glsl_type(gl_DepthRangeParameters_fields,
- Elements(gl_DepthRangeParameters_fields),
- "gl_DepthRangeParameters"),
-};
-/*@}*/
-
-/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30
- */
-/*@{*/
-
-static const struct glsl_struct_field gl_PointParameters_fields[] = {
- { glsl_type::float_type, "size", false },
- { glsl_type::float_type, "sizeMin", false },
- { glsl_type::float_type, "sizeMax", false },
- { glsl_type::float_type, "fadeThresholdSize", false },
- { glsl_type::float_type, "distanceConstantAttenuation", false },
- { glsl_type::float_type, "distanceLinearAttenuation", false },
- { glsl_type::float_type, "distanceQuadraticAttenuation", false },
-};
-
-static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
- { glsl_type::vec4_type, "emission", false },
- { glsl_type::vec4_type, "ambient", false },
- { glsl_type::vec4_type, "diffuse", false },
- { glsl_type::vec4_type, "specular", false },
- { glsl_type::float_type, "shininess", false },
-};
-
-static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
- { glsl_type::vec4_type, "ambient", false },
- { glsl_type::vec4_type, "diffuse", false },
- { glsl_type::vec4_type, "specular", false },
- { glsl_type::vec4_type, "position", false },
- { glsl_type::vec4_type, "halfVector", false },
- { glsl_type::vec3_type, "spotDirection", false },
- { glsl_type::float_type, "spotExponent", false },
- { glsl_type::float_type, "spotCutoff", false },
- { glsl_type::float_type, "spotCosCutoff", false },
- { glsl_type::float_type, "constantAttenuation", false },
- { glsl_type::float_type, "linearAttenuation", false },
- { glsl_type::float_type, "quadraticAttenuation", false },
-};
-
-static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
- { glsl_type::vec4_type, "ambient", false },
-};
-
-static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
- { glsl_type::vec4_type, "sceneColor", false },
-};
-
-static const struct glsl_struct_field gl_LightProducts_fields[] = {
- { glsl_type::vec4_type, "ambient", false },
- { glsl_type::vec4_type, "diffuse", false },
- { glsl_type::vec4_type, "specular", false },
-};
-
-static const struct glsl_struct_field gl_FogParameters_fields[] = {
- { glsl_type::vec4_type, "color", false },
- { glsl_type::float_type, "density", false },
- { glsl_type::float_type, "start", false },
- { glsl_type::float_type, "end", false },
- { glsl_type::float_type, "scale", false },
-};
-
-const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = {
- glsl_type(gl_PointParameters_fields,
- Elements(gl_PointParameters_fields),
- "gl_PointParameters"),
- glsl_type(gl_MaterialParameters_fields,
- Elements(gl_MaterialParameters_fields),
- "gl_MaterialParameters"),
- glsl_type(gl_LightSourceParameters_fields,
- Elements(gl_LightSourceParameters_fields),
- "gl_LightSourceParameters"),
- glsl_type(gl_LightModelParameters_fields,
- Elements(gl_LightModelParameters_fields),
- "gl_LightModelParameters"),
- glsl_type(gl_LightModelProducts_fields,
- Elements(gl_LightModelProducts_fields),
- "gl_LightModelProducts"),
- glsl_type(gl_LightProducts_fields,
- Elements(gl_LightProducts_fields),
- "gl_LightProducts"),
- glsl_type(gl_FogParameters_fields,
- Elements(gl_FogParameters_fields),
- "gl_FogParameters"),
-};
-/*@}*/
-
-/** \name Types in GLSL 1.10 (but not GLSL ES 1.00)
- */
-/*@{*/
-const glsl_type glsl_type::builtin_110_types[] = {
- glsl_type(GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT,
- "sampler1D"),
- glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT,
- "sampler1DShadow"),
- glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT,
- "sampler2DShadow"),
-};
-/*@}*/
-
-/** \name Types added in GLSL 1.20
- */
-/*@{*/
-
-const glsl_type glsl_type::builtin_120_types[] = {
- glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"),
- glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"),
- glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"),
- glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"),
- glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"),
- glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"),
-};
-const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0];
-const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1];
-const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2];
-const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3];
-const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4];
-const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5];
-/*@}*/
-
-/** \name Types added in GLSL 1.30
- */
-/*@{*/
-
-const glsl_type glsl_type::builtin_130_types[] = {
- glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"),
- glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"),
- glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"),
- glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"),
-
- /* 1D and 2D texture arrays - several of these are included only in
- * builtin_EXT_texture_array_types.
- */
- glsl_type(GL_INT_SAMPLER_1D_ARRAY,
- GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY,
- GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"),
- glsl_type(GL_INT_SAMPLER_2D_ARRAY,
- GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY,
- GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"),
-
- /* cube shadow samplers */
- glsl_type(GL_SAMPLER_CUBE_SHADOW,
- GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"),
-
- /* signed and unsigned integer samplers */
- glsl_type(GL_INT_SAMPLER_1D,
- GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_1D,
- GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"),
- glsl_type(GL_INT_SAMPLER_2D,
- GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_2D,
- GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"),
- glsl_type(GL_INT_SAMPLER_3D,
- GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_3D,
- GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"),
- glsl_type(GL_INT_SAMPLER_CUBE,
- GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"),
- glsl_type(GL_INT_SAMPLER_CUBE,
- GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"),
-};
-
-const glsl_type *const glsl_type::uint_type = & builtin_130_types[0];
-const glsl_type *const glsl_type::uvec2_type = & builtin_130_types[1];
-const glsl_type *const glsl_type::uvec3_type = & builtin_130_types[2];
-const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3];
-/*@}*/
-
-
-/** \name Types added in GLSL 1.40
- */
-/*@{*/
-const glsl_type glsl_type::builtin_140_types[] = {
- glsl_type(GL_INT_SAMPLER_2D_RECT,
- GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_INT, "isampler2DRect"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_RECT,
- GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_UINT, "usampler2DRect"),
-};
-/*@}*/
-
-/** \name Sampler types added by GL_ARB_texture_rectangle
- */
-/*@{*/
-
-const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = {
- glsl_type(GL_SAMPLER_2D_RECT,
- GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"),
- glsl_type(GL_SAMPLER_2D_RECT_SHADOW,
- GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"),
-};
-/*@}*/
-
-/** \name Sampler types added by GL_EXT_texture_array
- */
-/*@{*/
-
-const glsl_type glsl_type::builtin_EXT_texture_array_types[] = {
- glsl_type(GL_SAMPLER_1D_ARRAY,
- GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
- glsl_type(GL_SAMPLER_2D_ARRAY,
- GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
- glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW,
- GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
- glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW,
- GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),
-};
-/*@}*/
-
-/** \name Sampler types added by GL_EXT_texture_buffer_object
- */
-/*@{*/
-
-const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = {
- glsl_type(GL_SAMPLER_BUFFER,
- GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"),
- glsl_type(GL_INT_SAMPLER_BUFFER,
- GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER,
- GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"),
-};
-/*@}*/
-
-/** \name Sampler types added by GL_OES_EGL_image_external
- */
-/*@{*/
-
-const glsl_type glsl_type::builtin_OES_EGL_image_external_types[] = {
- glsl_type(GL_SAMPLER_EXTERNAL_OES,
- GLSL_SAMPLER_DIM_EXTERNAL, 0, 0, GLSL_TYPE_FLOAT, "samplerExternalOES"),
-};
-/*@}*/
-
-/** \name Sampler types added by GL_ARB_texture_cube_map_array
- */
-/*@{*/
-const glsl_type glsl_type::builtin_ARB_texture_cube_map_array_types[] = {
- glsl_type(GL_SAMPLER_CUBE_MAP_ARRAY,
- GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_FLOAT, "samplerCubeArray"),
- glsl_type(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW,
- GLSL_SAMPLER_DIM_CUBE, 1, 1, GLSL_TYPE_FLOAT, "samplerCubeArrayShadow"),
- glsl_type(GL_INT_SAMPLER_CUBE_MAP_ARRAY,
- GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_INT, "isamplerCubeArray"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY,
- GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_UINT, "usamplerCubeArray"),
-};
-/*@}*/
-
-/** \name Sampler types added by GL_ARB_texture_multisample
- */
-/*@{*/
-const glsl_type glsl_type::builtin_ARB_texture_multisample_types[] = {
- glsl_type(GL_SAMPLER_2D_MULTISAMPLE,
- GLSL_SAMPLER_DIM_MS, 0, 0, GLSL_TYPE_FLOAT, "sampler2DMS"),
- glsl_type(GL_INT_SAMPLER_2D_MULTISAMPLE,
- GLSL_SAMPLER_DIM_MS, 0, 0, GLSL_TYPE_INT, "isampler2DMS"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE,
- GLSL_SAMPLER_DIM_MS, 0, 0, GLSL_TYPE_UINT, "usampler2DMS"),
- glsl_type(GL_SAMPLER_2D_MULTISAMPLE_ARRAY,
- GLSL_SAMPLER_DIM_MS, 0, 1, GLSL_TYPE_FLOAT, "sampler2DMSArray"),
- glsl_type(GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY,
- GLSL_SAMPLER_DIM_MS, 0, 1, GLSL_TYPE_INT, "isampler2DMSArray"),
- glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY,
- GLSL_SAMPLER_DIM_MS, 0, 1, GLSL_TYPE_UINT, "usampler2DMSArray"),
-};
-/*@}*/
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 98627145a..f4087df30 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -28,6 +28,7 @@
extern "C" {
#include "main/core.h" /* for struct gl_context */
#include "main/context.h"
+#include "main/shaderobj.h"
}
#include "ralloc.h"
@@ -302,6 +303,41 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
}
}
+extern "C" {
+
+/**
+ * The most common use of _mesa_glsl_shader_target_name(), which is
+ * shared with C code in Mesa core to translate a GLenum to a short
+ * shader stage name in debug printouts.
+ *
+ * It recognizes the PROGRAM variants of the names so it can be used
+ * with a struct gl_program->Target, not just a struct
+ * gl_shader->Type.
+ */
+const char *
+_mesa_glsl_shader_target_name(GLenum type)
+{
+ switch (type) {
+ case GL_VERTEX_SHADER:
+ case GL_VERTEX_PROGRAM_ARB:
+ return "vertex";
+ case GL_FRAGMENT_SHADER:
+ case GL_FRAGMENT_PROGRAM_ARB:
+ return "fragment";
+ case GL_GEOMETRY_SHADER:
+ return "geometry";
+ default:
+ assert(!"Should not get here.");
+ return "unknown";
+ }
+}
+
+} /* extern "C" */
+
+/**
+ * Overloaded C++ variant usable within the compiler for translating
+ * our internal enum into short stage names.
+ */
const char *
_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
{
@@ -1202,6 +1238,88 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier,
this->declarations.push_degenerate_list_at_head(&declarator_list->link);
}
+extern "C" {
+
+void
+_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
+ bool dump_ast, bool dump_hir)
+{
+ struct _mesa_glsl_parse_state *state =
+ new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
+ const char *source = shader->Source;
+
+ state->error = glcpp_preprocess(state, &source, &state->info_log,
+ &ctx->Extensions, ctx);
+
+ if (!state->error) {
+ _mesa_glsl_lexer_ctor(state, source);
+ _mesa_glsl_parse(state);
+ _mesa_glsl_lexer_dtor(state);
+ }
+
+ if (dump_ast) {
+ foreach_list_const(n, &state->translation_unit) {
+ ast_node *ast = exec_node_data(ast_node, n, link);
+ ast->print();
+ }
+ printf("\n\n");
+ }
+
+ ralloc_free(shader->ir);
+ shader->ir = new(shader) exec_list;
+ if (!state->error && !state->translation_unit.is_empty())
+ _mesa_ast_to_hir(shader->ir, state);
+
+ if (!state->error) {
+ validate_ir_tree(shader->ir);
+
+ /* Print out the unoptimized IR. */
+ if (dump_hir) {
+ _mesa_print_ir(shader->ir, state);
+ }
+ }
+
+
+ if (!state->error && !shader->ir->is_empty()) {
+ struct gl_shader_compiler_options *options =
+ &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
+
+ /* Do some optimization at compile time to reduce shader IR size
+ * and reduce later work if the same shader is linked multiple times
+ */
+ while (do_common_optimization(shader->ir, false, false, 32, options))
+ ;
+
+ validate_ir_tree(shader->ir);
+ }
+
+ if (shader->InfoLog)
+ ralloc_free(shader->InfoLog);
+
+ shader->symbols = state->symbols;
+ shader->CompileStatus = !state->error;
+ shader->InfoLog = state->info_log;
+ shader->Version = state->language_version;
+ shader->InfoLog = state->info_log;
+ shader->IsES = state->es_shader;
+
+ memcpy(shader->builtins_to_link, state->builtins_to_link,
+ sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link);
+ shader->num_builtins_to_link = state->num_builtins_to_link;
+
+ if (shader->UniformBlocks)
+ ralloc_free(shader->UniformBlocks);
+ shader->NumUniformBlocks = state->num_uniform_blocks;
+ shader->UniformBlocks = state->uniform_blocks;
+ ralloc_steal(shader, shader->UniformBlocks);
+
+ /* Retain any live IR, but trash the rest. */
+ reparent_ir(shader->ir, shader->ir);
+
+ ralloc_free(state);
+}
+
+} /* extern "C" */
/**
* Do the set of common optimizations passes
*
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index cdb8fc00d..bf665663e 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -375,6 +375,9 @@ _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target);
extern "C" {
#endif
+extern const char *
+_mesa_glsl_shader_target_name(GLenum type);
+
extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, struct gl_context *gl_ctx);
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index df9c5d36f..9d3691b54 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -27,7 +27,6 @@
#include "glsl_symbol_table.h"
#include "glsl_parser_extras.h"
#include "glsl_types.h"
-#include "builtin_types.h"
extern "C" {
#include "program/hash_table.h"
}
@@ -129,22 +128,6 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
}
}
-static void
-add_types_to_symbol_table(glsl_symbol_table *symtab,
- const struct glsl_type *types,
- unsigned num_types, bool warn,
- bool skip_1d)
-{
- (void) warn;
-
- for (unsigned i = 0; i < num_types; i++) {
- if (skip_1d && types[i].base_type == GLSL_TYPE_SAMPLER
- && types[i].sampler_dimensionality == GLSL_SAMPLER_DIM_1D)
- continue;
-
- symtab->add_type(types[i].name, & types[i]);
- }
-}
bool
glsl_type::contains_sampler() const
@@ -210,242 +193,6 @@ glsl_type::sampler_index() const
}
}
-void
-glsl_type::generate_100ES_types(glsl_symbol_table *symtab)
-{
- bool skip_1d = false;
- add_types_to_symbol_table(symtab, builtin_core_types,
- Elements(builtin_core_types),
- false, skip_1d);
- add_types_to_symbol_table(symtab, builtin_structure_types,
- Elements(builtin_structure_types),
- false, skip_1d);
- add_types_to_symbol_table(symtab, void_type, 1, false, skip_1d);
-}
-
-void
-glsl_type::generate_300ES_types(glsl_symbol_table *symtab)
-{
- /* GLSL 3.00 ES types are the same as GLSL 1.30 types, except that 1D
- * samplers are skipped, and samplerCubeShadow is added.
- */
- bool add_deprecated = false;
- bool skip_1d = true;
-
- generate_130_types(symtab, add_deprecated, skip_1d);
-
- add_types_to_symbol_table(symtab, &_samplerCubeShadow_type, 1, false,
- skip_1d);
-}
-
-void
-glsl_type::generate_110_types(glsl_symbol_table *symtab, bool add_deprecated,
- bool skip_1d)
-{
- generate_100ES_types(symtab);
-
- add_types_to_symbol_table(symtab, builtin_110_types,
- Elements(builtin_110_types),
- false, skip_1d);
- add_types_to_symbol_table(symtab, &_sampler3D_type, 1, false, skip_1d);
- if (add_deprecated) {
- add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,
- Elements(builtin_110_deprecated_structure_types),
- false, skip_1d);
- }
-}
-
-
-void
-glsl_type::generate_120_types(glsl_symbol_table *symtab, bool add_deprecated,
- bool skip_1d)
-{
- generate_110_types(symtab, add_deprecated, skip_1d);
-
- add_types_to_symbol_table(symtab, builtin_120_types,
- Elements(builtin_120_types), false, skip_1d);
-}
-
-
-void
-glsl_type::generate_130_types(glsl_symbol_table *symtab, bool add_deprecated,
- bool skip_1d)
-{
- generate_120_types(symtab, add_deprecated, skip_1d);
-
- add_types_to_symbol_table(symtab, builtin_130_types,
- Elements(builtin_130_types), false, skip_1d);
- generate_EXT_texture_array_types(symtab, false);
-}
-
-
-void
-glsl_type::generate_140_types(glsl_symbol_table *symtab)
-{
- bool skip_1d = false;
-
- generate_130_types(symtab, false, skip_1d);
-
- add_types_to_symbol_table(symtab, builtin_140_types,
- Elements(builtin_140_types), false, skip_1d);
-
- add_types_to_symbol_table(symtab, builtin_EXT_texture_buffer_object_types,
- Elements(builtin_EXT_texture_buffer_object_types),
- false, skip_1d);
-}
-
-
-void
-glsl_type::generate_150_types(glsl_symbol_table *symtab)
-{
- generate_140_types(symtab);
- generate_ARB_texture_multisample_types(symtab, false);
-}
-
-
-void
-glsl_type::generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab,
- bool warn)
-{
- bool skip_1d = false;
-
- add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types,
- Elements(builtin_ARB_texture_rectangle_types),
- warn, skip_1d);
-}
-
-
-void
-glsl_type::generate_EXT_texture_array_types(glsl_symbol_table *symtab,
- bool warn)
-{
- bool skip_1d = false;
-
- add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types,
- Elements(builtin_EXT_texture_array_types),
- warn, skip_1d);
-}
-
-
-void
-glsl_type::generate_OES_texture_3D_types(glsl_symbol_table *symtab, bool warn)
-{
- bool skip_1d = false;
-
- add_types_to_symbol_table(symtab, &_sampler3D_type, 1, warn, skip_1d);
-}
-
-
-void
-glsl_type::generate_OES_EGL_image_external_types(glsl_symbol_table *symtab,
- bool warn)
-{
- bool skip_1d = false;
-
- add_types_to_symbol_table(symtab, builtin_OES_EGL_image_external_types,
- Elements(builtin_OES_EGL_image_external_types),
- warn, skip_1d);
-}
-
-void
-glsl_type::generate_ARB_texture_cube_map_array_types(glsl_symbol_table *symtab,
- bool warn)
-{
- bool skip_1d = false;
-
- add_types_to_symbol_table(symtab, builtin_ARB_texture_cube_map_array_types,
- Elements(builtin_ARB_texture_cube_map_array_types),
- warn, skip_1d);
-}
-
-void
-glsl_type::generate_ARB_texture_multisample_types(glsl_symbol_table *symtab,
- bool warn)
-{
- bool skip_1d = false;
- add_types_to_symbol_table(symtab, builtin_ARB_texture_multisample_types,
- Elements(builtin_ARB_texture_multisample_types),
- warn, skip_1d);
-}
-
-void
-_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
-{
- if (state->es_shader) {
- switch (state->language_version) {
- case 100:
- assert(state->es_shader);
- glsl_type::generate_100ES_types(state->symbols);
- break;
- case 300:
- glsl_type::generate_300ES_types(state->symbols);
- break;
- default:
- assert(!"Unexpected language version");
- break;
- }
- } else {
- bool skip_1d = false;
- switch (state->language_version) {
- case 110:
- glsl_type::generate_110_types(state->symbols, true, skip_1d);
- break;
- case 120:
- glsl_type::generate_120_types(state->symbols, true, skip_1d);
- break;
- case 130:
- glsl_type::generate_130_types(state->symbols, true, skip_1d);
- break;
- case 140:
- glsl_type::generate_140_types(state->symbols);
- break;
- case 150:
- glsl_type::generate_150_types(state->symbols);
- break;
- default:
- assert(!"Unexpected language version");
- break;
- }
- }
-
- if (state->ARB_texture_rectangle_enable ||
- state->is_version(140, 0)) {
- glsl_type::generate_ARB_texture_rectangle_types(state->symbols,
- state->ARB_texture_rectangle_warn);
- }
- if (state->OES_texture_3D_enable
- && state->is_version(0, 100)) {
- glsl_type::generate_OES_texture_3D_types(state->symbols,
- state->OES_texture_3D_warn);
- }
-
- if (state->EXT_texture_array_enable
- && !state->is_version(130, 0)) {
- // These are already included in 130; don't create twice.
- glsl_type::generate_EXT_texture_array_types(state->symbols,
- state->EXT_texture_array_warn);
- }
-
- /* We cannot check for language_version == 100 here because we need the
- * types to support fixed-function program generation. But this is fine
- * since the extension is never enabled for OpenGL contexts.
- */
- if (state->OES_EGL_image_external_enable) {
- glsl_type::generate_OES_EGL_image_external_types(state->symbols,
- state->OES_EGL_image_external_warn);
- }
-
- if (state->ARB_texture_cube_map_array_enable) {
- glsl_type::generate_ARB_texture_cube_map_array_types(state->symbols,
- state->ARB_texture_cube_map_array_warn);
- }
-
- if (state->ARB_texture_multisample_enable) {
- glsl_type::generate_ARB_texture_multisample_types(state->symbols,
- state->ARB_texture_multisample_warn);
- }
-}
-
const glsl_type *glsl_type::get_base_type() const
{
@@ -534,6 +281,58 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
}
+const glsl_type *const
+glsl_type::vec(unsigned components)
+{
+ if (components == 0 || components > 4)
+ return error_type;
+
+ static const glsl_type *const ts[] = {
+ float_type, vec2_type, vec3_type, vec4_type
+ };
+ return ts[components - 1];
+}
+
+
+const glsl_type *const
+glsl_type::ivec(unsigned components)
+{
+ if (components == 0 || components > 4)
+ return error_type;
+
+ static const glsl_type *const ts[] = {
+ int_type, ivec2_type, ivec3_type, ivec4_type
+ };
+ return ts[components - 1];
+}
+
+
+const glsl_type *const
+glsl_type::uvec(unsigned components)
+{
+ if (components == 0 || components > 4)
+ return error_type;
+
+ static const glsl_type *const ts[] = {
+ uint_type, uvec2_type, uvec3_type, uvec4_type
+ };
+ return ts[components - 1];
+}
+
+
+const glsl_type *const
+glsl_type::bvec(unsigned components)
+{
+ if (components == 0 || components > 4)
+ return error_type;
+
+ static const glsl_type *const ts[] = {
+ bool_type, bvec2_type, bvec3_type, bvec4_type
+ };
+ return ts[components - 1];
+}
+
+
const glsl_type *
glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
{
@@ -548,13 +347,13 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
if (columns == 1) {
switch (base_type) {
case GLSL_TYPE_UINT:
- return uint_type + (rows - 1);
+ return uvec(rows);
case GLSL_TYPE_INT:
- return int_type + (rows - 1);
+ return ivec(rows);
case GLSL_TYPE_FLOAT:
- return float_type + (rows - 1);
+ return vec(rows);
case GLSL_TYPE_BOOL:
- return bool_type + (rows - 1);
+ return bvec(rows);
default:
return error_type;
}
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index 31e3dd253..cb5208029 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -153,40 +153,28 @@ struct glsl_type {
struct glsl_struct_field *structure; /**< List of struct fields. */
} fields;
-
/**
* \name Pointers to various public type singletons
*/
/*@{*/
- static const glsl_type *const error_type;
- static const glsl_type *const void_type;
- static const glsl_type *const int_type;
- static const glsl_type *const ivec2_type;
- static const glsl_type *const ivec3_type;
- static const glsl_type *const ivec4_type;
- static const glsl_type *const uint_type;
- static const glsl_type *const uvec2_type;
- static const glsl_type *const uvec3_type;
- static const glsl_type *const uvec4_type;
- static const glsl_type *const float_type;
- static const glsl_type *const vec2_type;
- static const glsl_type *const vec3_type;
- static const glsl_type *const vec4_type;
- static const glsl_type *const bool_type;
- static const glsl_type *const bvec2_type;
- static const glsl_type *const bvec3_type;
- static const glsl_type *const bvec4_type;
- static const glsl_type *const mat2_type;
- static const glsl_type *const mat2x3_type;
- static const glsl_type *const mat2x4_type;
- static const glsl_type *const mat3x2_type;
- static const glsl_type *const mat3_type;
- static const glsl_type *const mat3x4_type;
- static const glsl_type *const mat4x2_type;
- static const glsl_type *const mat4x3_type;
- static const glsl_type *const mat4_type;
+#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 *const vec(unsigned components);
+ static const glsl_type *const ivec(unsigned components);
+ static const glsl_type *const uvec(unsigned components);
+ static const glsl_type *const bvec(unsigned components);
+ /**@}*/
/**
* For numeric and boolean derrived types returns the basic scalar type
@@ -542,53 +530,14 @@ private:
static unsigned record_key_hash(const void *key);
/**
- * \name Pointers to various type singletons
- */
- /*@{*/
- static const glsl_type _error_type;
- static const glsl_type _void_type;
- static const glsl_type _sampler3D_type;
- static const glsl_type _samplerCubeShadow_type;
- static const glsl_type builtin_core_types[];
- static const glsl_type builtin_structure_types[];
- static const glsl_type builtin_110_deprecated_structure_types[];
- static const glsl_type builtin_110_types[];
- static const glsl_type builtin_120_types[];
- static const glsl_type builtin_130_types[];
- static const glsl_type builtin_140_types[];
- static const glsl_type builtin_ARB_texture_rectangle_types[];
- static const glsl_type builtin_EXT_texture_array_types[];
- static const glsl_type builtin_EXT_texture_buffer_object_types[];
- static const glsl_type builtin_OES_EGL_image_external_types[];
- static const glsl_type builtin_ARB_texture_cube_map_array_types[];
- static const glsl_type builtin_ARB_texture_multisample_types[];
- /*@}*/
-
- /**
- * \name Methods to populate a symbol table with built-in types.
- *
- * \internal
- * This is one of the truely annoying things about C++. Methods that are
- * completely internal and private to a type still have to be advertised to
- * the world in a public header file.
+ * \name Built-in type flyweights
*/
/*@{*/
- static void generate_100ES_types(glsl_symbol_table *);
- static void generate_300ES_types(glsl_symbol_table *);
- static void generate_110_types(glsl_symbol_table *, bool add_deprecated,
- bool skip_1d);
- static void generate_120_types(glsl_symbol_table *, bool add_deprecated,
- bool skip_1d);
- static void generate_130_types(glsl_symbol_table *, bool add_deprecated,
- bool skip_1d);
- static void generate_140_types(glsl_symbol_table *);
- static void generate_150_types(glsl_symbol_table *);
- static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool);
- static void generate_EXT_texture_array_types(glsl_symbol_table *, bool);
- static void generate_OES_texture_3D_types(glsl_symbol_table *, bool);
- static void generate_OES_EGL_image_external_types(glsl_symbol_table *, bool);
- static void generate_ARB_texture_cube_map_array_types(glsl_symbol_table *, bool);
- static void generate_ARB_texture_multisample_types(glsl_symbol_table *, bool);
+#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"
/*@}*/
/**
@@ -616,6 +565,8 @@ 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/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index 6d4150136..1f0dc0906 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -36,6 +36,8 @@
#include "ir_hierarchical_visitor.h"
#include "main/mtypes.h"
+#ifdef __cplusplus
+
/**
* \defgroup IR Intermediate representation nodes
*
@@ -2050,4 +2052,14 @@ extern char *
prototype_string(const glsl_type *return_type, const char *name,
exec_list *parameters);
+extern "C" {
+#endif /* __cplusplus */
+
+extern void _mesa_print_ir(struct exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
#endif /* IR_H */
diff --git a/mesalib/src/glsl/ir_hierarchical_visitor.h b/mesalib/src/glsl/ir_hierarchical_visitor.h
index 143eb7c88..1988ad091 100644
--- a/mesalib/src/glsl/ir_hierarchical_visitor.h
+++ b/mesalib/src/glsl/ir_hierarchical_visitor.h
@@ -36,6 +36,7 @@ enum ir_visitor_status {
};
+#ifdef __cplusplus
/**
* Base class of hierarchical visitors of IR instruction trees
*
@@ -181,5 +182,6 @@ void visit_tree(ir_instruction *ir,
ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l,
bool statement_list = true);
+#endif /* __cplusplus */
#endif /* IR_HIERARCHICAL_VISITOR_H */
diff --git a/mesalib/src/glsl/ir_print_visitor.cpp b/mesalib/src/glsl/ir_print_visitor.cpp
index f01019c98..ca973a5f3 100644
--- a/mesalib/src/glsl/ir_print_visitor.cpp
+++ b/mesalib/src/glsl/ir_print_visitor.cpp
@@ -38,6 +38,7 @@ ir_instruction::print(void) const
deconsted->accept(&v);
}
+extern "C" {
void
_mesa_print_ir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
@@ -69,6 +70,8 @@ _mesa_print_ir(exec_list *instructions,
printf("\n)");
}
+} /* extern "C" */
+
ir_print_visitor::ir_print_visitor()
{
indentation = 0;
diff --git a/mesalib/src/glsl/ir_print_visitor.h b/mesalib/src/glsl/ir_print_visitor.h
index 6c308f31e..a84056d16 100644
--- a/mesalib/src/glsl/ir_print_visitor.h
+++ b/mesalib/src/glsl/ir_print_visitor.h
@@ -33,9 +33,6 @@ extern "C" {
#include "program/symbol_table.h"
}
-extern void _mesa_print_ir(exec_list *instructions,
- struct _mesa_glsl_parse_state *state);
-
/**
* Abstract base class of visitors of IR instruction trees
*/
diff --git a/mesalib/src/glsl/ir_rvalue_visitor.cpp b/mesalib/src/glsl/ir_rvalue_visitor.cpp
index 3504a4dda..8eb1c62c3 100644
--- a/mesalib/src/glsl/ir_rvalue_visitor.cpp
+++ b/mesalib/src/glsl/ir_rvalue_visitor.cpp
@@ -32,7 +32,6 @@
#include "ir.h"
#include "ir_visitor.h"
#include "ir_rvalue_visitor.h"
-#include "ir_print_visitor.h"
#include "glsl_types.h"
ir_visitor_status
diff --git a/mesalib/src/glsl/ir_visitor.h b/mesalib/src/glsl/ir_visitor.h
index 4a00155be..bd47ef7d5 100644
--- a/mesalib/src/glsl/ir_visitor.h
+++ b/mesalib/src/glsl/ir_visitor.h
@@ -26,6 +26,7 @@
#ifndef IR_VISITOR_H
#define IR_VISITOR_H
+#ifdef __cplusplus
/**
* Abstract base class of visitors of IR instruction trees
*/
@@ -81,5 +82,6 @@ public:
virtual void visit(class ir_constant *) {}
virtual void visit(class ir_call *) {}
};
+#endif /* __cplusplus */
#endif /* IR_VISITOR_H */
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 4ea00b000..6fce7fb8d 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -157,7 +157,7 @@ class count_uniform_size : public program_resource_visitor {
public:
count_uniform_size(struct string_to_uint_map *map)
: num_active_uniforms(0), num_values(0), num_shader_samplers(0),
- num_shader_uniform_components(0), map(map)
+ num_shader_uniform_components(0), is_ubo_var(false), map(map)
{
/* empty */
}
diff --git a/mesalib/src/glsl/link_varyings.cpp b/mesalib/src/glsl/link_varyings.cpp
index 34e3440d6..4fdbdc199 100644
--- a/mesalib/src/glsl/link_varyings.cpp
+++ b/mesalib/src/glsl/link_varyings.cpp
@@ -31,6 +31,7 @@
#include "main/mtypes.h"
#include "glsl_symbol_table.h"
+#include "glsl_parser_extras.h"
#include "ir_optimization.h"
#include "linker.h"
#include "link_varyings.h"
@@ -47,9 +48,10 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
gl_shader *producer, gl_shader *consumer)
{
glsl_symbol_table parameters;
- /* FINISHME: Figure these out dynamically. */
- const char *const producer_stage = "vertex";
- const char *const consumer_stage = "fragment";
+ const char *const producer_stage =
+ _mesa_glsl_shader_target_name(producer->Type);
+ const char *const consumer_stage =
+ _mesa_glsl_shader_target_name(consumer->Type);
/* Find all shader outputs in the "producer" stage.
*/
@@ -1135,8 +1137,11 @@ assign_varying_locations(struct gl_context *ctx,
* "glsl1-varying read but not written" in piglit.
*/
- linker_error(prog, "fragment shader varying %s not written "
- "by vertex shader\n.", var->name);
+ linker_error(prog, "%s shader varying %s not written "
+ "by %s shader\n.",
+ _mesa_glsl_shader_target_name(consumer->Type),
+ var->name,
+ _mesa_glsl_shader_target_name(producer->Type));
}
/* An 'in' variable is only really a shader input if its
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index cd8d680ae..c168e47e0 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -66,6 +66,7 @@
#include "main/core.h"
#include "glsl_symbol_table.h"
+#include "glsl_parser_extras.h"
#include "ir.h"
#include "program.h"
#include "program/hash_table.h"
@@ -1009,8 +1010,7 @@ link_intrastage_shaders(void *mem_ctx,
if (main == NULL) {
linker_error(prog, "%s shader lacks `main'\n",
- (shader_list[0]->Type == GL_VERTEX_SHADER)
- ? "vertex" : "fragment");
+ _mesa_glsl_shader_target_name(shader_list[0]->Type));
return NULL;
}
diff --git a/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp b/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp
index 040b0bf83..0f5072793 100644
--- a/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp
@@ -99,7 +99,7 @@ compare_index_block(exec_list *instructions, ir_variable *index,
ir_rvalue *const condition_val =
new(mem_ctx) ir_expression(ir_binop_equal,
- &glsl_type::bool_type[components - 1],
+ glsl_type::bvec(components),
broadcast_index,
test_indices);
diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp
index 768415169..df6d1e9d4 100644
--- a/mesalib/src/glsl/main.cpp
+++ b/mesalib/src/glsl/main.cpp
@@ -45,7 +45,6 @@
#include "ast.h"
#include "glsl_parser_extras.h"
#include "ir_optimization.h"
-#include "ir_print_visitor.h"
#include "program.h"
#include "loop_analysis.h"
#include "standalone_scaffolding.h"
@@ -155,70 +154,13 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
struct _mesa_glsl_parse_state *state =
new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
- const char *source = shader->Source;
- state->error = glcpp_preprocess(state, &source, &state->info_log,
- state->extensions, ctx) != 0;
-
- if (!state->error) {
- _mesa_glsl_lexer_ctor(state, source);
- _mesa_glsl_parse(state);
- _mesa_glsl_lexer_dtor(state);
- }
-
- if (dump_ast) {
- foreach_list_const(n, &state->translation_unit) {
- ast_node *ast = exec_node_data(ast_node, n, link);
- ast->print();
- }
- printf("\n\n");
- }
-
- shader->ir = new(shader) exec_list;
- if (!state->error && !state->translation_unit.is_empty())
- _mesa_ast_to_hir(shader->ir, state);
-
- /* Print out the unoptimized IR. */
- if (!state->error && dump_hir) {
- validate_ir_tree(shader->ir);
- _mesa_print_ir(shader->ir, state);
- }
-
- /* Optimization passes */
- if (!state->error && !shader->ir->is_empty()) {
- const struct gl_shader_compiler_options *opts =
- &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
- bool progress;
- do {
- progress = do_common_optimization(shader->ir, false, false, 32, opts);
- } while (progress);
-
- validate_ir_tree(shader->ir);
- }
-
+ _mesa_glsl_compile_shader(ctx, shader, dump_ast, dump_hir);
/* Print out the resulting IR */
if (!state->error && dump_lir) {
_mesa_print_ir(shader->ir, state);
}
- shader->symbols = state->symbols;
- shader->CompileStatus = !state->error;
- shader->Version = state->language_version;
- shader->IsES = state->es_shader;
- memcpy(shader->builtins_to_link, state->builtins_to_link,
- sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link);
- shader->num_builtins_to_link = state->num_builtins_to_link;
-
- if (shader->InfoLog)
- ralloc_free(shader->InfoLog);
-
- shader->InfoLog = state->info_log;
-
- /* Retain any live IR, but trash the rest. */
- reparent_ir(shader->ir, shader);
-
- ralloc_free(state);
-
return;
}
diff --git a/mesalib/src/glsl/opt_array_splitting.cpp b/mesalib/src/glsl/opt_array_splitting.cpp
index 67733ca6b..f4a7ef99b 100644
--- a/mesalib/src/glsl/opt_array_splitting.cpp
+++ b/mesalib/src/glsl/opt_array_splitting.cpp
@@ -36,7 +36,6 @@
#include "ir.h"
#include "ir_visitor.h"
#include "ir_rvalue_visitor.h"
-#include "ir_print_visitor.h"
#include "glsl_types.h"
static bool debug = false;
diff --git a/mesalib/src/glsl/opt_noop_swizzle.cpp b/mesalib/src/glsl/opt_noop_swizzle.cpp
index 693719e3d..586ad5e61 100644
--- a/mesalib/src/glsl/opt_noop_swizzle.cpp
+++ b/mesalib/src/glsl/opt_noop_swizzle.cpp
@@ -32,7 +32,6 @@
#include "ir.h"
#include "ir_visitor.h"
#include "ir_rvalue_visitor.h"
-#include "ir_print_visitor.h"
#include "glsl_types.h"
namespace {
diff --git a/mesalib/src/glsl/opt_structure_splitting.cpp b/mesalib/src/glsl/opt_structure_splitting.cpp
index 806c079e5..9f4b3dd8f 100644
--- a/mesalib/src/glsl/opt_structure_splitting.cpp
+++ b/mesalib/src/glsl/opt_structure_splitting.cpp
@@ -34,7 +34,6 @@
#include "ir.h"
#include "ir_visitor.h"
-#include "ir_print_visitor.h"
#include "ir_rvalue_visitor.h"
#include "glsl_types.h"
diff --git a/mesalib/src/glsl/program.h b/mesalib/src/glsl/program.h
index 6a76d4d54..f15113a08 100644
--- a/mesalib/src/glsl/program.h
+++ b/mesalib/src/glsl/program.h
@@ -24,15 +24,27 @@
#include "main/core.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void
+_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
+ bool dump_ast, bool dump_hir);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
extern void
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog);
extern void
-linker_error(gl_shader_program *prog, const char *fmt, ...)
+linker_error(struct gl_shader_program *prog, const char *fmt, ...)
PRINTFLIKE(2, 3);
extern void
-linker_warning(gl_shader_program *prog, const char *fmt, ...)
+linker_warning(struct gl_shader_program *prog, const char *fmt, ...)
PRINTFLIKE(2, 3);
extern long
diff --git a/mesalib/src/glsl/test_optpass.cpp b/mesalib/src/glsl/test_optpass.cpp
index fc10cbbde..67e2ab2b1 100644
--- a/mesalib/src/glsl/test_optpass.cpp
+++ b/mesalib/src/glsl/test_optpass.cpp
@@ -39,7 +39,6 @@
#include "ast.h"
#include "ir_optimization.h"
-#include "ir_print_visitor.h"
#include "program.h"
#include "ir_reader.h"
#include "standalone_scaffolding.h"
diff --git a/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml b/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml
index 11f268dc6..f2877a4f7 100644
--- a/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml
+++ b/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml
@@ -72,7 +72,7 @@
<function name="DebugMessageCallbackARB" offset="assign">
<param name="callback" type="GLDEBUGPROCARB"/>
- <param name="userParam" type="const GLvoid *"/>
+ <param name="userParam" type="GLvoid *"/>
</function>
<function name="GetDebugMessageLogARB" offset="assign">
diff --git a/mesalib/src/mapi/glapi/gen/SConscript b/mesalib/src/mapi/glapi/gen/SConscript
index 6d36248e7..18158ff8b 100644
--- a/mesalib/src/mapi/glapi/gen/SConscript
+++ b/mesalib/src/mapi/glapi/gen/SConscript
@@ -3,6 +3,12 @@ Import('*')
from sys import executable as python_cmd
+# Be conservative and depend on all XML files here. Missing dependencies means
+# broken builds, whereas extraneous dependencies merely means regenerate the
+# .[ch] files -- scons should not recompile them though.
+sources = ['gl_and_es_API.xml'] + env.Glob('*.xml')
+
+
# Generate the GL API headers that are used by various parts of the
# Mesa and GLX tree. Other .c and .h files are generated elsewhere
# if they're only used in one place.
@@ -10,28 +16,28 @@ from sys import executable as python_cmd
env.CodeGenerate(
target = '../../../mesa/main/dispatch.h',
script = 'gl_table.py',
- source = 'gl_and_es_API.xml',
+ source = sources,
command = python_cmd + ' $SCRIPT -m remap_table -f $SOURCE > $TARGET',
)
env.CodeGenerate(
target = '../../../mapi/glapi/glapitable.h',
script = 'gl_table.py',
- source = 'gl_and_es_API.xml',
+ source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
env.CodeGenerate(
target = '../../../mapi/glapi/glapitemp.h',
script = 'gl_apitemp.py',
- source = 'gl_and_es_API.xml',
+ source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
env.CodeGenerate(
target = '../../../mapi/glapi/glprocs.h',
script = 'gl_procs.py',
- source = 'gl_and_es_API.xml',
+ source = sources,
command = python_cmd + ' $SCRIPT -f $SOURCE > $TARGET'
)
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index e0a833f27..0fb3a1aab 100755
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -10168,7 +10168,7 @@
<param name="mode" type="GLenum"/>
<param name="count" type="const GLsizei *"/>
<param name="type" type="GLenum"/>
- <param name="indices" type="const GLvoid **"/>
+ <param name="indices" type="const GLvoid * const *"/>
<param name="primcount" type="GLsizei"/>
<glx handcode="true"/>
</function>
diff --git a/mesalib/src/mapi/glapi/glapi_priv.h b/mesalib/src/mapi/glapi/glapi_priv.h
index 795e0a200..92925faac 100644
--- a/mesalib/src/mapi/glapi/glapi_priv.h
+++ b/mesalib/src/mapi/glapi/glapi_priv.h
@@ -40,8 +40,8 @@
#ifndef GL_OES_fixed_point
typedef int GLfixed;
-typedef int GLclampx;
#endif
+typedef int GLclampx;
#ifndef GL_OES_EGL_image
typedef void *GLeglImageOES;
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c
index 016c0e80f..5faa98af1 100644
--- a/mesalib/src/mesa/drivers/common/driverfuncs.c
+++ b/mesalib/src/mesa/drivers/common/driverfuncs.c
@@ -75,7 +75,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->GetString = NULL; /* REQUIRED! */
driver->UpdateState = NULL; /* REQUIRED! */
- driver->GetBufferSize = NULL; /* REQUIRED! */
driver->ResizeBuffers = _mesa_resize_framebuffer;
driver->Finish = NULL;
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am
index b545f37de..ad7887d06 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am
@@ -66,7 +66,7 @@ options.h: t_options.h $(MOS)
# Update .mo files from the corresponding .po files.
%/LC_MESSAGES/options.mo: %.po
- @mo="$@" \
+ @mo="$@"; \
lang=$${mo%%/*}; \
echo "Updating ($$lang) $@ from $?."; \
mkdir -p $$lang/LC_MESSAGES; \
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index f72db1029..15681fce2 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -647,7 +647,6 @@ swrast_init_driver_functions(struct dd_function_table *driver)
{
driver->GetString = get_string;
driver->UpdateState = update_state;
- driver->GetBufferSize = NULL;
driver->Viewport = viewport;
driver->ChooseTextureFormat = swrastChooseTextureFormat;
driver->MapRenderbuffer = swrast_map_renderbuffer;
diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
index 35ec65ac3..ef791ab2f 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
@@ -605,7 +605,6 @@ WMesaContext WMesaCreateContext(HDC hDC,
_mesa_init_driver_functions(&functions);
functions.GetString = wmesa_get_string;
functions.UpdateState = wmesa_update_state;
- functions.GetBufferSize = wmesa_get_buffer_size;
functions.Flush = wmesa_flush;
functions.Clear = clear;
functions.ResizeBuffers = wmesa_resize_buffers;
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 9358e699c..ca617f744 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -1045,8 +1045,6 @@ _mesa_PopAttrib(void)
_mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth);
_mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth);
_mesa_Hint(GL_FOG_HINT, hint->Fog);
- _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT,
- hint->ClipVolumeClipping);
_mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB,
hint->TextureCompression);
}
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index c59f755c6..5ad04cc99 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -1388,25 +1388,6 @@ check_compatible(const struct gl_context *ctx,
/**
- * Do one-time initialization for the given framebuffer. Specifically,
- * ask the driver for the window's current size and update the framebuffer
- * object to match.
- * Really, the device driver should totally take care of this.
- */
-static void
-initialize_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb)
-{
- GLuint width, height;
- if (ctx->Driver.GetBufferSize) {
- ctx->Driver.GetBufferSize(fb, &width, &height);
- if (ctx->Driver.ResizeBuffers)
- ctx->Driver.ResizeBuffers(ctx, fb, width, height);
- fb->Initialized = GL_TRUE;
- }
-}
-
-
-/**
* Check if the viewport/scissor size has not yet been initialized.
* Initialize the size if the given width and height are non-zero.
*/
@@ -1508,32 +1489,6 @@ _mesa_make_current( struct gl_context *newCtx,
*/
newCtx->NewState |= _NEW_BUFFERS;
-#if 1
- /* We want to get rid of these lines: */
- if (!drawBuffer->Initialized) {
- initialize_framebuffer_size(newCtx, drawBuffer);
- }
- if (readBuffer != drawBuffer && !readBuffer->Initialized) {
- initialize_framebuffer_size(newCtx, readBuffer);
- }
-
- _mesa_resizebuffers(newCtx);
-#else
- /* We want the drawBuffer and readBuffer to be initialized by
- * the driver.
- * This generally means the Width and Height match the actual
- * window size and the renderbuffers (both hardware and software
- * based) are allocated to match. The later can generally be
- * done with a call to _mesa_resize_framebuffer().
- *
- * It's theoretically possible for a buffer to have zero width
- * or height, but for now, assert check that the driver did what's
- * expected of it.
- */
- ASSERT(drawBuffer->Width > 0);
- ASSERT(drawBuffer->Height > 0);
-#endif
-
if (drawBuffer) {
_mesa_check_init_viewport(newCtx,
drawBuffer->Width, drawBuffer->Height);
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index e2519780a..c1d9b2c95 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -93,15 +93,6 @@ struct dd_function_table {
void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state );
/**
- * Get the width and height of the named buffer/window.
- *
- * Mesa uses this to determine when the driver's window size has changed.
- * XXX OBSOLETE: this function will be removed in the future.
- */
- void (*GetBufferSize)( struct gl_framebuffer *buffer,
- GLuint *width, GLuint *height );
-
- /**
* Resize the given framebuffer to the given size.
* XXX OBSOLETE: this function will be removed in the future.
*/
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index cc652bac8..465420766 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -659,11 +659,11 @@ _mesa_DebugMessageControlARB(GLenum gl_source, GLenum gl_type,
}
void GLAPIENTRY
-_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const GLvoid *userParam)
+_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, GLvoid *userParam)
{
GET_CURRENT_CONTEXT(ctx);
ctx->Debug.Callback = callback;
- ctx->Debug.CallbackData = (void *) userParam;
+ ctx->Debug.CallbackData = userParam;
}
void
diff --git a/mesalib/src/mesa/main/errors.h b/mesalib/src/mesa/main/errors.h
index 7e7503aa9..4b376fb60 100644
--- a/mesalib/src/mesa/main/errors.h
+++ b/mesalib/src/mesa/main/errors.h
@@ -101,7 +101,7 @@ _mesa_DebugMessageControlARB(GLenum source, GLenum type, GLenum severity,
GLboolean enabled);
void GLAPIENTRY
_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback,
- const GLvoid *userParam);
+ GLvoid *userParam);
#ifdef __cplusplus
}
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index fc6fbadec..2ba4475c9 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -174,7 +174,6 @@ static const struct extension extension_table[] = {
{ "GL_EXT_discard_framebuffer", o(EXT_framebuffer_object), ES1 | ES2, 2009 },
{ "GL_EXT_blend_minmax", o(EXT_blend_minmax), GLL | ES1 | ES2, 1995 },
{ "GL_EXT_blend_subtract", o(dummy_true), GLL, 1995 },
- { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL, 1996 },
{ "GL_EXT_compiled_vertex_array", o(dummy_true), GLL, 1996 },
{ "GL_EXT_copy_texture", o(dummy_true), GLL, 1995 },
{ "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL, 2002 },
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index d162da8db..86317efcd 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -51,7 +51,6 @@ extern "C" {
#include "../glsl/glsl_symbol_table.h"
#include "../glsl/glsl_parser_extras.h"
#include "../glsl/ir_optimization.h"
-#include "../glsl/ir_print_visitor.h"
#include "../program/ir_to_mesa.h"
using namespace ir_builder;
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index 1906a8a55..d28882ac4 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -319,81 +319,12 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
}
}
-
-
-/**
- * XXX THIS IS OBSOLETE - drivers should take care of detecting window
- * size changes and act accordingly, likely calling _mesa_resize_framebuffer().
- *
- * GL_MESA_resize_buffers extension.
- *
- * When this function is called, we'll ask the window system how large
- * the current window is. If it's a new size, we'll call the driver's
- * ResizeBuffers function. The driver will then resize its color buffers
- * as needed, and maybe call the swrast's routine for reallocating
- * swrast-managed depth/stencil/accum/etc buffers.
- * \note This function should only be called through the GL API, not
- * from device drivers (as was done in the past).
- */
-void
-_mesa_resizebuffers( struct gl_context *ctx )
-{
- FLUSH_VERTICES(ctx, 0);
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glResizeBuffersMESA\n");
-
- if (!ctx->Driver.GetBufferSize) {
- return;
- }
-
- if (ctx->WinSysDrawBuffer) {
- GLuint newWidth, newHeight;
- struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer;
-
- assert(_mesa_is_winsys_fbo(buffer));
-
- /* ask device driver for size of output buffer */
- ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
-
- /* see if size of device driver's color buffer (window) has changed */
- if (buffer->Width != newWidth || buffer->Height != newHeight) {
- if (ctx->Driver.ResizeBuffers)
- ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight );
- }
- }
-
- if (ctx->WinSysReadBuffer
- && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) {
- GLuint newWidth, newHeight;
- struct gl_framebuffer *buffer = ctx->WinSysReadBuffer;
-
- assert(_mesa_is_winsys_fbo(buffer));
-
- /* ask device driver for size of read buffer */
- ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
-
- /* see if size of device driver's color buffer (window) has changed */
- if (buffer->Width != newWidth || buffer->Height != newHeight) {
- if (ctx->Driver.ResizeBuffers)
- ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight );
- }
- }
-
- ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
-}
-
-
/*
* XXX THIS IS OBSOLETE
*/
void GLAPIENTRY
_mesa_ResizeBuffersMESA( void )
{
- GET_CURRENT_CONTEXT(ctx);
-
- if (ctx->Extensions.MESA_resize_buffers)
- _mesa_resizebuffers( ctx );
}
diff --git a/mesalib/src/mesa/main/hint.c b/mesalib/src/mesa/main/hint.c
index 6d3e58d58..3e056ebaf 100644
--- a/mesalib/src/mesa/main/hint.c
+++ b/mesalib/src/mesa/main/hint.c
@@ -90,16 +90,6 @@ _mesa_Hint( GLenum target, GLenum mode )
ctx->Hint.PolygonSmooth = mode;
break;
- /* GL_EXT_clip_volume_hint */
- case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
- if (ctx->API != API_OPENGL_COMPAT)
- goto invalid_target;
- if (ctx->Hint.ClipVolumeClipping == mode)
- return;
- FLUSH_VERTICES(ctx, _NEW_HINT);
- ctx->Hint.ClipVolumeClipping = mode;
- break;
-
/* GL_ARB_texture_compression */
case GL_TEXTURE_COMPRESSION_HINT_ARB:
if (!_mesa_is_desktop_gl(ctx))
@@ -158,7 +148,6 @@ void _mesa_init_hint( struct gl_context * ctx )
ctx->Hint.LineSmooth = GL_DONT_CARE;
ctx->Hint.PolygonSmooth = GL_DONT_CARE;
ctx->Hint.Fog = GL_DONT_CARE;
- ctx->Hint.ClipVolumeClipping = GL_DONT_CARE;
ctx->Hint.TextureCompression = GL_DONT_CARE;
ctx->Hint.GenerateMipmap = GL_DONT_CARE;
ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE;
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 0002da5c0..df2d20b3a 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -794,7 +794,6 @@ struct gl_hint_attrib
GLenum LineSmooth;
GLenum PolygonSmooth;
GLenum Fog;
- GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
GLenum TextureCompression; /**< GL_ARB_texture_compression */
GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
@@ -2680,8 +2679,6 @@ struct gl_framebuffer
*/
struct gl_config Visual;
- GLboolean Initialized;
-
GLuint Width, Height; /**< size of frame buffer in pixels */
/** \name Drawing bounds (Intersection of buffer size and scissor box) */
@@ -3055,7 +3052,6 @@ struct gl_extensions
GLboolean EXT_blend_equation_separate;
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_minmax;
- GLboolean EXT_clip_volume_hint;
GLboolean EXT_depth_bounds_test;
GLboolean EXT_draw_buffers2;
GLboolean EXT_fog_coord;
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 8cb02760b..4cc0357b1 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -48,11 +48,14 @@
#include "main/transformfeedback.h"
#include "main/uniforms.h"
#include "program/program.h"
+#include "program/prog_print.h"
#include "program/prog_parameter.h"
#include "ralloc.h"
#include <stdbool.h>
#include "../glsl/glsl_parser_extras.h"
+#include "../glsl/ir.h"
#include "../glsl/ir_uniform.h"
+#include "../glsl/program.h"
/** Define this to enable shader substitution (see below) */
#define SHADER_SUBST 0
@@ -743,10 +746,42 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
/* set default pragma state for shader */
sh->Pragmas = options->DefaultPragmas;
- /* this call will set the sh->CompileStatus field to indicate if
- * compilation was successful.
- */
- _mesa_glsl_compile_shader(ctx, sh);
+ if (!sh->Source) {
+ /* If the user called glCompileShader without first calling
+ * glShaderSource, we should fail to compile, but not raise a GL_ERROR.
+ */
+ sh->CompileStatus = GL_FALSE;
+ } else {
+ if (ctx->Shader.Flags & GLSL_DUMP) {
+ printf("GLSL source for %s shader %d:\n",
+ _mesa_glsl_shader_target_name(sh->Type), sh->Name);
+ printf("%s\n", sh->Source);
+ }
+
+ /* this call will set the shader->CompileStatus field to indicate if
+ * compilation was successful.
+ */
+ _mesa_glsl_compile_shader(ctx, sh, false, false);
+
+ if (ctx->Shader.Flags & GLSL_LOG) {
+ _mesa_write_shader_to_file(sh);
+ }
+
+ if (ctx->Shader.Flags & GLSL_DUMP) {
+ if (sh->CompileStatus) {
+ printf("GLSL IR for shader %d:\n", sh->Name);
+ _mesa_print_ir(sh->ir, NULL);
+ printf("\n\n");
+ } else {
+ printf("GLSL shader %d failed to compile.\n", sh->Name);
+ }
+ if (sh->InfoLog && sh->InfoLog[0] != 0) {
+ printf("GLSL shader %d info log:\n", sh->Name);
+ printf("%s\n", sh->InfoLog);
+ }
+ }
+
+ }
if (sh->CompileStatus == GL_FALSE &&
(ctx->Shader.Flags & GLSL_REPORT_ERRORS)) {
@@ -816,21 +851,8 @@ print_shader_info(const struct gl_shader_program *shProg)
printf("Mesa: glUseProgram(%u)\n", shProg->Name);
for (i = 0; i < shProg->NumShaders; i++) {
- const char *s;
- switch (shProg->Shaders[i]->Type) {
- case GL_VERTEX_SHADER:
- s = "vertex";
- break;
- case GL_FRAGMENT_SHADER:
- s = "fragment";
- break;
- case GL_GEOMETRY_SHADER:
- s = "geometry";
- break;
- default:
- s = "";
- }
- printf(" %s shader %u, checksum %u\n", s,
+ printf(" %s shader %u, checksum %u\n",
+ _mesa_glsl_shader_target_name(shProg->Shaders[i]->Type),
shProg->Shaders[i]->Name,
shProg->Shaders[i]->SourceChecksum);
}
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index 296f80f17..3c460042e 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -33,6 +33,7 @@
#include "program/hash_table.h"
#include "../glsl/program.h"
#include "../glsl/ir_uniform.h"
+#include "../glsl/glsl_parser_extras.h"
#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "uniforms.h"
@@ -434,12 +435,6 @@ log_uniform(const void *values, enum glsl_base_type basicType,
static void
log_program_parameters(const struct gl_shader_program *shProg)
{
- static const char *stages[] = {
- "vertex", "fragment", "geometry"
- };
-
- assert(Elements(stages) == MESA_SHADER_TYPES);
-
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (shProg->_LinkedShaders[i] == NULL)
continue;
@@ -447,7 +442,7 @@ log_program_parameters(const struct gl_shader_program *shProg)
const struct gl_program *const prog = shProg->_LinkedShaders[i]->Program;
printf("Program %d %s shader parameters:\n",
- shProg->Name, stages[i]);
+ shProg->Name, _mesa_glsl_shader_target_name(prog->Target));
for (unsigned j = 0; j < prog->Parameters->NumParameters; j++) {
printf("%s: %p %f %f %f %f\n",
prog->Parameters->Parameters[j].Name,
diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h
index 14fe26d5f..92239176e 100644
--- a/mesalib/src/mesa/main/uniforms.h
+++ b/mesalib/src/mesa/main/uniforms.h
@@ -272,7 +272,7 @@ static inline GLint
_mesa_uniform_merge_location_offset(const struct gl_shader_program *prog,
unsigned base_location, unsigned offset)
{
- assert(prog->UniformLocationBaseScale >= 0);
+ assert(prog->UniformLocationBaseScale >= 1);
assert(offset < prog->UniformLocationBaseScale);
return (base_location * prog->UniformLocationBaseScale) + offset;
}
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index a5b6699c2..35a9b8437 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -33,7 +33,6 @@
#include "main/compiler.h"
#include "ir.h"
#include "ir_visitor.h"
-#include "ir_print_visitor.h"
#include "ir_expression_flattening.h"
#include "ir_uniform.h"
#include "glsl_types.h"
@@ -1057,9 +1056,9 @@ ir_to_mesa_visitor::emit_swz(ir_expression *ir)
this->result.file = PROGRAM_UNDEFINED;
deref->accept(this);
if (this->result.file == PROGRAM_UNDEFINED) {
- ir_print_visitor v;
printf("Failed to get tree for expression operand:\n");
- deref->accept(&v);
+ deref->print();
+ printf("\n");
exit(1);
}
@@ -1129,9 +1128,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
this->result.file = PROGRAM_UNDEFINED;
ir->operands[operand]->accept(this);
if (this->result.file == PROGRAM_UNDEFINED) {
- ir_print_visitor v;
printf("Failed to get tree for expression operand:\n");
- ir->operands[operand]->accept(&v);
+ ir->operands[operand]->print();
+ printf("\n");
exit(1);
}
op[operand] = this->result;
@@ -2811,22 +2810,19 @@ get_mesa_program(struct gl_context *ctx,
int i;
struct gl_program *prog;
GLenum target;
- const char *target_string;
+ const char *target_string = _mesa_glsl_shader_target_name(shader->Type);
struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
switch (shader->Type) {
case GL_VERTEX_SHADER:
target = GL_VERTEX_PROGRAM_ARB;
- target_string = "vertex";
break;
case GL_FRAGMENT_SHADER:
target = GL_FRAGMENT_PROGRAM_ARB;
- target_string = "fragment";
break;
case GL_GEOMETRY_SHADER:
target = GL_GEOMETRY_PROGRAM_NV;
- target_string = "geometry";
break;
default:
assert(!"should not be reached");
@@ -3101,99 +3097,6 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
return prog->LinkStatus;
}
-
-/**
- * Compile a GLSL shader. Called via glCompileShader().
- */
-void
-_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
-{
- struct _mesa_glsl_parse_state *state =
- new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
-
- const char *source = shader->Source;
- /* Check if the user called glCompileShader without first calling
- * glShaderSource. This should fail to compile, but not raise a GL_ERROR.
- */
- if (source == NULL) {
- shader->CompileStatus = GL_FALSE;
- return;
- }
-
- state->error = glcpp_preprocess(state, &source, &state->info_log,
- &ctx->Extensions, ctx);
-
- if (ctx->Shader.Flags & GLSL_DUMP) {
- printf("GLSL source for %s shader %d:\n",
- _mesa_glsl_shader_target_name(state->target), shader->Name);
- printf("%s\n", shader->Source);
- }
-
- if (!state->error) {
- _mesa_glsl_lexer_ctor(state, source);
- _mesa_glsl_parse(state);
- _mesa_glsl_lexer_dtor(state);
- }
-
- ralloc_free(shader->ir);
- shader->ir = new(shader) exec_list;
- if (!state->error && !state->translation_unit.is_empty())
- _mesa_ast_to_hir(shader->ir, state);
-
- if (!state->error && !shader->ir->is_empty()) {
- validate_ir_tree(shader->ir);
- struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
-
- /* Do some optimization at compile time to reduce shader IR size
- * and reduce later work if the same shader is linked multiple times
- */
- while (do_common_optimization(shader->ir, false, false, 32, options))
- ;
-
- validate_ir_tree(shader->ir);
- }
-
- shader->symbols = state->symbols;
-
- shader->CompileStatus = !state->error;
- shader->InfoLog = state->info_log;
- shader->Version = state->language_version;
- memcpy(shader->builtins_to_link, state->builtins_to_link,
- sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link);
- shader->num_builtins_to_link = state->num_builtins_to_link;
-
- if (ctx->Shader.Flags & GLSL_LOG) {
- _mesa_write_shader_to_file(shader);
- }
-
- if (ctx->Shader.Flags & GLSL_DUMP) {
- if (shader->CompileStatus) {
- printf("GLSL IR for shader %d:\n", shader->Name);
- _mesa_print_ir(shader->ir, NULL);
- printf("\n\n");
- } else {
- printf("GLSL shader %d failed to compile.\n", shader->Name);
- }
- if (shader->InfoLog && shader->InfoLog[0] != 0) {
- printf("GLSL shader %d info log:\n", shader->Name);
- printf("%s\n", shader->InfoLog);
- }
- }
-
- if (shader->UniformBlocks)
- ralloc_free(shader->UniformBlocks);
- shader->NumUniformBlocks = state->num_uniform_blocks;
- shader->UniformBlocks = state->uniform_blocks;
- ralloc_steal(shader, shader->UniformBlocks);
-
- /* Retain any live IR, but trash the rest. */
- reparent_ir(shader->ir, shader->ir);
-
- ralloc_free(state);
-}
-
-
/**
* Link a GLSL shader program. Called via glLinkProgram().
*/
diff --git a/mesalib/src/mesa/program/ir_to_mesa.h b/mesalib/src/mesa/program/ir_to_mesa.h
index aa053d9c8..2488a4582 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.h
+++ b/mesalib/src/mesa/program/ir_to_mesa.h
@@ -33,7 +33,6 @@ struct gl_context;
struct gl_shader;
struct gl_shader_program;
-void _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *sh);
void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
GLboolean _mesa_ir_compile_shader(struct gl_context *ctx, struct gl_shader *shader);
GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c
index 16739fd39..4eed0b5aa 100644
--- a/mesalib/src/mesa/program/register_allocate.c
+++ b/mesalib/src/mesa/program/register_allocate.c
@@ -157,6 +157,16 @@ struct ra_graph {
unsigned int *stack;
unsigned int stack_count;
+
+ /**
+ * Tracks the start of the set of optimistically-colored registers in the
+ * stack.
+ *
+ * Along with any registers not in the stack (if one called ra_simplify()
+ * and didn't do optimistic coloring), these need to be considered for
+ * spilling.
+ */
+ unsigned int stack_optimistic_start;
};
/**
@@ -509,6 +519,7 @@ ra_optimistic_color(struct ra_graph *g)
{
unsigned int i;
+ g->stack_optimistic_start = g->stack_count;
for (i = 0; i < g->count; i++) {
if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG)
continue;
@@ -587,8 +598,16 @@ ra_get_best_spill_node(struct ra_graph *g)
{
unsigned int best_node = -1;
float best_benefit = 0.0;
- unsigned int n;
+ unsigned int n, i;
+ /* For any registers not in the stack to be colored, consider them for
+ * spilling. This will mostly collect nodes that were being optimistally
+ * colored as part of ra_allocate_no_spills() if we didn't successfully
+ * optimistically color.
+ *
+ * It also includes nodes not trivially colorable by ra_simplify() if it
+ * was used directly instead of as part of ra_allocate_no_spills().
+ */
for (n = 0; n < g->count; n++) {
float cost = g->nodes[n].spill_cost;
float benefit;
@@ -596,10 +615,6 @@ ra_get_best_spill_node(struct ra_graph *g)
if (cost <= 0.0)
continue;
- /* Only consider registers for spilling if they are still in the
- * interference graph (those on the stack have already been proven to be
- * allocatable without spilling).
- */
if (g->nodes[n].in_stack)
continue;
@@ -611,6 +626,26 @@ ra_get_best_spill_node(struct ra_graph *g)
}
}
+ /* Also consider spilling any nodes that were set up to be optimistically
+ * colored that we couldn't manage to color in ra_select().
+ */
+ for (i = g->stack_optimistic_start; i < g->stack_count; i++) {
+ float cost, benefit;
+
+ n = g->stack[i];
+ cost = g->nodes[n].spill_cost;
+
+ if (cost <= 0.0)
+ continue;
+
+ benefit = ra_get_spill_benefit(g, n);
+
+ if (benefit / cost > best_benefit) {
+ best_benefit = benefit / cost;
+ best_node = n;
+ }
+ }
+
return best_node;
}
diff --git a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
index 27a910b5f..723ab561c 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
@@ -205,7 +205,7 @@ static void st_bind_ubos(struct st_context *st,
* Take the minimum just to be sure.
*/
if (!binding->AutomaticSize)
- cb.buffer_size = MIN2(cb.buffer_size, binding->Size);
+ cb.buffer_size = MIN2(cb.buffer_size, (unsigned) binding->Size);
}
else {
cb.buffer_offset = 0;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index b8e2fad25..8da664afb 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -346,8 +346,8 @@ is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb)
return ctx->Scissor.Enabled &&
(ctx->Scissor.X > 0 ||
ctx->Scissor.Y > 0 ||
- ctx->Scissor.Width < rb->Width ||
- ctx->Scissor.Height < rb->Height);
+ (unsigned) ctx->Scissor.Width < rb->Width ||
+ (unsigned) ctx->Scissor.Height < rb->Height);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.h b/mesalib/src/mesa/state_tracker/st_cb_fbo.h
index 461dbe985..f335c371b 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.h
@@ -59,7 +59,7 @@ struct st_renderbuffer
void *data;
struct st_texture_object *rtt; /**< GL render to texture's texture */
- int rtt_level, rtt_face, rtt_slice;
+ unsigned rtt_level, rtt_face, rtt_slice;
};
diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
index 9fab113fa..b5df58c03 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
@@ -208,7 +208,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
const uint bytesPerRow = width * util_format_get_blocksize(dst_format);
GLuint row;
- for (row = 0; row < height; row++) {
+ for (row = 0; row < (unsigned) height; row++) {
GLvoid *dest = _mesa_image_address3d(pack, pixels,
width, height, format,
type, 0, row, 0);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 68c334ed8..c167744f4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -734,7 +734,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
const uint bytesPerRow = width * util_format_get_blocksize(src_format);
GLuint row, slice;
- for (slice = 0; slice < depth; slice++) {
+ for (slice = 0; slice < (unsigned) depth; slice++) {
if (gl_target == GL_TEXTURE_1D_ARRAY) {
/* 1D array textures.
* We need to convert gallium coords to GL coords.
@@ -747,7 +747,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
else {
ubyte *slice_map = map;
- for (row = 0; row < height; row++) {
+ for (row = 0; row < (unsigned) height; row++) {
GLvoid *src = _mesa_image_address3d(unpack, pixels,
width, height, format,
type, slice, row, 0);
@@ -1625,7 +1625,7 @@ st_AllocTextureStorage(struct gl_context *ctx,
GLuint ptWidth, ptHeight, ptDepth, ptLayers, bindings;
enum pipe_format fmt;
GLint level;
- int num_samples = texImage->NumSamples;
+ GLuint num_samples = texImage->NumSamples;
assert(levels > 0);
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 56f3a4a48..16d977fc9 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -55,21 +55,21 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
{
switch (mesaFormat) {
case MESA_FORMAT_RGBA8888:
- return PIPE_FORMAT_A8B8G8R8_UNORM;
+ return PIPE_FORMAT_ABGR8888_UNORM;
case MESA_FORMAT_RGBA8888_REV:
- return PIPE_FORMAT_R8G8B8A8_UNORM;
+ return PIPE_FORMAT_RGBA8888_UNORM;
case MESA_FORMAT_ARGB8888:
- return PIPE_FORMAT_B8G8R8A8_UNORM;
+ return PIPE_FORMAT_BGRA8888_UNORM;
case MESA_FORMAT_ARGB8888_REV:
- return PIPE_FORMAT_A8R8G8B8_UNORM;
+ return PIPE_FORMAT_ARGB8888_UNORM;
case MESA_FORMAT_RGBX8888:
- return PIPE_FORMAT_X8B8G8R8_UNORM;
+ return PIPE_FORMAT_XBGR8888_UNORM;
case MESA_FORMAT_RGBX8888_REV:
- return PIPE_FORMAT_R8G8B8X8_UNORM;
+ return PIPE_FORMAT_RGBX8888_UNORM;
case MESA_FORMAT_XRGB8888:
- return PIPE_FORMAT_B8G8R8X8_UNORM;
+ return PIPE_FORMAT_BGRX8888_UNORM;
case MESA_FORMAT_XRGB8888_REV:
- return PIPE_FORMAT_X8R8G8B8_UNORM;
+ return PIPE_FORMAT_XRGB8888_UNORM;
case MESA_FORMAT_ARGB1555:
return PIPE_FORMAT_B5G5R5A1_UNORM;
case MESA_FORMAT_ARGB4444:
@@ -401,21 +401,21 @@ gl_format
st_pipe_format_to_mesa_format(enum pipe_format format)
{
switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_ABGR8888_UNORM:
return MESA_FORMAT_RGBA8888;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
+ case PIPE_FORMAT_RGBA8888_UNORM:
return MESA_FORMAT_RGBA8888_REV;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_BGRA8888_UNORM:
return MESA_FORMAT_ARGB8888;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_ARGB8888_UNORM:
return MESA_FORMAT_ARGB8888_REV;
- case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_XBGR8888_UNORM:
return MESA_FORMAT_RGBX8888;
- case PIPE_FORMAT_R8G8B8X8_UNORM:
+ case PIPE_FORMAT_RGBX8888_UNORM:
return MESA_FORMAT_RGBX8888_REV;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_BGRX8888_UNORM:
return MESA_FORMAT_XRGB8888;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_XRGB8888_UNORM:
return MESA_FORMAT_XRGB8888_REV;
case PIPE_FORMAT_B5G5R5A1_UNORM:
return MESA_FORMAT_ARGB1555;
@@ -1521,12 +1521,12 @@ struct exact_format_mapping
static const struct exact_format_mapping rgba8888_tbl[] =
{
- { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_A8B8G8R8_UNORM },
- { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_A8B8G8R8_UNORM },
- { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_R8G8B8A8_UNORM },
- { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_R8G8B8A8_UNORM },
- { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_A8R8G8B8_UNORM },
- { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_B8G8R8A8_UNORM },
+ { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_ABGR8888_UNORM },
+ { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_ABGR8888_UNORM },
+ { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_RGBA8888_UNORM },
+ { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_RGBA8888_UNORM },
+ { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_ARGB8888_UNORM },
+ { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_BGRA8888_UNORM },
{ GL_RGBA, GL_UNSIGNED_BYTE, PIPE_FORMAT_R8G8B8A8_UNORM },
{ GL_ABGR_EXT, GL_UNSIGNED_BYTE, PIPE_FORMAT_A8B8G8R8_UNORM },
{ GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8A8_UNORM },
@@ -1535,15 +1535,15 @@ static const struct exact_format_mapping rgba8888_tbl[] =
static const struct exact_format_mapping rgbx8888_tbl[] =
{
- { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8R8G8B8_UNORM },
- { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_B8G8R8X8_UNORM },
- { GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8X8_UNORM },
- { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8B8G8R8_UNORM },
- { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_X8B8G8R8_UNORM },
- { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_R8G8B8X8_UNORM },
- { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_R8G8B8X8_UNORM },
+ { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_XBGR8888_UNORM },
+ { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_XBGR8888_UNORM },
+ { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_RGBX8888_UNORM },
+ { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_RGBX8888_UNORM },
+ { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_XRGB8888_UNORM },
+ { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_BGRX8888_UNORM },
{ GL_RGBA, GL_UNSIGNED_BYTE, PIPE_FORMAT_R8G8B8X8_UNORM },
{ GL_ABGR_EXT, GL_UNSIGNED_BYTE, PIPE_FORMAT_X8B8G8R8_UNORM },
+ { GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8X8_UNORM },
{ 0, 0, 0 }
};
diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
index e5512af2a..d01a21ebf 100644
--- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
@@ -118,7 +118,7 @@ compute_num_levels(struct gl_context *ctx,
baseImage = _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel);
numLevels = texObj->BaseLevel + baseImage->MaxNumLevels;
- numLevels = MIN2(numLevels, texObj->MaxLevel + 1);
+ numLevels = MIN2(numLevels, (GLuint) texObj->MaxLevel + 1);
assert(numLevels >= 1);
return numLevels;
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index d6796d7a1..32bc2b37b 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -34,7 +34,6 @@
#include "main/compiler.h"
#include "ir.h"
#include "ir_visitor.h"
-#include "ir_print_visitor.h"
#include "ir_expression_flattening.h"
#include "glsl_types.h"
#include "glsl_parser_extras.h"
@@ -1396,9 +1395,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
this->result.file = PROGRAM_UNDEFINED;
ir->operands[operand]->accept(this);
if (this->result.file == PROGRAM_UNDEFINED) {
- ir_print_visitor v;
printf("Failed to get tree for expression operand:\n");
- ir->operands[operand]->accept(&v);
+ ir->operands[operand]->print();
+ printf("\n");
exit(1);
}
op[operand] = this->result;
@@ -4995,7 +4994,6 @@ get_mesa_program(struct gl_context *ctx,
glsl_to_tgsi_visitor* v;
struct gl_program *prog;
GLenum target;
- const char *target_string;
bool progress;
struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
@@ -5006,17 +5004,14 @@ get_mesa_program(struct gl_context *ctx,
case GL_VERTEX_SHADER:
target = GL_VERTEX_PROGRAM_ARB;
ptarget = PIPE_SHADER_VERTEX;
- target_string = "vertex";
break;
case GL_FRAGMENT_SHADER:
target = GL_FRAGMENT_PROGRAM_ARB;
ptarget = PIPE_SHADER_FRAGMENT;
- target_string = "fragment";
break;
case GL_GEOMETRY_SHADER:
target = GL_GEOMETRY_PROGRAM_NV;
ptarget = PIPE_SHADER_GEOMETRY;
- target_string = "geometry";
break;
default:
assert(!"should not be reached");
@@ -5106,7 +5101,8 @@ get_mesa_program(struct gl_context *ctx,
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("\n");
- printf("GLSL IR for linked %s program %d:\n", target_string,
+ printf("GLSL IR for linked %s program %d:\n",
+ _mesa_glsl_shader_target_name(shader->Type),
shader_program->Name);
_mesa_print_ir(shader->ir, NULL);
printf("\n");
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index ec876087c..9c2b4d24e 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -431,8 +431,6 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi)
stfb->stamp = 0;
st_framebuffer_update_attachments(stfb);
- stfb->Base.Initialized = GL_TRUE;
-
return stfb;
}
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 9dadd0421..75831faf9 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -1371,7 +1371,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
static void GLAPIENTRY
vbo_exec_MultiDrawElements(GLenum mode,
const GLsizei *count, GLenum type,
- const GLvoid **indices,
+ const GLvoid * const *indices,
GLsizei primcount)
{
GET_CURRENT_CONTEXT(ctx);
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index 26951bd94..2028d8b2c 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -1182,7 +1182,7 @@ _save_OBE_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
static void GLAPIENTRY
_save_OBE_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
- const GLvoid **indices, GLsizei primcount)
+ const GLvoid * const *indices, GLsizei primcount)
{
GLsizei i;